[PATCH] Add rtems_version_control_key_is_valid()

Sebastian Huber sebastian.huber at embedded-brains.de
Tue Sep 10 07:22:03 UTC 2019


---
 cpukit/include/rtems/version.h        | 19 +++++++++++++++++--
 testsuites/sptests/spversion01/init.c |  8 +++++++-
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/cpukit/include/rtems/version.h b/cpukit/include/rtems/version.h
index 30dd70cc21..a8aff732f3 100644
--- a/cpukit/include/rtems/version.h
+++ b/cpukit/include/rtems/version.h
@@ -16,6 +16,8 @@
 #ifndef _RTEMS_VERSION_H
 #define _RTEMS_VERSION_H
 
+#include <stdbool.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -65,11 +67,24 @@ int rtems_version_revision( void );
  * The key is specific to the version control system being used and allows the
  * built version to be identified.
  *
- * @return The version control key or the empty string if no version control
- * key is available.
+ * Use rtems_version_control_key_is_valid() to check if the version control key
+ * is valid.
+ *
+ * @return The version control key.
  */
 const char *rtems_version_control_key( void );
 
+/**
+ * @brief Returns true, if the version control key is valid, otherwise false.
+ *
+ * @retval true The version control key is valid.
+ * @retval false Otherwise.
+ */
+static inline bool rtems_version_control_key_is_valid( const char *key )
+{
+  return key[ 0 ] != '\0';
+}
+
 /**
  * @brief Returns the board support package name.
  *
diff --git a/testsuites/sptests/spversion01/init.c b/testsuites/sptests/spversion01/init.c
index fc38577691..9db3143d39 100644
--- a/testsuites/sptests/spversion01/init.c
+++ b/testsuites/sptests/spversion01/init.c
@@ -22,13 +22,19 @@ static rtems_task Init(
   rtems_task_argument argument
 )
 {
+  const char *key;
+  const char *valid;
+
   TEST_BEGIN();
 
+  key = rtems_version_control_key();
+  valid = rtems_version_control_key_is_valid(key) ? "valid" : "invalid";
+
   printf("Release  : %s\n", rtems_version());
   printf("Major    : %d\n", rtems_version_major());
   printf("Minor    : %d\n", rtems_version_minor());
   printf("Revision : %d\n", rtems_version_revision());
-  printf("VC Key   : %s\n", rtems_version_control_key());
+  printf("VC Key   : %s (%s)\n", key, valid);
   printf("BSP      : %s\n", rtems_board_support_package());
 
   TEST_END();
-- 
2.16.4




More information about the devel mailing list