[PATCH] libosmocore[master]: utils: add osmo_strscpy() macro to use sizeof(dst)

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Fri Jan 13 13:41:28 UTC 2017


Review at  https://gerrit.osmocom.org/1599

utils: add osmo_strscpy() macro to use sizeof(dst)

Change-Id: Ie973fc51835066540eba7ed2946ddf33a268b022
---
M include/osmocom/core/utils.h
M src/utils.c
2 files changed, 5 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/99/1599/1

diff --git a/include/osmocom/core/utils.h b/include/osmocom/core/utils.h
index 0d61901..4ff9726 100644
--- a/include/osmocom/core/utils.h
+++ b/include/osmocom/core/utils.h
@@ -89,4 +89,8 @@
 size_t osmo_strlcpy(char *dst, const char *src, size_t siz);
 char *osmo_strncpy(char *dst, const char *src, size_t siz);
 
+/*! \brief Call osmo_strncpy() with the \a siz arg passed as sizeof(dst). */
+#define osmo_strscpy(dest, src) \
+	osmo_strncpy(dest, src, sizeof(dest))
+
 /*! @} */
diff --git a/src/utils.c b/src/utils.c
index e2a5db2..a884785 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -379,7 +379,7 @@
  *
  * If \a siz is zero or \a src is NULL, copy nothing and return \a dst.
  *
- * \see osmo_strlcpy
+ * \see osmo_strlcpy, osmo_strscpy
  */
 char *osmo_strncpy(char *dst, const char *src, size_t siz)
 {

-- 
To view, visit https://gerrit.osmocom.org/1599
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie973fc51835066540eba7ed2946ddf33a268b022
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list