Skip to content

Commit 77ca1a4

Browse files
authored
Merge pull request collectd#2512 from Stackdriver/pri
Replace zu with PRIsz and llu with PRIu64.
2 parents ac6580f + 4c4988b commit 77ca1a4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+194
-170
lines changed

src/amqp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ static int camqp_connect(camqp_config_t *conf) /* {{{ */
503503

504504
static int camqp_shutdown(void) /* {{{ */
505505
{
506-
DEBUG("amqp plugin: Shutting down %zu subscriber threads.",
506+
DEBUG("amqp plugin: Shutting down %" PRIsz " subscriber threads.",
507507
subscriber_threads_num);
508508

509509
subscriber_threads_running = 0;

src/barometer.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -412,16 +412,16 @@ static int get_reference_temperature(double *result) {
412412
continue;
413413
}
414414

415-
DEBUG(
416-
"barometer: get_reference_temperature - initialize \"%s\", %zu vals",
417-
list->sensor_name, values_num);
415+
DEBUG("barometer: get_reference_temperature - initialize \"%s\", %" PRIsz
416+
" vals",
417+
list->sensor_name, values_num);
418418

419419
list->initialized = 1;
420420
list->num_values = values_num;
421421

422422
for (size_t i = 0; i < values_num; ++i) {
423-
DEBUG("barometer: get_reference_temperature - rate %zu: %lf **", i,
424-
values[i]);
423+
DEBUG("barometer: get_reference_temperature - rate %" PRIsz ": %lf **",
424+
i, values[i]);
425425
if (!isnan(values[i])) {
426426
avg_sum += values[i];
427427
++avg_num;
@@ -444,7 +444,7 @@ static int get_reference_temperature(double *result) {
444444
}
445445

446446
for (size_t i = 0; i < REF_TEMP_AVG_NUM * list->num_values; ++i) {
447-
DEBUG("barometer: get_reference_temperature - history %zu: %lf", i,
447+
DEBUG("barometer: get_reference_temperature - history %" PRIsz ": %lf", i,
448448
values_history[i]);
449449
if (!isnan(values_history[i])) {
450450
avg_sum += values_history[i];
@@ -464,8 +464,9 @@ static int get_reference_temperature(double *result) {
464464
}
465465

466466
for (size_t i = 0; i < values_num; ++i) {
467-
DEBUG("barometer: get_reference_temperature - rate last %zu: %lf **", i,
468-
values[i]);
467+
DEBUG("barometer: get_reference_temperature - rate last %" PRIsz
468+
": %lf **",
469+
i, values[i]);
469470
if (!isnan(values[i])) {
470471
avg_sum += values[i];
471472
++avg_num;

src/ceph.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1341,7 +1341,7 @@ static int cconn_main_loop(uint32_t request_type) {
13411341
struct cconn *io = io_array + i;
13421342
ret = cconn_prepare(io, fds + nfds);
13431343
if (ret < 0) {
1344-
WARNING("ceph plugin: cconn_prepare(name=%s,i=%zu,st=%d)=%d",
1344+
WARNING("ceph plugin: cconn_prepare(name=%s,i=%" PRIsz ",st=%d)=%d",
13451345
io->d->name, i, io->state, ret);
13461346
cconn_close(io);
13471347
io->request_type = ASOK_REQ_NONE;

src/csv.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ static int value_list_to_string(char *buffer, int buffer_len,
7474
}
7575
status = snprintf(buffer + offset, buffer_len - offset, ",%lf", rates[i]);
7676
} else if (ds->ds[i].type == DS_TYPE_COUNTER) {
77-
status = snprintf(buffer + offset, buffer_len - offset, ",%llu",
78-
vl->values[i].counter);
77+
status = snprintf(buffer + offset, buffer_len - offset, ",%" PRIu64,
78+
(uint64_t)vl->values[i].counter);
7979
} else if (ds->ds[i].type == DS_TYPE_DERIVE) {
8080
status = snprintf(buffer + offset, buffer_len - offset, ",%" PRIi64,
8181
vl->values[i].derive);

src/curl_xml.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,8 @@ static int cx_check_type(const data_set_t *ds, cx_xpath_t *xpath) /* {{{ */
240240
}
241241

242242
if (ds->ds_num != xpath->values_len) {
243-
WARNING("curl_xml plugin: DataSet `%s' requires %zu values, but config "
244-
"talks about %zu",
243+
WARNING("curl_xml plugin: DataSet `%s' requires %" PRIsz
244+
" values, but config talks about %" PRIsz,
245245
xpath->type, ds->ds_num, xpath->values_len);
246246
return -1;
247247
}

src/daemon/common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,7 @@ int format_values(char *ret, size_t ret_len, /* {{{ */
889889
}
890890
BUFFER_ADD(":" GAUGE_FORMAT, rates[i]);
891891
} else if (ds->ds[i].type == DS_TYPE_COUNTER)
892-
BUFFER_ADD(":%llu", vl->values[i].counter);
892+
BUFFER_ADD(":%" PRIu64, (uint64_t)vl->values[i].counter);
893893
else if (ds->ds[i].type == DS_TYPE_DERIVE)
894894
BUFFER_ADD(":%" PRIi64, vl->values[i].derive);
895895
else if (ds->ds[i].type == DS_TYPE_ABSOLUTE)

src/daemon/globals.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030
#define DATA_MAX_NAME_LEN 128
3131
#endif
3232

33+
#ifndef PRIsz
34+
#define PRIsz "zu"
35+
#endif /* PRIsz */
36+
3337
/* Type for time as used by "utils_time.h" */
3438
typedef uint64_t cdtime_t;
3539

src/daemon/plugin.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ static void start_read_threads(size_t num) /* {{{ */
637637
}
638638

639639
char name[THREAD_NAME_MAX];
640-
snprintf(name, sizeof(name), "reader#%zu", read_threads_num);
640+
snprintf(name, sizeof(name), "reader#%" PRIsz, read_threads_num);
641641
set_thread_name(read_threads[read_threads_num], name);
642642

643643
read_threads_num++;
@@ -648,7 +648,7 @@ static void stop_read_threads(void) {
648648
if (read_threads == NULL)
649649
return;
650650

651-
INFO("collectd: Stopping %zu read threads.", read_threads_num);
651+
INFO("collectd: Stopping %" PRIsz " read threads.", read_threads_num);
652652

653653
pthread_mutex_lock(&read_lock);
654654
read_loop = 0;
@@ -843,7 +843,7 @@ static void start_write_threads(size_t num) /* {{{ */
843843
}
844844

845845
char name[THREAD_NAME_MAX];
846-
snprintf(name, sizeof(name), "writer#%zu", write_threads_num);
846+
snprintf(name, sizeof(name), "writer#%" PRIsz, write_threads_num);
847847
set_thread_name(write_threads[write_threads_num], name);
848848

849849
write_threads_num++;
@@ -858,7 +858,7 @@ static void stop_write_threads(void) /* {{{ */
858858
if (write_threads == NULL)
859859
return;
860860

861-
INFO("collectd: Stopping %zu write threads.", write_threads_num);
861+
INFO("collectd: Stopping %" PRIsz " write threads.", write_threads_num);
862862

863863
pthread_mutex_lock(&write_lock);
864864
write_loop = 0;
@@ -890,7 +890,7 @@ static void stop_write_threads(void) /* {{{ */
890890
pthread_mutex_unlock(&write_lock);
891891

892892
if (i > 0) {
893-
WARNING("plugin: %zu value list%s left after shutting down "
893+
WARNING("plugin: %" PRIsz " value list%s left after shutting down "
894894
"the write threads.",
895895
i, (i == 1) ? " was" : "s were");
896896
}
@@ -1956,8 +1956,8 @@ static int plugin_dispatch_values_internal(value_list_t *vl) {
19561956
#else
19571957
if (ds->ds_num != vl->values_len) {
19581958
ERROR("plugin_dispatch_values: ds->type = %s: "
1959-
"(ds->ds_num = %zu) != "
1960-
"(vl->values_len = %zu)",
1959+
"(ds->ds_num = %" PRIsz ") != "
1960+
"(vl->values_len = %" PRIsz ")",
19611961
ds->type, ds->ds_num, vl->values_len);
19621962
return -1;
19631963
}

src/daemon/types_list.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ static int parse_ds(data_source_t *dsrc, char *buf, size_t buf_len) {
3939
int fields_num;
4040

4141
if (buf_len < 11) {
42-
ERROR("parse_ds: (buf_len = %zu) < 11", buf_len);
42+
ERROR("parse_ds: (buf_len = %" PRIsz ") < 11", buf_len);
4343
return -1;
4444
}
4545

@@ -121,8 +121,8 @@ static void parse_line(char *buf) {
121121

122122
for (size_t i = 0; i < ds->ds_num; i++)
123123
if (parse_ds(ds->ds + i, fields[i + 1], strlen(fields[i + 1])) != 0) {
124-
ERROR("types_list: parse_line: Cannot parse data source #%zu "
125-
"of data set %s",
124+
ERROR("types_list: parse_line: Cannot parse data source #%" PRIsz
125+
" of data set %s",
126126
i, ds->type);
127127
sfree(ds->ds);
128128
sfree(ds);

src/daemon/utils_cache.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ static int uc_insert(const data_set_t *ds, const value_list_t *vl,
154154
ce = cache_alloc(ds->ds_num);
155155
if (ce == NULL) {
156156
sfree(key_copy);
157-
ERROR("uc_insert: cache_alloc (%zu) failed.", ds->ds_num);
157+
ERROR("uc_insert: cache_alloc (%" PRIsz ") failed.", ds->ds_num);
158158
return -1;
159159
}
160160

@@ -381,7 +381,7 @@ int uc_update(const data_set_t *ds, const value_list_t *vl) {
381381
return -1;
382382
} /* switch (ds->ds[i].type) */
383383

384-
DEBUG("uc_update: %s: ds[%zu] = %lf", name, i, ce->values_gauge[i]);
384+
DEBUG("uc_update: %s: ds[%" PRIsz "] = %lf", name, i, ce->values_gauge[i]);
385385
} /* for (i) */
386386

387387
/* Update the history if it exists. */
@@ -469,8 +469,8 @@ gauge_t *uc_get_rate(const data_set_t *ds, const value_list_t *vl) {
469469
/* This is important - the caller has no other way of knowing how many
470470
* values are returned. */
471471
if (ret_num != ds->ds_num) {
472-
ERROR("utils_cache: uc_get_rate: ds[%s] has %zu values, "
473-
"but uc_get_rate_by_name returned %zu.",
472+
ERROR("utils_cache: uc_get_rate: ds[%s] has %" PRIsz " values, "
473+
"but uc_get_rate_by_name returned %" PRIsz ".",
474474
ds->type, ds->ds_num, ret_num);
475475
sfree(ret);
476476
return NULL;
@@ -488,7 +488,7 @@ int uc_get_value_by_name(const char *name, value_t **ret_values,
488488

489489
pthread_mutex_lock(&cache_lock);
490490

491-
if (c_avl_get(cache_tree, name, (void *) &ce) == 0) {
491+
if (c_avl_get(cache_tree, name, (void *)&ce) == 0) {
492492
assert(ce != NULL);
493493

494494
/* remove missing values from getval */
@@ -504,8 +504,7 @@ int uc_get_value_by_name(const char *name, value_t **ret_values,
504504
memcpy(ret, ce->values_raw, ret_num * sizeof(value_t));
505505
}
506506
}
507-
}
508-
else {
507+
} else {
509508
DEBUG("utils_cache: uc_get_value_by_name: No such value: %s", name);
510509
status = -1;
511510
}
@@ -537,10 +536,10 @@ value_t *uc_get_value(const data_set_t *ds, const value_list_t *vl) {
537536

538537
/* This is important - the caller has no other way of knowing how many
539538
* values are returned. */
540-
if (ret_num != (size_t) ds->ds_num) {
541-
ERROR("utils_cache: uc_get_value: ds[%s] has %zu values, "
542-
"but uc_get_value_by_name returned %zu.", ds->type, ds->ds_num,
543-
ret_num);
539+
if (ret_num != (size_t)ds->ds_num) {
540+
ERROR("utils_cache: uc_get_value: ds[%s] has %" PRIsz " values, "
541+
"but uc_get_value_by_name returned %" PRIsz ".",
542+
ds->type, ds->ds_num, ret_num);
544543
sfree(ret);
545544
return (NULL);
546545
}

0 commit comments

Comments
 (0)