From e8822ac91488fa8516f3b184d40cd04ae3469ae5 Mon Sep 17 00:00:00 2001 From: Sebastian Reimers Date: Thu, 25 Apr 2024 16:41:35 +0200 Subject: [PATCH 1/6] ci/coverage: increase min. coverage (#1106) --- .github/workflows/coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 96294ba79..5065fad46 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -48,7 +48,7 @@ jobs: - name: coverage check run: | - min_cov="63.8" + min_cov="64.4" cov=$(~/.local/bin/gcovr -r . -s | grep lines | awk '{ print $2 }' | sed 's/%//') echo "Coverage: ${cov}% (min $min_cov%)" exit $(echo "$cov < $min_cov" | bc -l) From 2b3bbaff9db2738bf204ce4c4183dfa139378a95 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" <114750+alfredh@users.noreply.github.com> Date: Sun, 28 Apr 2024 08:21:45 +0200 Subject: [PATCH 2/6] rtp: fix correct logging text (#1109) --- src/rtp/sess.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rtp/sess.c b/src/rtp/sess.c index f577325d2..88b5773c6 100644 --- a/src/rtp/sess.c +++ b/src/rtp/sess.c @@ -608,7 +608,7 @@ void rtcp_sess_rx_rtp(struct rtcp_sess *sess, struct rtp_header *hdr, } if (!rtp_source_update_seq(mbr->s, hdr->seq)) { - DEBUG_WARNING("rtp_update_seq() returned 0\n"); + DEBUG_WARNING("rtp_source_update_seq() returned 0\n"); } if (sess->srate_rx) { From f3178afe88b19ebd6dbce6fe9ed2a23f68bc4f1e Mon Sep 17 00:00:00 2001 From: Sebastian Reimers Date: Sun, 28 Apr 2024 10:25:47 +0200 Subject: [PATCH 3/6] types: fix RE_ARG_SIZE bit fields (#1110) GCC workaround for bit fields (always default otherwise). --- include/re_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/re_types.h b/include/re_types.h index 739b1dcf0..336eea919 100644 --- a/include/re_types.h +++ b/include/re_types.h @@ -303,7 +303,7 @@ typedef int re_sock_t; #define HAVE_RE_ARG 1 #define RE_ARG_SIZE(type) \ - _Generic((type), \ + _Generic((0)?(type):(type), \ bool: sizeof(int), \ char: sizeof(int), \ unsigned char: sizeof(unsigned int), \ From 2b331963f5fa5a08615b43a339d5f6365a57ea68 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" <114750+alfredh@users.noreply.github.com> Date: Sun, 28 Apr 2024 10:52:24 +0200 Subject: [PATCH 4/6] fmt: use re_fprintf instead of DEBUG_WARNING to avoid deadlock (#1112) --- src/fmt/print.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/fmt/print.c b/src/fmt/print.c index a02fb858b..040dd3aac 100644 --- a/src/fmt/print.c +++ b/src/fmt/print.c @@ -494,11 +494,12 @@ static int vhprintf(const char *fmt, va_list ap, re_vprintf_h *vph, void *arg, out: #ifndef RELEASE if (err == ENODATA) { - DEBUG_WARNING("Format: \"%b<-- NO ARG\n", fmt, p - fmt + 1); + re_fprintf(stderr, "Format: \"%b<-- NO ARG\n", + fmt, p - fmt + 1); re_assert(0 && "RE_VA_ARG: no more arguments"); } if (err == EOVERFLOW) { - DEBUG_WARNING("Format: \"%b<-- SIZE ERROR\n", fmt, + re_fprintf(stderr, "Format: \"%b<-- SIZE ERROR\n", fmt, p - fmt + 1); re_assert(0 && "RE_VA_ARG: arg is not compatible"); } From b5da6fc4effb80411e65ae91fbfe4a1332679da4 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" <114750+alfredh@users.noreply.github.com> Date: Sun, 28 Apr 2024 11:08:12 +0200 Subject: [PATCH 5/6] dbg: remove support for logfile (#1111) --- include/re_dbg.h | 1 - src/dbg/dbg.c | 44 ++------------------------------------------ 2 files changed, 2 insertions(+), 43 deletions(-) diff --git a/include/re_dbg.h b/include/re_dbg.h index 8ab1e9370..4db88698e 100644 --- a/include/re_dbg.h +++ b/include/re_dbg.h @@ -114,7 +114,6 @@ typedef void (dbg_print_h)(int level, const char *p, size_t len, void *arg); void dbg_init(int level, enum dbg_flags flags); void dbg_close(void); -int dbg_logfile_set(const char *name); void dbg_handler_set(dbg_print_h *ph, void *arg); void dbg_printf(int level, const char *fmt, ...); const char *dbg_level_str(int level); diff --git a/src/dbg/dbg.c b/src/dbg/dbg.c index e7a19ea84..df3e74847 100644 --- a/src/dbg/dbg.c +++ b/src/dbg/dbg.c @@ -28,14 +28,12 @@ static struct { enum dbg_flags flags; /**< Debug flags */ dbg_print_h *ph; /**< Optional print handler */ void *arg; /**< Handler argument */ - FILE *f; /**< Logfile */ } dbg = { 0, DBG_INFO, DBG_ANSI, NULL, NULL, - NULL, }; static once_flag flag = ONCE_FLAG_INIT; @@ -82,37 +80,6 @@ void dbg_init(int level, enum dbg_flags flags) */ void dbg_close(void) { - if (dbg.f) { - (void)fclose(dbg.f); - dbg.f = NULL; - } -} - - -/** - * Set debug logfile - * - * @param name Name of the logfile, NULL to close - * - * @return 0 if success, otherwise errorcode - */ -int dbg_logfile_set(const char *name) -{ - int err; - - dbg_close(); - - if (!name) - return 0; - - err = fs_fopen(&dbg.f, name, "a+"); - if (err) - return err; - - (void)re_fprintf(dbg.f, "\n===== Log Started: %H", fmt_gmtime, NULL); - (void)fflush(dbg.f); - - return 0; } @@ -180,7 +147,7 @@ static void dbg_vprintf(int level, const char *fmt, va_list ap) } -/* Formatted output to print handler and/or logfile */ +/* Formatted output to print handler */ static void dbg_fmt_vprintf(int level, const char *fmt, va_list ap) { char buf[256]; @@ -191,10 +158,9 @@ static void dbg_fmt_vprintf(int level, const char *fmt, va_list ap) if (level > dbg.level) goto out; - if (!dbg.ph && !dbg.f) + if (!dbg.ph) goto out; - len = re_vsnprintf(buf, sizeof(buf), fmt, ap); if (len <= 0) goto out; @@ -204,12 +170,6 @@ static void dbg_fmt_vprintf(int level, const char *fmt, va_list ap) dbg.ph(level, buf, len, dbg.arg); } - /* Output to file */ - if (dbg.f) { - if (fwrite(buf, 1, len, dbg.f) > 0) - (void)fflush(dbg.f); - } - out: dbg_unlock(); } From 06ce16c003d591a8d12a8694035ef1895cc49760 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" <114750+alfredh@users.noreply.github.com> Date: Mon, 29 Apr 2024 08:28:06 +0200 Subject: [PATCH 6/6] test: add usage of rtcp_msg_print() (#1105) --- test/rtp.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/rtp.c b/test/rtp.c index ca67f2d81..3ed53dd6d 100644 --- a/test/rtp.c +++ b/test/rtp.c @@ -243,6 +243,7 @@ int test_rtcp_encode(void) struct mbuf *mb; const size_t sz = sizeof(rtcp_msg) - 1; const uint32_t srcv[2] = {0x12345678, 0x00abcdef}; + char debug_buf[512]; int err = 0; mb = mbuf_alloc(512); @@ -285,7 +286,17 @@ int test_rtcp_encode(void) while (mbuf_get_left(mb) >= 4 && !err) { struct rtcp_msg *msg = NULL; err = rtcp_decode(&msg, mb); + if (err) + break; + + /* Check that debug print works */ + debug_buf[0] = '\0'; + re_snprintf(debug_buf, sizeof(debug_buf), + "%H", rtcp_msg_print, msg); + msg = mem_deref(msg); + + ASSERT_TRUE(str_isset(debug_buf)); } if (err) goto out;