Web lists-archives.com

Re: [GSoC][PATCH v3 09/13] sequencer: change the way skip_unnecessary_picks() returns its result




Alban Gruin <alban.gruin@xxxxxxxxx> writes:

> @@ -4467,7 +4467,7 @@ int skip_unnecessary_picks(void)
>  	}
>  
>  	todo_list_release(&todo_list);
> -	printf("%s\n", oid_to_hex(oid));
> +	*output_oid = oid_to_hex(oid);

The return value from oid_to_hex() is volatile and does not survive
across multiple calls to it.  If this interface is meant to be long
lived (as opposed to an intermediate step during the conversion that
will soon disappear), it probably makes more sense to have the
caller supply an output buffer and call oid_to_hex_r() into it, or
something like that.

> diff --git a/sequencer.h b/sequencer.h
> index 11a533461..25b50efe2 100644
> --- a/sequencer.h
> +++ b/sequencer.h
> @@ -88,7 +88,7 @@ int sequencer_add_exec_commands(const char *command);
>  int transform_todos(unsigned flags);
>  enum missing_commit_check_level get_missing_commit_check_level(void);
>  int check_todo_list(void);
> -int skip_unnecessary_picks(void);
> +int skip_unnecessary_picks(const char **output_oid);
>  int rearrange_squash(void);
>  
>  extern const char sign_off_header[];