mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <sha@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 4/4] lib: rename json_strcpy to json_strdup
Date: Thu, 21 Sep 2023 15:03:16 +0200	[thread overview]
Message-ID: <20230921130316.GQ637806@pengutronix.de> (raw)
In-Reply-To: <20230921102426.1109289-4-a.fatoum@pengutronix.de>

On Thu, Sep 21, 2023 at 12:24:26PM +0200, Ahmad Fatoum wrote:
> json_strcpy is an unfortunate name for a function that allocates
> memory. Rename it to json_strdup instead.

s/json_strcpy/jsmn_strcpy/
s/json_strdup/jsmn_strdup/

Sascha

> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@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
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



  reply	other threads:[~2023-09-21 13:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-21 10:24 [PATCH 1/4] lib: jsmn: add and use new jsmn_token_size helper Ahmad Fatoum
2023-09-21 10:24 ` [PATCH 2/4] lib: jsmn: add helper for allocating tokens Ahmad Fatoum
2023-09-21 10:24 ` [PATCH 3/4] lib: jsmn: add case-insensitive comparison Ahmad Fatoum
2023-09-21 10:24 ` [PATCH 4/4] lib: rename json_strcpy to json_strdup Ahmad Fatoum
2023-09-21 13:03   ` Sascha Hauer [this message]
2023-09-21 13:04     ` Ahmad Fatoum
2023-09-21 13:08       ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230921130316.GQ637806@pengutronix.de \
    --to=sha@pengutronix.de \
    --cc=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox