@cryptotaxi247 / netdata-1 / commits / bf1cb6048

Use print macros (#13876)

* use print macros * cast instead

Emmanuel Vasilakis committed Oct 25, 2022 at 17:24 UTC bf1cb6048ba63438d0173f86d62ee4106bdcece6
11 files changed +73 -73
collectors/apps.plugin/apps_plugin.c
+1 -1
@@ -4709,7 +4709,7 @@ static void apps_plugin_function_processes(const char *transaction, char *functi
4709 buffer_free(wb);
4710
4711 fprintf(stdout, "\n ]");
4712 - fprintf(stdout, ",\n \"expires\":%ld", expires);
4712 + fprintf(stdout, ",\n \"expires\":%lld", (long long)expires);
4713 fprintf(stdout, "\n}");
4714
4715 pluginsd_function_result_end_to_stdout();
daemon/unit_test.c
+4 -4
@@ -1910,7 +1910,7 @@ static int test_dbengine_check_rrdr(RRDSET *st[CHARTS], RRDDIM *rd[CHARTS][DIMS]
1910 int current_region, time_t time_start, time_t time_end)
1911 {
1912 int update_every = REGION_UPDATE_EVERY[current_region];
1913 - fprintf(stderr, "%s() running on region %d, start time %ld, end time %ld, update every %d...\n", __FUNCTION__, current_region, time_start, time_end, update_every);
1913 + fprintf(stderr, "%s() running on region %d, start time %lld, end time %lld, update every %d...\n", __FUNCTION__, current_region, (long long)time_start, (long long)time_end, update_every);
1914 uint8_t same;
1915 time_t time_now, time_retrieved;
1916 int i, j, errors, value_errors = 0, time_errors = 0;
@@ -2495,7 +2495,7 @@ void dbengine_stress_test(unsigned TEST_DURATION_SEC, unsigned DSET_CHARTS, unsi
2495 test_duration = now_realtime_sec() - (time_start - HISTORY_SECONDS);
2496 if (!test_duration)
2497 test_duration = 1;
2498 - fprintf(stderr, "\nDB-engine stress test finished in %ld seconds.\n", test_duration);
2498 + fprintf(stderr, "\nDB-engine stress test finished in %lld seconds.\n", (long long)test_duration);
2499 unsigned long stored_metrics_nr = 0;
2500 for (i = 0 ; i < DSET_CHARTS ; ++i) {
2501 stored_metrics_nr += chart_threads[i]->stored_metrics_nr;
@@ -2510,8 +2510,8 @@ void dbengine_stress_test(unsigned TEST_DURATION_SEC, unsigned DSET_CHARTS, unsi
2510 fprintf(stderr, "%lu metric data points were queried by %u reader threads.\n", queried_metrics_nr, QUERY_THREADS);
2511 fprintf(stderr, "Query starting time is randomly chosen from the beginning of the time-series up to the time of\n"
2512 "the latest data point, and ending time from 1 second up to 1 hour after the starting time.\n");
2513 - fprintf(stderr, "Performance is %lu written data points/sec and %lu read data points/sec.\n",
2514 - stored_metrics_nr / test_duration, queried_metrics_nr / test_duration);
2513 + fprintf(stderr, "Performance is %lld written data points/sec and %lld read data points/sec.\n",
2514 + (long long)(stored_metrics_nr / test_duration), (long long)(queried_metrics_nr / test_duration));
2515
2516 for (i = 0 ; i < DSET_CHARTS ; ++i) {
2517 freez(chart_threads[i]);
database/rrdcontext.c
+22 -22
@@ -1708,12 +1708,12 @@ static inline int rrdmetric_to_json_callback(const DICTIONARY_ITEM *item, void *
1708
1709 buffer_sprintf(wb,
1710 "\n\t\t\t\t\t\t\t\"name\":\"%s\""
1711 - ",\n\t\t\t\t\t\t\t\"first_time_t\":%ld"
1712 - ",\n\t\t\t\t\t\t\t\"last_time_t\":%ld"
1711 + ",\n\t\t\t\t\t\t\t\"first_time_t\":%lld"
1712 + ",\n\t\t\t\t\t\t\t\"last_time_t\":%lld"
1713 ",\n\t\t\t\t\t\t\t\"collected\":%s"
1714 , string2str(rm->name)
1715 - , rm->first_time_t
1716 - , rrd_flag_is_collected(rm) ? t->now : rm->last_time_t
1715 + , (long long)rm->first_time_t
1716 + , rrd_flag_is_collected(rm) ? (long long)t->now : (long long)rm->last_time_t
1717 , rrd_flag_is_collected(rm) ? "true" : "false"
1718 );
1719
@@ -1823,8 +1823,8 @@ static inline int rrdinstance_to_json_callback(const DICTIONARY_ITEM *item, void
1823 ",\n\t\t\t\t\t\"chart_type\":\"%s\""
1824 ",\n\t\t\t\t\t\"priority\":%u"
1825 ",\n\t\t\t\t\t\"update_every\":%d"
1826 - ",\n\t\t\t\t\t\"first_time_t\":%ld"
1827 - ",\n\t\t\t\t\t\"last_time_t\":%ld"
1826 + ",\n\t\t\t\t\t\"first_time_t\":%lld"
1827 + ",\n\t\t\t\t\t\"last_time_t\":%lld"
1828 ",\n\t\t\t\t\t\"collected\":%s"
1829 , string2str(ri->name)
1830 , string2str(ri->rc->id)
@@ -1834,8 +1834,8 @@ static inline int rrdinstance_to_json_callback(const DICTIONARY_ITEM *item, void
1834 , rrdset_type_name(ri->chart_type)
1835 , ri->priority
1836 , ri->update_every
1837 - , first_time_t
1838 - , (flags & RRD_FLAG_COLLECTED) ? t_parent->now : last_time_t
1837 + , (long long)first_time_t
1838 + , (flags & RRD_FLAG_COLLECTED) ? (long long)t_parent->now : (long long)last_time_t
1839 , (flags & RRD_FLAG_COLLECTED) ? "true" : "false"
1840 );
1841
@@ -1949,16 +1949,16 @@ static inline int rrdcontext_to_json_callback(const DICTIONARY_ITEM *item, void
1949 ",\n\t\t\t\"family\":\"%s\""
1950 ",\n\t\t\t\"chart_type\":\"%s\""
1951 ",\n\t\t\t\"priority\":%u"
1952 - ",\n\t\t\t\"first_time_t\":%ld"
1953 - ",\n\t\t\t\"last_time_t\":%ld"
1952 + ",\n\t\t\t\"first_time_t\":%lld"
1953 + ",\n\t\t\t\"last_time_t\":%lld"
1954 ",\n\t\t\t\"collected\":%s"
1955 , string2str(rc->title)
1956 , string2str(rc->units)
1957 , string2str(rc->family)
1958 , rrdset_type_name(rc->chart_type)
1959 , rc->priority
1960 - , first_time_t
1961 - , (flags & RRD_FLAG_COLLECTED) ? t_parent->now : last_time_t
1960 + , (long long)first_time_t
1961 + , (flags & RRD_FLAG_COLLECTED) ? (long long)t_parent->now : (long long)last_time_t
1962 , (flags & RRD_FLAG_COLLECTED) ? "true" : "false"
1963 );
1964
@@ -2621,19 +2621,19 @@ void query_target_generate_name(QUERY_TARGET *qt) {
2621
2622 char resampling_buffer[20 + 1] = "";
2623 if(qt->request.resampling_time > 1)
2624 - snprintfz(resampling_buffer, 20, "/resampling:%ld", qt->request.resampling_time);
2624 + snprintfz(resampling_buffer, 20, "/resampling:%lld", (long long)qt->request.resampling_time);
2625
2626 char tier_buffer[20 + 1] = "";
2627 if(qt->request.options & RRDR_OPTION_SELECTED_TIER)
2628 snprintfz(tier_buffer, 20, "/tier:%zu", qt->request.tier);
2629
2630 if(qt->request.st)
2631 - snprintfz(qt->id, MAX_QUERY_TARGET_ID_LENGTH, "chart://host:%s/instance:%s/dimensions:%s/after:%ld/before:%ld/points:%zu/group:%s%s/options:%s%s%s"
2631 + snprintfz(qt->id, MAX_QUERY_TARGET_ID_LENGTH, "chart://host:%s/instance:%s/dimensions:%s/after:%lld/before:%lld/points:%zu/group:%s%s/options:%s%s%s"
2632 , rrdhost_hostname(qt->request.st->rrdhost)
2633 , rrdset_name(qt->request.st)
2634 , (qt->request.dimensions) ? qt->request.dimensions : "*"
2635 - , qt->request.after
2636 - , qt->request.before
2635 + , (long long)qt->request.after
2636 + , (long long)qt->request.before
2637 , qt->request.points
2638 , web_client_api_request_v1_data_group_to_string(qt->request.group_method)
2639 , qt->request.group_options?qt->request.group_options:""
@@ -2642,13 +2642,13 @@ void query_target_generate_name(QUERY_TARGET *qt) {
2642 , tier_buffer
2643 );
2644 else if(qt->request.host && qt->request.rca && qt->request.ria && qt->request.rma)
2645 - snprintfz(qt->id, MAX_QUERY_TARGET_ID_LENGTH, "metric://host:%s/context:%s/instance:%s/dimension:%s/after:%ld/before:%ld/points:%zu/group:%s%s/options:%s%s%s"
2645 + snprintfz(qt->id, MAX_QUERY_TARGET_ID_LENGTH, "metric://host:%s/context:%s/instance:%s/dimension:%s/after:%lld/before:%lld/points:%zu/group:%s%s/options:%s%s%s"
2646 , rrdhost_hostname(qt->request.host)
2647 , rrdcontext_acquired_id(qt->request.rca)
2648 , rrdinstance_acquired_id(qt->request.ria)
2649 , rrdmetric_acquired_id(qt->request.rma)
2650 - , qt->request.after
2651 - , qt->request.before
2650 + , (long long)qt->request.after
2651 + , (long long)qt->request.before
2652 , qt->request.points
2653 , web_client_api_request_v1_data_group_to_string(qt->request.group_method)
2654 , qt->request.group_options?qt->request.group_options:""
@@ -2657,13 +2657,13 @@ void query_target_generate_name(QUERY_TARGET *qt) {
2657 , tier_buffer
2658 );
2659 else
2660 - snprintfz(qt->id, MAX_QUERY_TARGET_ID_LENGTH, "context://host:%s/contexts:%s/instances:%s/dimensions:%s/after:%ld/before:%ld/points:%zu/group:%s%s/options:%s%s%s"
2660 + snprintfz(qt->id, MAX_QUERY_TARGET_ID_LENGTH, "context://host:%s/contexts:%s/instances:%s/dimensions:%s/after:%lld/before:%lld/points:%zu/group:%s%s/options:%s%s%s"
2661 , (qt->request.host) ? rrdhost_hostname(qt->request.host) : ((qt->request.hosts) ? qt->request.hosts : "*")
2662 , (qt->request.contexts) ? qt->request.contexts : "*"
2663 , (qt->request.charts) ? qt->request.charts : "*"
2664 , (qt->request.dimensions) ? qt->request.dimensions : "*"
2665 - , qt->request.after
2666 - , qt->request.before
2665 + , (long long)qt->request.after
2666 + , (long long)qt->request.before
2667 , qt->request.points
2668 , web_client_api_request_v1_data_group_to_string(qt->request.group_method)
2669 , qt->request.group_options?qt->request.group_options:""
database/sqlite/sqlite_metadata.c
+4 -4
@@ -729,8 +729,8 @@ static void check_dimension_metadata(struct metadata_wc *wc)
729 wc->check_metadata_after = now + METADATA_MAINTENANCE_RETRY;
730 } else
731 wc->row_id = 0;
732 - info("METADATA: Checked %u, deleted %u -- will resume after row %"PRIu64" in %ld seconds", total_checked, total_deleted, wc->row_id,
733 - wc->check_metadata_after - now);
732 + info("METADATA: Checked %u, deleted %u -- will resume after row %"PRIu64" in %lld seconds", total_checked, total_deleted, wc->row_id,
733 + (long long)(wc->check_metadata_after - now));
734
735 skip_run:
736 rc = sqlite3_finalize(res);
@@ -1536,9 +1536,9 @@ static void *metadata_unittest_threads(void)
1536 int threads_to_create = 4;
1537 fprintf(
1538 stderr,
1539 - "\nChecking metadata queue using %d threads for %ld seconds...\n",
1539 + "\nChecking metadata queue using %d threads for %lld seconds...\n",
1540 threads_to_create,
1541 - seconds_to_run);
1541 + (long long)seconds_to_run);
1542
1543 netdata_thread_t threads[threads_to_create];
1544 tu.join = 0;
libnetdata/clocks/clocks.c
+6 -6
@@ -197,28 +197,28 @@ void sleep_to_absolute_time(usec_t usec) {
197 if (!einval_printed) {
198 einval_printed++;
199 error(
200 - "Invalid time given to clock_nanosleep(): clockid = %d, tv_sec = %ld, tv_nsec = %ld",
200 + "Invalid time given to clock_nanosleep(): clockid = %d, tv_sec = %lld, tv_nsec = %ld",
201 clock,
202 - req.tv_sec,
202 + (long long)req.tv_sec,
203 req.tv_nsec);
204 }
205 } else if (ret == ENOTSUP) {
206 if (!enotsup_printed) {
207 enotsup_printed++;
208 error(
209 - "Invalid clock id given to clock_nanosleep(): clockid = %d, tv_sec = %ld, tv_nsec = %ld",
209 + "Invalid clock id given to clock_nanosleep(): clockid = %d, tv_sec = %lld, tv_nsec = %ld",
210 clock,
211 - req.tv_sec,
211 + (long long)req.tv_sec,
212 req.tv_nsec);
213 }
214 } else {
215 if (!eunknown_printed) {
216 eunknown_printed++;
217 error(
218 - "Unknown return value %d from clock_nanosleep(): clockid = %d, tv_sec = %ld, tv_nsec = %ld",
218 + "Unknown return value %d from clock_nanosleep(): clockid = %d, tv_sec = %lld, tv_nsec = %ld",
219 ret,
220 clock,
221 - req.tv_sec,
221 + (long long)req.tv_sec,
222 req.tv_nsec);
223 }
224 }
libnetdata/dictionary/dictionary.c
+4 -4
@@ -2913,9 +2913,9 @@ static int dictionary_unittest_threads() {
2913 int threads_to_create = 2;
2914 fprintf(
2915 stderr,
2916 - "\nChecking dictionary concurrency with %d threads for %ld seconds...\n",
2916 + "\nChecking dictionary concurrency with %d threads for %lld seconds...\n",
2917 threads_to_create,
2918 - seconds_to_run);
2918 + (long long)seconds_to_run);
2919
2920 netdata_thread_t threads[threads_to_create];
2921 tu.join = 0;
@@ -3068,8 +3068,8 @@ static int dictionary_unittest_view_threads() {
3068 time_t seconds_to_run = 5;
3069 fprintf(
3070 stderr,
3071 - "\nChecking dictionary concurrency with 1 master and 1 view threads for %ld seconds...\n",
3072 - seconds_to_run);
3071 + "\nChecking dictionary concurrency with 1 master and 1 view threads for %lld seconds...\n",
3072 + (long long)seconds_to_run);
3073
3074 netdata_thread_t master_thread, view_thread;
3075 tv.join = 0;
libnetdata/string/string.c
+2 -2
@@ -545,9 +545,9 @@ int string_unittest(size_t entries) {
545 int threads_to_create = 2;
546 fprintf(
547 stderr,
548 - "Checking string concurrency with %d threads for %ld seconds...\n",
548 + "Checking string concurrency with %d threads for %lld seconds...\n",
549 threads_to_create,
550 - seconds_to_run);
550 + (long long)seconds_to_run);
551 // check string concurrency
552 netdata_thread_t threads[threads_to_create];
553 tu.join = 0;
web/api/formatters/json_wrapper.c
+12 -12
@@ -58,23 +58,23 @@ void rrdr_json_wrapper_begin(RRDR *r, BUFFER *wb, uint32_t format, RRDR_OPTIONS
58 " %sapi%s: 1,\n"
59 " %sid%s: %s%s%s,\n"
60 " %sname%s: %s%s%s,\n"
61 - " %sview_update_every%s: %ld,\n"
62 - " %supdate_every%s: %ld,\n"
63 - " %sfirst_entry%s: %ld,\n"
64 - " %slast_entry%s: %ld,\n"
65 - " %sbefore%s: %ld,\n"
66 - " %safter%s: %ld,\n"
61 + " %sview_update_every%s: %lld,\n"
62 + " %supdate_every%s: %lld,\n"
63 + " %sfirst_entry%s: %lld,\n"
64 + " %slast_entry%s: %lld,\n"
65 + " %sbefore%s: %lld,\n"
66 + " %safter%s: %lld,\n"
67 " %sgroup%s: %s%s%s,\n"
68 " %soptions%s: %s"
69 , kq, kq
70 , kq, kq, sq, qt->id, sq
71 , kq, kq, sq, qt->id, sq
72 - , kq, kq, r->update_every
73 - , kq, kq, qt->db.minimum_latest_update_every
74 - , kq, kq, qt->db.first_time_t
75 - , kq, kq, qt->db.last_time_t
76 - , kq, kq, r->before
77 - , kq, kq, r->after
72 + , kq, kq, (long long)r->update_every
73 + , kq, kq, (long long)qt->db.minimum_latest_update_every
74 + , kq, kq, (long long)qt->db.first_time_t
75 + , kq, kq, (long long)qt->db.last_time_t
76 + , kq, kq, (long long)r->before
77 + , kq, kq, (long long)r->after
78 , kq, kq, sq, web_client_api_request_v1_data_group_to_string(group_method), sq
79 , kq, kq, sq);
80
web/api/queries/query.c
+2 -2
@@ -2069,8 +2069,8 @@ RRDR *rrd2rrdr(ONEWAYALLOC *owa, QUERY_TARGET *qt) {
2069
2070 dimensions_used++;
2071 if (timeout && ((NETDATA_DOUBLE)dt_usec(&query_start_time, &query_current_time) / 1000.0) > (NETDATA_DOUBLE)timeout) {
2072 - log_access("QUERY CANCELED RUNTIME EXCEEDED %0.2f ms (LIMIT %ld ms)",
2073 - (NETDATA_DOUBLE)dt_usec(&query_start_time, &query_current_time) / 1000.0, timeout);
2072 + log_access("QUERY CANCELED RUNTIME EXCEEDED %0.2f ms (LIMIT %lld ms)",
2073 + (NETDATA_DOUBLE)dt_usec(&query_start_time, &query_current_time) / 1000.0, (long long)timeout);
2074 r->result_options |= RRDR_RESULT_OPTION_CANCEL;
2075 break;
2076 }
web/api/queries/weights.c
+12 -12
@@ -119,25 +119,25 @@ static void results_header_to_json(DICTIONARY *results __maybe_unused, BUFFER *w
119 WEIGHTS_STATS *stats) {
120
121 buffer_sprintf(wb, "{\n"
122 - "\t\"after\": %ld,\n"
123 - "\t\"before\": %ld,\n"
124 - "\t\"duration\": %ld,\n"
122 + "\t\"after\": %lld,\n"
123 + "\t\"before\": %lld,\n"
124 + "\t\"duration\": %lld,\n"
125 "\t\"points\": %zu,\n",
126 - after,
127 - before,
128 - before - after,
126 + (long long)after,
127 + (long long)before,
128 + (long long)(before - after),
129 points
130 );
131
132 if(method == WEIGHTS_METHOD_MC_KS2 || method == WEIGHTS_METHOD_MC_VOLUME)
133 buffer_sprintf(wb, ""
134 - "\t\"baseline_after\": %ld,\n"
135 - "\t\"baseline_before\": %ld,\n"
136 - "\t\"baseline_duration\": %ld,\n"
134 + "\t\"baseline_after\": %lld,\n"
135 + "\t\"baseline_before\": %lld,\n"
136 + "\t\"baseline_duration\": %lld,\n"
137 "\t\"baseline_points\": %zu,\n",
138 - baseline_after,
139 - baseline_before,
140 - baseline_before - baseline_after,
138 + (long long)baseline_after,
139 + (long long)baseline_before,
140 + (long long)(baseline_before - baseline_after),
141 points << shifts
142 );
143
web/api/web_api_v1.c
+4 -4
@@ -1538,11 +1538,11 @@ static void web_client_api_v1_dbengine_stats_for_tier(BUFFER *wb, size_t tier) {
1538 ",\n\t\t\"metrics_pages\":%zu"
1539 ",\n\t\t\"extents_compressed_bytes\":%zu"
1540 ",\n\t\t\"pages_uncompressed_bytes\":%zu"
1541 - ",\n\t\t\"pages_duration_secs\":%ld"
1541 + ",\n\t\t\"pages_duration_secs\":%lld"
1542 ",\n\t\t\"single_point_pages\":%zu"
1543 ",\n\t\t\"first_t\":%llu"
1544 ",\n\t\t\"last_t\":%llu"
1545 - ",\n\t\t\"database_retention_secs\":%ld"
1545 + ",\n\t\t\"database_retention_secs\":%lld"
1546 ",\n\t\t\"average_compression_savings\":%0.2f"
1547 ",\n\t\t\"average_point_duration_secs\":%0.2f"
1548 ",\n\t\t\"average_metric_retention_secs\":%0.2f"
@@ -1573,11 +1573,11 @@ static void web_client_api_v1_dbengine_stats_for_tier(BUFFER *wb, size_t tier) {
1573 , stats.metrics_pages
1574 , stats.extents_compressed_bytes
1575 , stats.pages_uncompressed_bytes
1576 - , stats.pages_duration_secs
1576 + , (long long)stats.pages_duration_secs
1577 , stats.single_point_pages
1578 , stats.first_t
1579 , stats.last_t
1580 - , stats.database_retention_secs
1580 + , (long long)stats.database_retention_secs
1581 , stats.average_compression_savings
1582 , stats.average_point_duration_secs
1583 , stats.average_metric_retention_secs