core (named threads): flood of -Wformat-truncation warnings with gcc-7.1
Starting in Fedora 26 which has gcc-7.1.x, -Wformat-trunction is enabled with -Wformat, resulting in a flood of new warnings. This many warnings is a concern because it makes it hard(er) to see other warnings that should be addressed. An example is at https://kojipkgs.fedoraproject.org//packages/glusterfs/3.12.0/1.fc28/data/logs/x86_64/build.log For more info see https://review.gluster.org/#/c/18267/ I can't find much (or good) documentation on the heuristics the compiler uses for this warning. In the case of printing integer types it appears it looks at the available space in the destination and the range of values for the variable and/or its type. To address the specific question about why 0x3ff versus 0xfff to mask the value, either would suffice to hint to the compiler that the printed value will fit in three characters. But the loop is from 0...1023 (or 0...0x3ff if you prefer) so I chose that as a more "accurate" mask to use as it exactly matches the range of values of the loop. Fixes: bz#1492847 Change-Id: I6e309ba42159841131d8241bfc0566ef09e00aa9
This commit is contained in:
parent
621138ce76
commit
fd8f712f31
@ -135,9 +135,11 @@ void trap (void);
|
||||
#define GF_PERCENTAGE(val, total) (((val)*100)/(total))
|
||||
|
||||
/* pthread related */
|
||||
#define GF_THREAD_NAMEMAX 9
|
||||
#define GF_THREAD_NAME_PREFIX "gluster"
|
||||
#define GF_THREAD_NAME_PREFIX_LEN 7
|
||||
/* as per the man page, thread-name should be at max 16 bytes */
|
||||
/* with prefix of 'glfs_' (5), we are left with 11 more bytes */
|
||||
#define GF_THREAD_NAMEMAX 11
|
||||
#define GF_THREAD_NAME_PREFIX "glfs_"
|
||||
#define GF_THREAD_NAME_PREFIX_LEN 5
|
||||
|
||||
#include <stdbool.h>
|
||||
#define gf_boolean_t bool
|
||||
|
@ -714,7 +714,7 @@ event_dispatch_epoll (struct event_pool *event_pool)
|
||||
ev_data->event_index = i + 1;
|
||||
|
||||
snprintf (thread_name, sizeof(thread_name),
|
||||
"%s%d", "epoll", i);
|
||||
"epoll%03hx", (i & 0x3ff));
|
||||
ret = gf_thread_create (&t_id, NULL,
|
||||
event_dispatch_epoll_worker,
|
||||
ev_data, thread_name);
|
||||
@ -826,8 +826,7 @@ event_reconfigure_threads_epoll (struct event_pool *event_pool, int value)
|
||||
|
||||
snprintf (thread_name,
|
||||
sizeof(thread_name),
|
||||
"%s%d",
|
||||
"epoll", i);
|
||||
"epoll%03hx", (i & 0x3ff));
|
||||
ret = gf_thread_create (&t_id, NULL,
|
||||
event_dispatch_epoll_worker,
|
||||
ev_data, thread_name);
|
||||
|
@ -733,7 +733,7 @@ syncenv_scale (struct syncenv *env)
|
||||
|
||||
env->proc[i].env = env;
|
||||
snprintf (thread_name, sizeof(thread_name),
|
||||
"%s%d", "sproc", env->procs);
|
||||
"sproc%03hx", (env->procs & 0x3ff));
|
||||
ret = gf_thread_create (&env->proc[i].processor, NULL,
|
||||
syncenv_processor,
|
||||
&env->proc[i], thread_name);
|
||||
|
@ -4642,7 +4642,7 @@ gf_defrag_parallel_migration_init (xlator_t *this, gf_defrag_info_t *defrag,
|
||||
/*Spawn Threads Here*/
|
||||
while (index < thread_spawn_count) {
|
||||
snprintf (thread_name, sizeof(thread_name),
|
||||
"%s%d", "dhtmig", index + 1);
|
||||
"dhtmig%d", ((index + 1) & 0x3ff));
|
||||
ret = gf_thread_create (&(tid[index]), NULL,
|
||||
&gf_defrag_task, (void *)defrag,
|
||||
thread_name);
|
||||
@ -4885,7 +4885,6 @@ gf_defrag_start_crawl (void *data)
|
||||
} else {
|
||||
fc_thread_started = _gf_true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -618,8 +618,8 @@ gf_history_consume (void * data)
|
||||
|
||||
curr->retval = 0;
|
||||
memset (curr->changelog, '\0', PATH_MAX);
|
||||
snprintf (thread_name, sizeof(thread_name), "%s%d",
|
||||
"clogc", iter + 1);
|
||||
snprintf (thread_name, sizeof(thread_name),
|
||||
"clogc%03hx", ((iter + 1) & 0x3ff));
|
||||
|
||||
ret = gf_thread_create (&th_id[iter], NULL,
|
||||
gf_changelog_consume_wrap, curr,
|
||||
|
@ -116,7 +116,7 @@ changelog_init_rpc_threads (xlator_t *this, changelog_priv_t *priv,
|
||||
/* spawn dispatcher threads */
|
||||
for (; j < nr_dispatchers; j++) {
|
||||
snprintf (thread_name, sizeof(thread_name),
|
||||
"%s%d", "clogd", j);
|
||||
"clogd%03hx", (j & 0x3ff));
|
||||
ret = gf_thread_create (&priv->ev_dispatcher[j],
|
||||
NULL, changelog_ev_dispatch, conn,
|
||||
thread_name);
|
||||
|
@ -835,7 +835,7 @@ __iot_workers_scale (iot_conf_t *conf)
|
||||
diff --;
|
||||
|
||||
snprintf (thread_name, sizeof(thread_name),
|
||||
"%s%d", "iotwr", conf->curr_count);
|
||||
"iotwr%03hx", (conf->curr_count & 0x3ff));
|
||||
ret = gf_thread_create (&thread, &conf->w_attr, iot_worker,
|
||||
conf, thread_name);
|
||||
if (ret == 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user