Fix some wrong formatting characters for size_t

The '%lu' isn't stricly right either, but now this commit can be
referred to find locations to fix with the more correct '%zu' or
'PRIuMAX' or whatever is the right thing to use.
This commit is contained in:
Matthew Brush 2013-03-04 02:46:04 -08:00
parent 2aed767bb7
commit 5b2f19e1c4
5 changed files with 17 additions and 17 deletions

View File

@ -1,4 +1,4 @@
@set UPDATED 4 September 2005
@set UPDATED-MONTH September 2005
@set EDITION 0.03
@set VERSION 0.03
@set EDITION 0.04
@set VERSION 0.04

View File

@ -36,8 +36,8 @@ int main(int argc, char **argv) {
cfuhash_set_flag(hash, CFUHASH_FROZEN_UNTIL_GROWS);
for (i = 0; i < 32; i++) {
sprintf(list[i][0], "test_var%d", i);
sprintf(list[i][1], "value%d", i);
sprintf(list[i][0], "test_var%lu", i);
sprintf(list[i][1], "value%lu", i);
}
cfuhash_put(hash, "var1", "value1");
@ -58,7 +58,7 @@ int main(int argc, char **argv) {
printf("got var2='%s'\n", val);
printf("var4 %s\n", cfuhash_exists(hash, "var4") ? "exists" : "does NOT exist!!!");
printf("%d entries, %d buckets used out of %d\n", cfuhash_num_entries(hash), cfuhash_num_buckets_used(hash), cfuhash_num_buckets(hash));
printf("%lu entries, %lu buckets used out of %lu\n", cfuhash_num_entries(hash), cfuhash_num_buckets_used(hash), cfuhash_num_buckets(hash));
cfuhash_pretty_print(hash, stdout);
@ -69,7 +69,7 @@ int main(int argc, char **argv) {
size_t num_buckets = cfuhash_num_buckets(hash);
size_t num_entries = cfuhash_num_entries(hash);
cfuhash_put(hash, list[i][0], list[i][1]);
printf("%d entries, %d buckets used out of %d (%.2f)\n", num_entries, used, num_buckets, (float)num_entries/(float)num_buckets);
printf("%lu entries, %lu buckets used out of %lu (%.2f)\n", num_entries, used, num_buckets, (float)num_entries/(float)num_buckets);
}
@ -82,7 +82,7 @@ int main(int argc, char **argv) {
keys = (char **)cfuhash_keys_data(hash, &key_count, &key_sizes, 0);
printf("\n\nkeys (%u):\n", key_count);
printf("\n\nkeys (%lu):\n", key_count);
for (i = 0; i < key_count; i++) {
printf("\t%s\n", keys[i]);
free(keys[i]);
@ -92,7 +92,7 @@ int main(int argc, char **argv) {
}
cfuhash_clear(hash);
printf("%d entries, %d buckets used out of %d\n", cfuhash_num_entries(hash), cfuhash_num_buckets_used(hash), cfuhash_num_buckets(hash));
printf("%lu entries, %lu buckets used out of %lu\n", cfuhash_num_entries(hash), cfuhash_num_buckets_used(hash), cfuhash_num_buckets(hash));
cfuhash_destroy(hash);

View File

@ -113,8 +113,8 @@ time_it(cfuhash_function_t hf, double *elapsed_time, u_int32_t num_tests) {
cfutime_begin(time);
for (i = 0; i < num_tests; i++) {
sprintf(key, "%u", 15000000 - i);
sprintf(value, "value%d", i);
sprintf(key, "%lu", 15000000 - i);
sprintf(value, "value%lu", i);
cfuhash_put(hash, key, dup_str(value));
}
cfutime_end(time);
@ -123,7 +123,7 @@ time_it(cfuhash_function_t hf, double *elapsed_time, u_int32_t num_tests) {
used = cfuhash_num_buckets_used(hash);
num_buckets = cfuhash_num_buckets(hash);
num_entries = cfuhash_num_entries(hash);
printf("%d entries, %d/%d buckets (%.2f%%), %.2f%% threshold check\n", num_entries, used, num_buckets, 100.0 * (float)used/(float)num_buckets, 100.0 * (float)num_entries/(float)num_buckets);
printf("%lu entries, %lu/%lu buckets (%.2f%%), %.2f%% threshold check\n", num_entries, used, num_buckets, 100.0 * (float)used/(float)num_buckets, 100.0 * (float)num_entries/(float)num_buckets);
cfuhash_destroy_with_free_fn(hash, free_data);
@ -138,7 +138,7 @@ int main(int argc, char **argv) {
argc = argc;
argv = argv;
printf("mutex is %d bytes\n", sizeof(pthread_mutex_t));
printf("mutex is %lu bytes\n", sizeof(pthread_mutex_t));
printf("default:\n");
time_it(NULL, &elapsed_time, num_tests);

View File

@ -39,7 +39,7 @@ int main(int argc, char **argv) {
cfustring_append(buf, "test^*string%2^*3");
strings = cfustring_split_to_c_str(buf, &num_strings, 0, "%", "^*", NULL);
printf("got back %u strings\n", num_strings);
printf("got back %lu strings\n", num_strings);
printf("\n");
for (i = 0; i < num_strings; i++) {
@ -52,7 +52,7 @@ int main(int argc, char **argv) {
free(strings);
header_lines = cfustring_split(header_block, &num_headers, 0, "\r\n", "\n", NULL);
printf("got back %u headers\n", num_strings);
printf("got back %lu headers\n", num_strings);
for (i = 0; i < num_headers; i++) {
strings = cfustring_split_to_c_str(header_lines[i], &num_strings, 2, ":", NULL);
@ -61,7 +61,7 @@ int main(int argc, char **argv) {
size_t j = 0;
for (j = 0; j < num_strings; j++) free(strings[j]);
free(strings);
fprintf(stderr, "bad header: %u strings from split -- '%s'\n", num_strings, cfustring_get_buffer(header_lines[i]));
fprintf(stderr, "bad header: %lu strings from split -- '%s'\n", num_strings, cfustring_get_buffer(header_lines[i]));
continue;
}

View File

@ -876,12 +876,12 @@ cfuhash_bencode_strings(cfuhash_table_t *ht) {
for (i = 0; i < num_keys; i++) {
char *val = NULL;
snprintf(len_str, 32, "%d:", (keys[i] ? strlen(keys[i]) : 0));
snprintf(len_str, 32, "%lu:", (keys[i] ? strlen(keys[i]) : 0));
cfustring_append(bencoded, len_str);
cfustring_append(bencoded, keys[i]);
val = (char *)cfuhash_get(ht, keys[i]);
snprintf(len_str, 32, "%d:", (val ? strlen(val) : 0));
snprintf(len_str, 32, "%lu:", (val ? strlen(val) : 0));
cfustring_append(bencoded, len_str);
cfustring_append(bencoded, val);