Re: [PATCH] rtems: Make rtems_version_control_key() safer

2019-09-10 Thread Peter Dufault



> On Sep 9, 2019, at 22:00 , Chris Johns  wrote:
> 
> I would prefer we provide an interface to say the version control key has been
> set rather than exposing how we manage it. I think the change to not return 
> NULL
> is the correct one. What about adding ..
> 
> bool rtems_version_control_key_valid( void )
> {
>  return strlen( rtems_version_control_key( ) ) != 0;
> }
> 
> I have a feeling we may wedge ourselves in the future with users having code 
> to
> check the length.
> 
> Chris

I usually want both, that is, I always want the consistent error code interface 
(0 vs !0) and I frequently want more convenient interfaces.

Peter
-
Peter Dufault
HD Associates, Inc.  Software and System Engineering

This email is delivered through the public internet using protocols subject to 
interception and tampering.

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: [PATCH] rtems: Make rtems_version_control_key() safer

2019-09-09 Thread Chris Johns
On 6/9/19 10:34 pm, Sebastian Huber wrote:
> Return the empty string instead of a NULL pointer if no version key is
> available.
> ---
>  cpukit/include/rtems/version.h | 9 ++---
>  cpukit/sapi/src/version.c  | 2 +-
>  2 files changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/cpukit/include/rtems/version.h b/cpukit/include/rtems/version.h
> index d8c1206d91..30dd70cc21 100644
> --- a/cpukit/include/rtems/version.h
> +++ b/cpukit/include/rtems/version.h
> @@ -60,10 +60,13 @@ int rtems_version_revision( void );
>  
>  /**
>   * @brief Returns the version control key for the current version of code 
> that
> - * has been built. The key is specific to the version control system being 
> used
> - * and allows the built version to be identified.
> + * has been built.
>   *
> - * @retval int The version's version control key.
> + * 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.

Or ...

@return The version control key if @ref rtems_version_control_key_valid returns
true.

>   */
>  const char *rtems_version_control_key( void );
>  
> diff --git a/cpukit/sapi/src/version.c b/cpukit/sapi/src/version.c
> index e1e7705863..065a45c005 100644
> --- a/cpukit/sapi/src/version.c
> +++ b/cpukit/sapi/src/version.c
> @@ -58,6 +58,6 @@ const char *rtems_version_control_key( void )
>  #ifdef RTEMS_VERSION_VC_KEY
>return RTEMS_VERSION_VC_KEY;
>  #else
> -  return NULL;
> +  return "";
>  #endif
>  }

I would prefer we provide an interface to say the version control key has been
set rather than exposing how we manage it. I think the change to not return NULL
is the correct one. What about adding ..

bool rtems_version_control_key_valid( void )
{
  return strlen( rtems_version_control_key( ) ) != 0;
}

I have a feeling we may wedge ourselves in the future with users having code to
check the length.

Chris
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH] rtems: Make rtems_version_control_key() safer

2019-09-06 Thread Sebastian Huber
Return the empty string instead of a NULL pointer if no version key is
available.
---
 cpukit/include/rtems/version.h | 9 ++---
 cpukit/sapi/src/version.c  | 2 +-
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/cpukit/include/rtems/version.h b/cpukit/include/rtems/version.h
index d8c1206d91..30dd70cc21 100644
--- a/cpukit/include/rtems/version.h
+++ b/cpukit/include/rtems/version.h
@@ -60,10 +60,13 @@ int rtems_version_revision( void );
 
 /**
  * @brief Returns the version control key for the current version of code that
- * has been built. The key is specific to the version control system being used
- * and allows the built version to be identified.
+ * has been built.
  *
- * @retval int The version's version control key.
+ * 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.
  */
 const char *rtems_version_control_key( void );
 
diff --git a/cpukit/sapi/src/version.c b/cpukit/sapi/src/version.c
index e1e7705863..065a45c005 100644
--- a/cpukit/sapi/src/version.c
+++ b/cpukit/sapi/src/version.c
@@ -58,6 +58,6 @@ const char *rtems_version_control_key( void )
 #ifdef RTEMS_VERSION_VC_KEY
   return RTEMS_VERSION_VC_KEY;
 #else
-  return NULL;
+  return "";
 #endif
 }
-- 
2.16.4

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel