Re: [PATCH v2 06/27] update_refs(): Fix constness

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Michael Haggerty <mhagger@xxxxxxxxxxxx> writes:

> Since full const correctness is beyond the ability of C's type system,
> just put the const where it doesn't do any harm.  A (struct ref_update
> **) can be passed to a (struct ref_update * const *) argument, but not
> to a (const struct ref_update **) argument.

Sounds good, but next time please try not to break lines inside a
single typename, which is somewhat unreadable ;-)

I'd suggest rewording "s/Fix/tighten/".  Because a patch that
changes constness can loosen constness to make things more correct,
"git shortlog" output that says if it is tightening or loosening
would be more informative than the one that says that it is "fixing".

> Signed-off-by: Michael Haggerty <mhagger@xxxxxxxxxxxx>
> ---
>  builtin/update-ref.c | 2 +-
>  refs.c               | 2 +-
>  refs.h               | 2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/builtin/update-ref.c b/builtin/update-ref.c
> index f6345e5..a8a68e8 100644
> --- a/builtin/update-ref.c
> +++ b/builtin/update-ref.c
> @@ -14,7 +14,7 @@ static const char * const git_update_ref_usage[] = {
>  
>  static int updates_alloc;
>  static int updates_count;
> -static const struct ref_update **updates;
> +static struct ref_update **updates;
>  
>  static char line_termination = '\n';
>  static int update_flags;
> diff --git a/refs.c b/refs.c
> index 196984e..1305eb1 100644
> --- a/refs.c
> +++ b/refs.c
> @@ -3306,7 +3306,7 @@ static int ref_update_reject_duplicates(struct ref_update **updates, int n,
>  	return 0;
>  }
>  
> -int update_refs(const char *action, const struct ref_update **updates_orig,
> +int update_refs(const char *action, struct ref_update * const *updates_orig,
>  		int n, enum action_on_err onerr)
>  {
>  	int ret = 0, delnum = 0, i;
> diff --git a/refs.h b/refs.h
> index a713b34..08e60ac 100644
> --- a/refs.h
> +++ b/refs.h
> @@ -228,7 +228,7 @@ int update_ref(const char *action, const char *refname,
>  /**
>   * Lock all refs and then perform all modifications.
>   */
> -int update_refs(const char *action, const struct ref_update **updates,
> +int update_refs(const char *action, struct ref_update * const *updates,
>  		int n, enum action_on_err onerr);
>  
>  extern int parse_hide_refs_config(const char *var, const char *value, const char *);
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]