Skip to content

Commit

Permalink
Merge pull request #555 from kiyolee/size_t-warnings
Browse files Browse the repository at this point in the history
Fix size_t related MSVC compiler warnings
  • Loading branch information
akheron committed Nov 15, 2020
2 parents a740f15 + 638449c commit cc318fc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions examples/simple_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
void print_json(json_t *root);
void print_json_aux(json_t *element, int indent);
void print_json_indent(int indent);
const char *json_plural(int count);
const char *json_plural(size_t count);
void print_json_object(json_t *element, int indent);
void print_json_array(json_t *element, int indent);
void print_json_string(json_t *element, int indent);
Expand Down Expand Up @@ -80,7 +80,7 @@ void print_json_indent(int indent) {
}
}

const char *json_plural(int count) { return count == 1 ? "" : "s"; }
const char *json_plural(size_t count) { return count == 1 ? "" : "s"; }

void print_json_object(json_t *element, int indent) {
size_t size;
Expand All @@ -90,7 +90,7 @@ void print_json_object(json_t *element, int indent) {
print_json_indent(indent);
size = json_object_size(element);

printf("JSON Object of %ld pair%s:\n", size, json_plural(size));
printf("JSON Object of %lld pair%s:\n", (long long)size, json_plural(size));
json_object_foreach(element, key, value) {
print_json_indent(indent + 2);
printf("JSON Key: \"%s\"\n", key);
Expand All @@ -103,7 +103,7 @@ void print_json_array(json_t *element, int indent) {
size_t size = json_array_size(element);
print_json_indent(indent);

printf("JSON Array of %ld element%s:\n", size, json_plural(size));
printf("JSON Array of %lld element%s:\n", (long long)size, json_plural(size));
for (i = 0; i < size; i++) {
print_json_aux(json_array_get(element, i), indent + 2);
}
Expand Down
2 changes: 1 addition & 1 deletion src/lookup3.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ on 1 byte), but shoehorning those bytes into integers efficiently is messy.
# define HASH_BIG_ENDIAN 0
#endif

#define hashsize(n) ((uint32_t)1<<(n))
#define hashsize(n) ((size_t)1<<(n))
#define hashmask(n) (hashsize(n)-1)
#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))

Expand Down
2 changes: 1 addition & 1 deletion test/bin/json_process.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static const char *strip(char *str) {
}

static char *loadfile(FILE *file) {
long fsize, ret;
size_t fsize, ret;
char *buf;

fseek(file, 0, SEEK_END);
Expand Down

0 comments on commit cc318fc

Please sign in to comment.