summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
7ea33f7)
This will be convenient in an upcoming commit.
I had to add -Wno-format-zero-length to suppress a GCC warning about a
zero-length format string in this monitor_daemon() call:
set_subprogram_name("");
I don't know what that warning is good for anyway, and I guess the Clang
developers don't either because Clang didn't warn.
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
OVS_ENABLE_OPTION([-Wpointer-arith])
OVS_ENABLE_OPTION([-Wdeclaration-after-statement])
OVS_ENABLE_OPTION([-Wformat-security])
OVS_ENABLE_OPTION([-Wpointer-arith])
OVS_ENABLE_OPTION([-Wdeclaration-after-statement])
OVS_ENABLE_OPTION([-Wformat-security])
+OVS_ENABLE_OPTION([-Wno-format-zero-length])
OVS_ENABLE_OPTION([-Wswitch-enum])
OVS_ENABLE_OPTION([-Wunused-parameter])
OVS_ENABLE_OPTION([-Wstrict-aliasing])
OVS_ENABLE_OPTION([-Wswitch-enum])
OVS_ENABLE_OPTION([-Wunused-parameter])
OVS_ENABLE_OPTION([-Wstrict-aliasing])
return name ? name : "";
}
return name ? name : "";
}
-/* Sets 'name' as the name of the currently running thread or process. (This
- * appears in log messages and may also be visible in system process listings
- * and debuggers.) */
+/* Sets the formatted value of 'format' as the name of the currently running
+ * thread or process. (This appears in log messages and may also be visible in
+ * system process listings and debuggers.) */
-set_subprogram_name(const char *name)
+set_subprogram_name(const char *format, ...)
- const char *pname = name[0] ? name : program_name;
- free(subprogram_name_set(xstrdup(name)));
+ char *pname;
+
+ if (format) {
+ va_list args;
+
+ va_start(args, format);
+ pname = xvasprintf(format, args);
+ va_end(args);
+ } else {
+ pname = xstrdup(program_name);
+ }
+
+ free(subprogram_name_set(pname));
+
#if HAVE_GLIBC_PTHREAD_SETNAME_NP
pthread_setname_np(pthread_self(), pname);
#elif HAVE_NETBSD_PTHREAD_SETNAME_NP
#if HAVE_GLIBC_PTHREAD_SETNAME_NP
pthread_setname_np(pthread_self(), pname);
#elif HAVE_NETBSD_PTHREAD_SETNAME_NP
set_program_name__(name, VERSION, __DATE__, __TIME__)
const char *get_subprogram_name(void);
set_program_name__(name, VERSION, __DATE__, __TIME__)
const char *get_subprogram_name(void);
-void set_subprogram_name(const char *name);
+void set_subprogram_name(const char *format, ...) PRINTF_FORMAT(1, 2);
const char *get_program_version(void);
void ovs_print_version(uint8_t min_ofp, uint8_t max_ofp);
const char *get_program_version(void);
void ovs_print_version(uint8_t min_ofp, uint8_t max_ofp);