lib: bt_version_get_extra(): return `NULL` if none instead of empty str.
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Mon, 20 Jan 2020 21:59:05 +0000 (16:59 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 21 Jan 2020 20:14:32 +0000 (15:14 -0500)
This follows the pattern we have for other optional strings returned by
the library.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I775f4f3be917bde405ad3b5e63183dae9609cf03
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2833
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
include/babeltrace2/version.h
src/lib/babeltrace2.c

index 7cd0213f9b62952d297d4a3a679fd241f6cc18df..875fa2a71c89c3d800c35b488badc611fd118b87 100644 (file)
@@ -92,13 +92,7 @@ This extra information can contain a version suffix such as
 <code>-pre5</code> or <code>-rc1</code>.
 
 @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);
 
index 14572c29d2484131d768c0d5dab614e6c41747f5..8216cd11ad05a29a5baa66f917734eaa0445a639 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <babeltrace2/babeltrace.h>
 #include <stdlib.h>
+#include <string.h>
 
 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;
 }
This page took 0.026261 seconds and 4 git commands to generate.