[PATCH 4/4] lib: rename json_strcpy to json_strdup

Ahmad Fatoum a.fatoum at pengutronix.de
Thu Sep 21 03:24:26 PDT 2023


json_strcpy is an unfortunate name for a function that allocates
memory. Rename it to json_strdup instead.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 include/jsmn.h   | 2 +-
 lib/jsmn.c       | 2 +-
 test/self/json.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/jsmn.h b/include/jsmn.h
index 64b3b535ab6e..156ae2086439 100644
--- a/include/jsmn.h
+++ b/include/jsmn.h
@@ -153,7 +153,7 @@ JSMN_API const jsmntok_t *jsmn_locate(const char *path[], const char *json,
  * value does not exist or is not a string. The caller takes ownership of the
  * pointer returned.
  */
-JSMN_API char *jsmn_strcpy(const char *path[], const char *json, const jsmntok_t *tokens);
+JSMN_API char *jsmn_strdup(const char *path[], const char *json, const jsmntok_t *tokens);
 
 #ifdef __cplusplus
 }
diff --git a/lib/jsmn.c b/lib/jsmn.c
index 9e624f7518ad..10a77886a8bd 100644
--- a/lib/jsmn.c
+++ b/lib/jsmn.c
@@ -483,7 +483,7 @@ JSMN_API const jsmntok_t *jsmn_locate(const char *path[], const char *json,
 	return tokens;
 }
 
-JSMN_API char *jsmn_strcpy(const char *path[], const char *json,
+JSMN_API char *jsmn_strdup(const char *path[], const char *json,
 			   const jsmntok_t *tokens)
 {
 	const jsmntok_t *node;
diff --git a/test/self/json.c b/test/self/json.c
index d3088f1b7542..489671768923 100644
--- a/test/self/json.c
+++ b/test/self/json.c
@@ -104,7 +104,7 @@ static void test_json(void)
 	token = jsmn_skip_value(token);
 	__json_expect(json, token, JP("boolean"), JSMN_PRIMITIVE, "true");
 
-	string = jsmn_strcpy(JP("string"), json, tokens);
+	string = jsmn_strdup(JP("string"), json, tokens);
 	if (WARN_ON(!string))
 		goto out;
 
-- 
2.39.2




More information about the barebox mailing list