DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Konstantin Ananyev <konstantin.ananyev@huawei.com>
To: Marat Khalili <marat.khalili@huawei.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: RE: [PATCH] cmdline: add cmdline_ prefix to dprintf
Date: Tue, 8 Sep 2026 11:37:53 +0000	[thread overview]
Message-ID: <e7faa5d769fe447aad8dccd2a54ad56e@huawei.com> (raw)
In-Reply-To: <20260908101534.71961-1-marat.khalili@huawei.com>



> -----Original Message-----
> From: Marat Khalili <marat.khalili@huawei.com>
> Sent: Tuesday, September 8, 2026 11:16 AM
> Cc: dev@dpdk.org
> Subject: [PATCH] cmdline: add cmdline_ prefix to dprintf
> 
> Macro `dprintf` defined in `cmdline_cirbuf.h` may clash with eponymous
> glibc macro. Add `cmdline_` prefix to the one defined by DPDK.
> 
> Signed-off-by: Marat Khalili <marat.khalili@huawei.com>
> ---
>  lib/cmdline/cmdline.c        |  2 +-
>  lib/cmdline/cmdline_cirbuf.c | 28 ++++++++++++++--------------
>  lib/cmdline/cmdline_cirbuf.h |  6 +++---
>  lib/cmdline/cmdline_socket.c |  2 +-
>  4 files changed, 19 insertions(+), 19 deletions(-)
> 
> diff --git a/lib/cmdline/cmdline.c b/lib/cmdline/cmdline.c
> index 51fbc36cefe1..1b2df0dcc8f6 100644
> --- a/lib/cmdline/cmdline.c
> +++ b/lib/cmdline/cmdline.c
> @@ -113,7 +113,7 @@ RTE_EXPORT_SYMBOL(cmdline_free)
>  void
>  cmdline_free(struct cmdline *cl)
>  {
> -	dprintf("called\n");
> +	cmdline_dprintf("called\n");
> 
>  	if (!cl)
>  		return;
> diff --git a/lib/cmdline/cmdline_cirbuf.c b/lib/cmdline/cmdline_cirbuf.c
> index 07d9fc6b904f..5cc09c887ca3 100644
> --- a/lib/cmdline/cmdline_cirbuf.c
> +++ b/lib/cmdline/cmdline_cirbuf.c
> @@ -41,13 +41,13 @@ cirbuf_add_buf_head(struct cirbuf *cbuf, const char *c,
> unsigned int n)
>  	e = CIRBUF_IS_EMPTY(cbuf) ? 1 : 0;
> 
>  	if (n < cbuf->start + e) {
> -		dprintf("s[%d] -> d[%d] (%d)\n", 0, cbuf->start - n + e, n);
> +		cmdline_dprintf("s[%d] -> d[%d] (%d)\n", 0, cbuf->start - n + e,
> n);
>  		memcpy(cbuf->buf + cbuf->start - n + e, c, n);
>  	}
>  	else {
> -		dprintf("s[%d] -> d[%d] (%d)\n", + n - (cbuf->start + e), 0,
> +		cmdline_dprintf("s[%d] -> d[%d] (%d)\n", + n - (cbuf->start + e),
> 0,
>  			cbuf->start + e);
> -		dprintf("s[%d] -> d[%d] (%d)\n", cbuf->maxlen - n +
> +		cmdline_dprintf("s[%d] -> d[%d] (%d)\n", cbuf->maxlen - n +
>  			(cbuf->start + e), 0, n - (cbuf->start + e));
>  		memcpy(cbuf->buf, c  + n - (cbuf->start + e) , cbuf->start + e);
>  		memcpy(cbuf->buf + cbuf->maxlen - n + (cbuf->start + e), c,
> @@ -73,13 +73,13 @@ cirbuf_add_buf_tail(struct cirbuf *cbuf, const char *c,
> unsigned int n)
>  	e = CIRBUF_IS_EMPTY(cbuf) ? 1 : 0;
> 
>  	if (n < cbuf->maxlen - cbuf->end - 1 + e) {
> -		dprintf("s[%d] -> d[%d] (%d)\n", 0, cbuf->end + !e, n);
> +		cmdline_dprintf("s[%d] -> d[%d] (%d)\n", 0, cbuf->end + !e, n);
>  		memcpy(cbuf->buf + cbuf->end + !e, c, n);
>  	}
>  	else {
> -		dprintf("s[%d] -> d[%d] (%d)\n", cbuf->end + !e, 0,
> +		cmdline_dprintf("s[%d] -> d[%d] (%d)\n", cbuf->end + !e, 0,
>  			cbuf->maxlen - cbuf->end - 1 + e);
> -		dprintf("s[%d] -> d[%d] (%d)\n", cbuf->maxlen - cbuf->end - 1 +
> +		cmdline_dprintf("s[%d] -> d[%d] (%d)\n", cbuf->maxlen - cbuf-
> >end - 1 +
>  			e, 0, n - cbuf->maxlen + cbuf->end + 1 - e);
>  		memcpy(cbuf->buf + cbuf->end + !e, c, cbuf->maxlen -
>  		       cbuf->end - 1 + e);
> @@ -352,19 +352,19 @@ cirbuf_get_buf_head(struct cirbuf *cbuf, char *c,
> unsigned int size)
>  		return 0;
> 
>  	if (cbuf->start <= cbuf->end) {
> -		dprintf("s[%d] -> d[%d] (%d)\n", cbuf->start, 0, n);
> +		cmdline_dprintf("s[%d] -> d[%d] (%d)\n", cbuf->start, 0, n);
>  		memcpy(c, cbuf->buf + cbuf->start , n);
>  	}
>  	else {
>  		/* check if we need to go from end to the beginning */
>  		if (n <= cbuf->maxlen - cbuf->start) {
> -			dprintf("s[%d] -> d[%d] (%d)\n", 0, cbuf->start, n);
> +			cmdline_dprintf("s[%d] -> d[%d] (%d)\n", 0, cbuf->start,
> n);
>  			memcpy(c, cbuf->buf + cbuf->start , n);
>  		}
>  		else {
> -			dprintf("s[%d] -> d[%d] (%d)\n", cbuf->start, 0,
> +			cmdline_dprintf("s[%d] -> d[%d] (%d)\n", cbuf->start, 0,
>  				cbuf->maxlen - cbuf->start);
> -			dprintf("s[%d] -> d[%d] (%d)\n", 0, cbuf->maxlen - cbuf-
> >start,
> +			cmdline_dprintf("s[%d] -> d[%d] (%d)\n", 0, cbuf-
> >maxlen - cbuf->start,
>  				n - cbuf->maxlen + cbuf->start);
>  			memcpy(c, cbuf->buf + cbuf->start , cbuf->maxlen - cbuf-
> >start);
>  			memcpy(c + cbuf->maxlen - cbuf->start, cbuf->buf,
> @@ -391,19 +391,19 @@ cirbuf_get_buf_tail(struct cirbuf *cbuf, char *c,
> unsigned int size)
>  		return 0;
> 
>  	if (cbuf->start <= cbuf->end) {
> -		dprintf("s[%d] -> d[%d] (%d)\n", cbuf->end - n + 1, 0, n);
> +		cmdline_dprintf("s[%d] -> d[%d] (%d)\n", cbuf->end - n + 1, 0, n);
>  		memcpy(c, cbuf->buf + cbuf->end - n + 1, n);
>  	}
>  	else {
>  		/* check if we need to go from end to the beginning */
>  		if (n <= cbuf->end + 1) {
> -			dprintf("s[%d] -> d[%d] (%d)\n", 0, cbuf->end - n + 1, n);
> +			cmdline_dprintf("s[%d] -> d[%d] (%d)\n", 0, cbuf->end - n
> + 1, n);
>  			memcpy(c, cbuf->buf + cbuf->end - n + 1, n);
>  		}
>  		else {
> -			dprintf("s[%d] -> d[%d] (%d)\n", 0,
> +			cmdline_dprintf("s[%d] -> d[%d] (%d)\n", 0,
>  				cbuf->maxlen - cbuf->start, cbuf->end + 1);
> -			dprintf("s[%d] -> d[%d] (%d)\n",
> +			cmdline_dprintf("s[%d] -> d[%d] (%d)\n",
>  				cbuf->maxlen - n + cbuf->end + 1, 0, n - cbuf->end
> - 1);
>  			memcpy(c + cbuf->maxlen - cbuf->start,
>  					       cbuf->buf, cbuf->end + 1);
> diff --git a/lib/cmdline/cmdline_cirbuf.h b/lib/cmdline/cmdline_cirbuf.h
> index 8e571462ca5c..acd95ebc82ba 100644
> --- a/lib/cmdline/cmdline_cirbuf.h
> +++ b/lib/cmdline/cmdline_cirbuf.h
> @@ -23,10 +23,10 @@ struct cirbuf {
>  };
> 
>  #ifdef RTE_LIBRTE_CMDLINE_DEBUG
> -#define dprintf_(fmt, ...) printf("line %3.3d - " fmt "%.0s", __LINE__,
> __VA_ARGS__)
> -#define dprintf(...) dprintf_(__VA_ARGS__, "dummy")
> +#define cmdline_dprintf_(fmt, ...) printf("line %3.3d - " fmt "%.0s", __LINE__,
> __VA_ARGS__)
> +#define cmdline_dprintf(...) cmdline_dprintf_(__VA_ARGS__, "dummy")
>  #else
> -#define dprintf(...) (void)0
> +#define cmdline_dprintf(...) ((void)0)
>  #endif
> 
> 
> diff --git a/lib/cmdline/cmdline_socket.c b/lib/cmdline/cmdline_socket.c
> index f3d62acdae41..9af3789fbc91 100644
> --- a/lib/cmdline/cmdline_socket.c
> +++ b/lib/cmdline/cmdline_socket.c
> @@ -26,7 +26,7 @@ cmdline_file_new(cmdline_parse_ctx_t *ctx, const char
> *prompt, const char *path)
> 
>  	fd = open(path, O_RDONLY, 0);
>  	if (fd < 0) {
> -		dprintf("open() failed\n");
> +		cmdline_dprintf("open() failed\n");
>  		return NULL;
>  	}
>  	return cmdline_new(ctx, prompt, fd, -1);
> --
Acked-by: Konstantin Ananyev <konstantin.ananyev@huawei.com>
> 2.43.0


      parent reply	other threads:[~2026-09-08 11:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-08 10:15 [PATCH] cmdline: add cmdline_ prefix to dprintf Marat Khalili
2026-09-08 10:18 ` Bruce Richardson
2026-09-08 11:37 ` Konstantin Ananyev [this message]

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=e7faa5d769fe447aad8dccd2a54ad56e@huawei.com \
    --to=konstantin.ananyev@huawei.com \
    --cc=dev@dpdk.org \
    --cc=marat.khalili@huawei.com \
    /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