** get field and width arguments for field-manipulation functions, ** checking whether they are valid. ** ('luaL_error' called without 'return' to avoid later warnings about ** 'width' being used uninitialized.) */
| 153 | ** 'width' being used uninitialized.) |
| 154 | */ |
| 155 | static int fieldargs (lua_State *L, int farg, int *width) { |
| 156 | int f = luaL_checkint(L, farg); |
| 157 | int w = luaL_optint(L, farg + 1, 1); |
| 158 | luaL_argcheck(L, 0 <= f, farg, "field cannot be negative"); |
| 159 | luaL_argcheck(L, 0 < w, farg + 1, "width must be positive"); |
| 160 | if (f + w > LUA_NBITS) |
| 161 | luaL_error(L, "trying to access non-existent bits"); |
| 162 | *width = w; |
| 163 | return f; |
| 164 | } |
| 165 | |
| 166 | |
| 167 | static int b_extract (lua_State *L) { |
no test coverage detected