diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-07-27 13:32:59 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-07-27 13:32:59 -0300 |
| commit | 0acd55898d0aaae8dbc14c8a1bc1e3bdffc8701b (patch) | |
| tree | 0ac634fed90877130b1f102bf4075af999de2158 /lmathlib.c | |
| parent | 15231d4fb2f6984b25e0353ff46eda1a180b686d (diff) | |
| download | lua-0acd55898d0aaae8dbc14c8a1bc1e3bdffc8701b.tar.gz lua-0acd55898d0aaae8dbc14c8a1bc1e3bdffc8701b.tar.bz2 lua-0acd55898d0aaae8dbc14c8a1bc1e3bdffc8701b.zip | |
Added gcc option '-Wconversion'
No warnings for standard numerical types. Still pending alternative
numerical types.
Diffstat (limited to 'lmathlib.c')
| -rw-r--r-- | lmathlib.c | 12 |
1 files changed, 6 insertions, 6 deletions
| @@ -578,7 +578,7 @@ static int math_random (lua_State *L) { | |||
| 578 | low = 1; | 578 | low = 1; |
| 579 | up = luaL_checkinteger(L, 1); | 579 | up = luaL_checkinteger(L, 1); |
| 580 | if (up == 0) { /* single 0 as argument? */ | 580 | if (up == 0) { /* single 0 as argument? */ |
| 581 | lua_pushinteger(L, I2UInt(rv)); /* full random integer */ | 581 | lua_pushinteger(L, l_castU2S(I2UInt(rv))); /* full random integer */ |
| 582 | return 1; | 582 | return 1; |
| 583 | } | 583 | } |
| 584 | break; | 584 | break; |
| @@ -594,7 +594,7 @@ static int math_random (lua_State *L) { | |||
| 594 | luaL_argcheck(L, low <= up, 1, "interval is empty"); | 594 | luaL_argcheck(L, low <= up, 1, "interval is empty"); |
| 595 | /* project random integer into the interval [0, up - low] */ | 595 | /* project random integer into the interval [0, up - low] */ |
| 596 | p = project(I2UInt(rv), (lua_Unsigned)up - (lua_Unsigned)low, state); | 596 | p = project(I2UInt(rv), (lua_Unsigned)up - (lua_Unsigned)low, state); |
| 597 | lua_pushinteger(L, p + (lua_Unsigned)low); | 597 | lua_pushinteger(L, l_castU2S(p) + low); |
| 598 | return 1; | 598 | return 1; |
| 599 | } | 599 | } |
| 600 | 600 | ||
| @@ -608,8 +608,8 @@ static void setseed (lua_State *L, Rand64 *state, | |||
| 608 | state[3] = Int2I(0); | 608 | state[3] = Int2I(0); |
| 609 | for (i = 0; i < 16; i++) | 609 | for (i = 0; i < 16; i++) |
| 610 | nextrand(state); /* discard initial values to "spread" seed */ | 610 | nextrand(state); /* discard initial values to "spread" seed */ |
| 611 | lua_pushinteger(L, n1); | 611 | lua_pushinteger(L, l_castU2S(n1)); |
| 612 | lua_pushinteger(L, n2); | 612 | lua_pushinteger(L, l_castU2S(n2)); |
| 613 | } | 613 | } |
| 614 | 614 | ||
| 615 | 615 | ||
| @@ -621,8 +621,8 @@ static int math_randomseed (lua_State *L) { | |||
| 621 | n2 = I2UInt(nextrand(state->s)); /* in case seed is not that random... */ | 621 | n2 = I2UInt(nextrand(state->s)); /* in case seed is not that random... */ |
| 622 | } | 622 | } |
| 623 | else { | 623 | else { |
| 624 | n1 = luaL_checkinteger(L, 1); | 624 | n1 = l_castS2U(luaL_checkinteger(L, 1)); |
| 625 | n2 = luaL_optinteger(L, 2, 0); | 625 | n2 = l_castS2U(luaL_optinteger(L, 2, 0)); |
| 626 | } | 626 | } |
| 627 | setseed(L, state->s, n1, n2); | 627 | setseed(L, state->s, n1, n2); |
| 628 | return 2; /* return seeds */ | 628 | return 2; /* return seeds */ |
