All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ramsay Jones <ramsay@ramsayjones.plus.com>
To: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>,
	linux-sparse@vger.kernel.org
Cc: Jacob Keller <jacob.e.keller@intel.com>
Subject: Re: [PATCH v2 08/16] apply_ctype: reverse the order of arguments
Date: Mon, 28 Dec 2020 16:47:01 +0000	[thread overview]
Message-ID: <3be177c7-b744-2d79-7f9b-935bc22b3db9@ramsayjones.plus.com> (raw)
In-Reply-To: <20201226175129.9621-9-luc.vanoostenryck@gmail.com>



On 26/12/2020 17:51, Luc Van Oostenryck wrote:
> apply_ctype()'s argument order is: src, dst (so the reading
> direction) but the assignment/memcpy() order is much more used:
> 	dst = src;
> 	memcpy(dst, src, n);
> than the order here is confusing.
> 
> So, change its argument order to comply with the memcpy()/
> assignement order and stop the confusion.

Hmm, how about:

"""
apply_ctype()'s argument order is 'src' then 'dst', which reads as
copying 'src' to 'dst'. However, assignment, and many library functions
(eg. memcpy()), use the opposite order for the source and destination
of a copy operation.

So, change the argument order of apply_ctype() to mimic the order of
memcpy()/assignment, to hopefully reduce any potential confusion.
"""

Heh, well that is probably not much better! ;-)

However, what about the (er...) position of the 'pos' argument?
Should it move to the end?

ATB,
Ramsay Jones

> 
> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
> ---
>  parse.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/parse.c b/parse.c
> index 402214212d77..f106444f75d8 100644
> --- a/parse.c
> +++ b/parse.c
> @@ -1043,7 +1043,7 @@ static struct token *enum_specifier(struct token *token, struct symbol *sym, str
>  	return ret;
>  }
>  
> -static void apply_ctype(struct position pos, struct ctype *src, struct ctype *dst);
> +static void apply_ctype(struct position pos, struct ctype *dst, struct ctype *src);
>  
>  static struct token *typeof_specifier(struct token *token, struct symbol *sym, struct decl_state *ctx)
>  {
> @@ -1056,7 +1056,7 @@ static struct token *typeof_specifier(struct token *token, struct symbol *sym, s
>  		struct symbol *sym;
>  		token = typename(token->next, &sym, NULL);
>  		ctx->ctype.base_type = sym->ctype.base_type;
> -		apply_ctype(token->pos, &sym->ctype, &ctx->ctype);
> +		apply_ctype(token->pos, &ctx->ctype, &sym->ctype);
>  	} else {
>  		struct symbol *typeof_sym = alloc_symbol(token->pos, SYM_TYPEOF);
>  		token = parse_expression(token->next, &typeof_sym->initializer);
> @@ -1427,7 +1427,7 @@ static struct token *generic_qualifier(struct token *next, struct symbol *sym, s
>  	return next;
>  }
>  
> -static void apply_ctype(struct position pos, struct ctype *src, struct ctype *dst)
> +static void apply_ctype(struct position pos, struct ctype *dst, struct ctype *src)
>  {
>  	unsigned long mod = src->modifiers;
>  
> @@ -1529,7 +1529,7 @@ static struct token *declaration_specifiers(struct token *token, struct decl_sta
>  				break;
>  			seen |= Set_S | Set_T;
>  			ctx->ctype.base_type = s->ctype.base_type;
> -			apply_ctype(token->pos, &s->ctype, &ctx->ctype);
> +			apply_ctype(token->pos, &ctx->ctype, &s->ctype);
>  			token = token->next;
>  			continue;
>  		}
> 

  reply	other threads:[~2020-12-28 16:48 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-26 17:51 [PATCH 00/16] support __packed struct Luc Van Oostenryck
2020-12-26 17:51 ` [PATCH v2 01/16] add testcases for dubious enum values Luc Van Oostenryck
2020-12-26 17:51 ` [PATCH v2 02/16] add testcases for exotic " Luc Van Oostenryck
2020-12-28 16:10   ` Ramsay Jones
2020-12-28 20:00     ` Luc Van Oostenryck
2020-12-26 17:51 ` [PATCH v2 03/16] add testcases for enum attributes Luc Van Oostenryck
2020-12-26 17:51 ` [PATCH v2 04/16] add testcases for type attributes Luc Van Oostenryck
2020-12-28 16:13   ` Ramsay Jones
2020-12-28 19:59     ` Luc Van Oostenryck
2020-12-26 17:51 ` [PATCH v2 05/16] add testcases for packed structures Luc Van Oostenryck
2020-12-28 16:17   ` Ramsay Jones
2020-12-28 20:01     ` Luc Van Oostenryck
2020-12-26 17:51 ` [PATCH v2 06/16] add testcases for packed bitfields Luc Van Oostenryck
2020-12-28 16:28   ` Ramsay Jones
2020-12-28 20:05     ` Luc Van Oostenryck
2020-12-26 17:51 ` [PATCH v2 07/16] apply_ctype: use self-explanatory argument name Luc Van Oostenryck
2020-12-26 17:51 ` [PATCH v2 08/16] apply_ctype: reverse the order of arguments Luc Van Oostenryck
2020-12-28 16:47   ` Ramsay Jones [this message]
2020-12-28 20:37     ` Luc Van Oostenryck
2020-12-26 17:51 ` [PATCH v2 09/16] apply_ctype: move up its declaration Luc Van Oostenryck
2020-12-26 17:51 ` [PATCH v2 10/16] struct-attr: prepare to handle attributes at the end of struct definitions (1) Luc Van Oostenryck
2020-12-28 16:54   ` Ramsay Jones
2020-12-28 20:49     ` Luc Van Oostenryck
2020-12-26 17:51 ` [PATCH v2 11/16] struct-attr: prepare to handle attributes at the end of struct definitions (2) Luc Van Oostenryck
2020-12-26 17:51 ` [PATCH v2 12/16] struct-attr: prepare to handle attributes at the end of struct definitions (3) Luc Van Oostenryck
2020-12-26 17:51 ` [PATCH v2 13/16] struct-attr: fix type attribute like 'struct __attr { ... }' Luc Van Oostenryck
2020-12-26 17:51 ` [PATCH v2 14/16] struct-attr: fix: do not ignore struct/union/enum type attributes Luc Van Oostenryck
2020-12-26 17:51 ` [PATCH v2 15/16] packed: no out-of-bound access of packed bitfields Luc Van Oostenryck
2020-12-28 17:10   ` Ramsay Jones
2020-12-28 21:12     ` Luc Van Oostenryck
2020-12-26 17:51 ` [PATCH v2 16/16] packed: add support for __packed struct Luc Van Oostenryck
2020-12-28 17:18 ` [PATCH 00/16] support " Ramsay Jones
2020-12-28 21:33   ` Luc Van Oostenryck
2021-01-05 17:56     ` Jacob Keller
2021-01-05 20:39       ` Luc Van Oostenryck
2021-01-05 22:07         ` Jacob Keller
2021-01-05 17:55 ` Jacob Keller

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=3be177c7-b744-2d79-7f9b-935bc22b3db9@ramsayjones.plus.com \
    --to=ramsay@ramsayjones.plus.com \
    --cc=jacob.e.keller@intel.com \
    --cc=linux-sparse@vger.kernel.org \
    --cc=luc.vanoostenryck@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.