From 3149cde3aa7f87298db3e256e784e6ca6fb76882 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Mon, 20 Jan 2020 16:59:05 -0500 Subject: [PATCH] lib: bt_version_get_extra(): return `NULL` if none instead of empty str. This follows the pattern we have for other optional strings returned by the library. Signed-off-by: Philippe Proulx Change-Id: I775f4f3be917bde405ad3b5e63183dae9609cf03 Reviewed-on: https://review.lttng.org/c/babeltrace/+/2833 Reviewed-by: Francis Deslauriers Tested-by: jenkins --- include/babeltrace2/version.h | 8 +------- src/lib/babeltrace2.c | 3 ++- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/include/babeltrace2/version.h b/include/babeltrace2/version.h index 7cd0213f..875fa2a7 100644 --- a/include/babeltrace2/version.h +++ b/include/babeltrace2/version.h @@ -92,13 +92,7 @@ This extra information can contain a version suffix such as -pre5 or -rc1. @returns - @parblock - Extra information about the library's version. - - Cannot be \c NULL. - - Can be an empty string if there's no extra information. - @endparblock + Extra information about the library's version, or \c NULL if none. */ extern const char *bt_version_get_extra(void); diff --git a/src/lib/babeltrace2.c b/src/lib/babeltrace2.c index 14572c29..8216cd11 100644 --- a/src/lib/babeltrace2.c +++ b/src/lib/babeltrace2.c @@ -24,6 +24,7 @@ #include #include +#include unsigned int bt_version_get_major(void) { @@ -41,5 +42,5 @@ unsigned int bt_version_get_patch(void) { const char *bt_version_get_extra(void) { - return BT_VERSION_EXTRA; + return strlen(BT_VERSION_EXTRA) == 0 ? NULL : BT_VERSION_EXTRA; } -- 2.34.1