diff --git a/docs/Makefile.am b/docs/Makefile.am index 0c6eaa3d2..2ca1b0ab4 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -24,14 +24,18 @@ noinst_HEADERS = mainpage.h dist_man_MANS = man8/qb-blackbox.8 if HAVE_DOXYGEN inc_dir = $(top_srcdir)/include/qb -dependant_headers = $(wildcard $(inc_dir)/qb*.h) -dist_man_MANS += man3/qbipcc.h.3 man3/qbipcs.h.3 man3/qbatomic.h.3 \ - man3/qbhdb.h.3 man3/qbipc_common.h.3 man3/qblist.h.3 \ - man3/qbloop.h.3 man3/qbutil.h.3 man3/qbarray.h.3 \ - man3/qblog.h.3 man3/qbmap.h.3 +dependent_headers = $(subst $(inc_dir),,$(shell \ + printf 'include $(inc_dir)/Makefile.am\n\n%%.var:\n\t@echo $$($$*)' \ + | ${MAKE} --no-print-directory -f - inst_HEADERS.var \ + || echo $(inc_dir)/qb*.h)) +dependent_headers_omit = qbconfig.h -$(dist_man_MANS): man.dox $(dependant_headers) +dist_man_MANS += $(patsubst %,man3/%.3,$(filter-out \ + $(dependent_headers_omit),$(dependent_headers) \ + )) + +$(dist_man_MANS): man.dox $(dependent_headers:%=$(inc_dir)/%) mkdir -p man3 doxygen man.dox diff --git a/lib/log_format.c b/lib/log_format.c index 6c29f0a95..82fa1eb03 100644 --- a/lib/log_format.c +++ b/lib/log_format.c @@ -272,10 +272,11 @@ qb_log_target_format_static(int32_t target, const char * format, break; case 'H': - if (gethostname(tmp_buf, 255) == 0) { - tmp_buf[254] = '\0'; + if (gethostname(tmp_buf, sizeof(tmp_buf)) == 0) { + tmp_buf[sizeof(tmp_buf) - 1] = '\0'; } else { - (void)strlcpy(tmp_buf, "localhost", 255); + (void)strlcpy(tmp_buf, "localhost", + sizeof(tmp_buf)); } p = tmp_buf; break; diff --git a/tests/check_log.c b/tests/check_log.c index d7ac70bc8..853862016 100644 --- a/tests/check_log.c +++ b/tests/check_log.c @@ -450,8 +450,10 @@ static const char *_test_tags_stringify(uint32_t tags) START_TEST(test_log_format) { int32_t t; - char cmp_str[256]; + /* following size/length related equation holds in the context of use: + strlen(cmp_str) = strlen(host_str) + X; X ~ 20 < sizeof(host_str) */ char host_str[256]; + char cmp_str[2 * sizeof(host_str)]; qb_log_init("test", LOG_USER, LOG_DEBUG); qb_log_ctl(QB_LOG_SYSLOG, QB_LOG_CONF_ENABLED, QB_FALSE); @@ -498,16 +500,19 @@ START_TEST(test_log_format) qb_log_tags_stringify_fn_set(NULL); - gethostname(host_str, 256); + gethostname(host_str, sizeof(host_str)); + host_str[sizeof(host_str) - 1] = '\0'; qb_log_format_set(t, "%P %H %N %b"); qb_log(LOG_INFO, "Angus"); - snprintf(cmp_str, 256, "%d %s test Angus", getpid(), host_str); + snprintf(cmp_str, sizeof(cmp_str), "%d %s test Angus", getpid(), + host_str); ck_assert_str_eq(test_buf, cmp_str); qb_log_format_set(t, "%3N %H %P %b"); qb_log(LOG_INFO, "Angus"); - snprintf(cmp_str, 256, "tes %s %d Angus", host_str, getpid()); + snprintf(cmp_str, sizeof(cmp_str), "tes %s %d Angus", host_str, + getpid()); ck_assert_str_eq(test_buf, cmp_str); } END_TEST