[rtems commit] Add rtems_version_control_key_is_valid()

Sebastian Huber sebh at rtems.org
Wed Sep 11 05:28:54 UTC 2019


Module:    rtems
Branch:    master
Commit:    c1a1f2c8da4993b03f0a8fadac8f0521df48abec
Changeset: http://git.rtems.org/rtems/commit/?id=c1a1f2c8da4993b03f0a8fadac8f0521df48abec

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Tue Sep 10 09:21:11 2019 +0200

Add rtems_version_control_key_is_valid()

---

 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 30dd70c..a8aff73 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,12 +67,25 @@ 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.
  *
  * @return The board support package name.
diff --git a/testsuites/sptests/spversion01/init.c b/testsuites/sptests/spversion01/init.c
index fc38577..9db3143 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();




More information about the vc mailing list