Skip to content

Commit 9c0aa43

Browse files
committed
Use size_t lengths in struct buffer
1 parent 658c7cd commit 9c0aa43

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

nbt.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static struct nbt_tag *nbt_new(char *name, enum nbt_tag_type type)
3636
tag->type = type;
3737
tag->name = name;
3838

39-
int namelen = strlen(name);
39+
size_t namelen = strlen(name);
4040
tag->namelen[0] = namelen >> 8;
4141
tag->namelen[1] = namelen;
4242

@@ -70,7 +70,7 @@ struct nbt_tag *nbt_new_double(char *name, enum nbt_tag_type type, double double
7070
return tag;
7171
}
7272

73-
struct nbt_tag *nbt_new_blob(char *name, enum nbt_tag_type type, const void *data, int len)
73+
struct nbt_tag *nbt_new_blob(char *name, enum nbt_tag_type type, const void *data, size_t len)
7474
{
7575
if (type != NBT_TAG_BLOB && type != NBT_TAG_STR)
7676
dief("nbt_new_blob: bad type: %d", type);
@@ -252,7 +252,7 @@ struct buffer nbt_compress(struct nbt_tag *tag)
252252
return (struct buffer){ clen, cbuf };
253253
}
254254

255-
static struct nbt_tag *parse_tag(uint8_t *data, unsigned len, unsigned *taglen)
255+
static struct nbt_tag *parse_tag(uint8_t *data, size_t len, size_t *taglen)
256256
{
257257
if (len < 1)
258258
die("truncated NBT tag: short type");
@@ -283,7 +283,7 @@ static struct nbt_tag *parse_tag(uint8_t *data, unsigned len, unsigned *taglen)
283283
jbyte tb;
284284

285285
struct nbt_tag *sub;
286-
unsigned sublen;
286+
size_t sublen;
287287

288288
switch (tag->type)
289289
{
@@ -418,7 +418,7 @@ struct nbt_tag *nbt_uncompress(struct buffer buf)
418418
if (arr->len < 3 || memcmp(arr->data, "\x0a\x00", 3) != 0)
419419
die("nbt_uncompress: invalid header in uncompressed NBT");
420420

421-
unsigned t;
421+
size_t t;
422422
struct nbt_tag *tag = parse_tag(arr->data + 3, arr->len - 3, &t);
423423

424424
g_byte_array_unref(arr);

nbt.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ struct nbt_tag *nbt_new_int(char *name, enum nbt_tag_type type, jint intv);
2424
struct nbt_tag *nbt_new_long(char *name, jlong longv);
2525
struct nbt_tag *nbt_new_double(char *name, enum nbt_tag_type type, double doublev);
2626

27-
struct nbt_tag *nbt_new_blob(char *name, enum nbt_tag_type type, const void *data, int len);
27+
struct nbt_tag *nbt_new_blob(char *name, enum nbt_tag_type type, const void *data, size_t len);
2828
struct nbt_tag *nbt_new_str(char *name, const char *str);
2929

3030
struct nbt_tag *nbt_new_struct(char *name);

protocol.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ void packet_dump(packet_t *packet)
628628

629629
case FIELD_STRING:
630630
tb = packet_string(packet, f);
631-
DUMP(" '%.*s'", tb.len, tb.data);
631+
DUMP(" '%.*s'", (int) tb.len, tb.data);
632632
g_free(tb.data);
633633
break;
634634

types.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ typedef struct rgba rgba_t;
8080

8181
struct buffer
8282
{
83-
unsigned len;
83+
size_t len;
8484
unsigned char *data;
8585
};
8686

0 commit comments

Comments
 (0)