aboutsummaryrefslogtreecommitdiff
path: root/ldump.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2024-07-27 13:32:59 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2024-07-27 13:32:59 -0300
commit0acd55898d0aaae8dbc14c8a1bc1e3bdffc8701b (patch)
tree0ac634fed90877130b1f102bf4075af999de2158 /ldump.c
parent15231d4fb2f6984b25e0353ff46eda1a180b686d (diff)
downloadlua-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 'ldump.c')
-rw-r--r--ldump.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/ldump.c b/ldump.c
index a1e09856..71d9a5b1 100644
--- a/ldump.c
+++ b/ldump.c
@@ -27,7 +27,7 @@ typedef struct {
27 lua_State *L; 27 lua_State *L;
28 lua_Writer writer; 28 lua_Writer writer;
29 void *data; 29 void *data;
30 lu_mem offset; /* current position relative to beginning of dump */ 30 size_t offset; /* current position relative to beginning of dump */
31 int strip; 31 int strip;
32 int status; 32 int status;
33 Table *h; /* table to track saved strings */ 33 Table *h; /* table to track saved strings */
@@ -63,11 +63,11 @@ static void dumpBlock (DumpState *D, const void *b, size_t size) {
63** Dump enough zeros to ensure that current position is a multiple of 63** Dump enough zeros to ensure that current position is a multiple of
64** 'align'. 64** 'align'.
65*/ 65*/
66static void dumpAlign (DumpState *D, int align) { 66static void dumpAlign (DumpState *D, unsigned align) {
67 int padding = align - (D->offset % align); 67 unsigned padding = align - cast_uint(D->offset % align);
68 if (padding < align) { /* padding == align means no padding */ 68 if (padding < align) { /* padding == align means no padding */
69 static lua_Integer paddingContent = 0; 69 static lua_Integer paddingContent = 0;
70 lua_assert(cast_uint(align) <= sizeof(lua_Integer)); 70 lua_assert(align <= sizeof(lua_Integer));
71 dumpBlock(D, &paddingContent, padding); 71 dumpBlock(D, &paddingContent, padding);
72 } 72 }
73 lua_assert(D->offset % align == 0); 73 lua_assert(D->offset % align == 0);
@@ -94,10 +94,10 @@ static void dumpByte (DumpState *D, int y) {
94*/ 94*/
95static void dumpVarint (DumpState *D, size_t x) { 95static void dumpVarint (DumpState *D, size_t x) {
96 lu_byte buff[DIBS]; 96 lu_byte buff[DIBS];
97 int n = 1; 97 unsigned n = 1;
98 buff[DIBS - 1] = x & 0x7f; /* fill least-significant byte */ 98 buff[DIBS - 1] = x & 0x7f; /* fill least-significant byte */
99 while ((x >>= 7) != 0) /* fill other bytes in reverse order */ 99 while ((x >>= 7) != 0) /* fill other bytes in reverse order */
100 buff[DIBS - (++n)] = (x & 0x7f) | 0x80; 100 buff[DIBS - (++n)] = cast_byte((x & 0x7f) | 0x80);
101 dumpVector(D, buff + DIBS - n, n); 101 dumpVector(D, buff + DIBS - n, n);
102} 102}
103 103
@@ -159,7 +159,7 @@ static void dumpCode (DumpState *D, const Proto *f) {
159 dumpInt(D, f->sizecode); 159 dumpInt(D, f->sizecode);
160 dumpAlign(D, sizeof(f->code[0])); 160 dumpAlign(D, sizeof(f->code[0]));
161 lua_assert(f->code != NULL); 161 lua_assert(f->code != NULL);
162 dumpVector(D, f->code, f->sizecode); 162 dumpVector(D, f->code, cast_uint(f->sizecode));
163} 163}
164 164
165 165
@@ -216,13 +216,13 @@ static void dumpDebug (DumpState *D, const Proto *f) {
216 n = (D->strip) ? 0 : f->sizelineinfo; 216 n = (D->strip) ? 0 : f->sizelineinfo;
217 dumpInt(D, n); 217 dumpInt(D, n);
218 if (f->lineinfo != NULL) 218 if (f->lineinfo != NULL)
219 dumpVector(D, f->lineinfo, n); 219 dumpVector(D, f->lineinfo, cast_uint(n));
220 n = (D->strip) ? 0 : f->sizeabslineinfo; 220 n = (D->strip) ? 0 : f->sizeabslineinfo;
221 dumpInt(D, n); 221 dumpInt(D, n);
222 if (n > 0) { 222 if (n > 0) {
223 /* 'abslineinfo' is an array of structures of int's */ 223 /* 'abslineinfo' is an array of structures of int's */
224 dumpAlign(D, sizeof(int)); 224 dumpAlign(D, sizeof(int));
225 dumpVector(D, f->abslineinfo, n); 225 dumpVector(D, f->abslineinfo, cast_uint(n));
226 } 226 }
227 n = (D->strip) ? 0 : f->sizelocvars; 227 n = (D->strip) ? 0 : f->sizelocvars;
228 dumpInt(D, n); 228 dumpInt(D, n);