Skip to content

Commit

Permalink
lib: bt_version_get_extra(): return NULL if none instead of empty str.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
eepp authored and jgalar committed Jan 21, 2020
1 parent fbc5b30 commit 3149cde
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
8 changes: 1 addition & 7 deletions include/babeltrace2/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
3 changes: 2 additions & 1 deletion src/lib/babeltrace2.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include <babeltrace2/babeltrace.h>
#include <stdlib.h>
#include <string.h>

unsigned int bt_version_get_major(void)
{
Expand All @@ -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;
}

0 comments on commit 3149cde

Please sign in to comment.