Re: [PATCH 6/6] strbuf: remove environment variables

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

 



On Tue, May 2, 2023 at 2:15 PM Calvin Wan <calvinwan@xxxxxxxxxx> wrote:
>
> As a lower level library, strbuf should not directly access environment
> variables within its functions. Therefore, add an additional variable to
> function signatures for functions that use an environment variable and
> refactor callers to pass in the environment variable.

Yaay!  I hate the pervasive implicit use of globals throughout the
codebase, and like seeing changes that at least make them less hidden.

I might have split this patch into three, one for each of the
functions you are changing.  The reason is just that it makes review
so much easier; a simple --color-words view then becomes easy
to rapidly scan through on each patch.  When one patch includes all
three, reviewers have to double check the position of the added
parameter in the argument list against the name of the function.  But
that's a really minor point, and some might prefer as you have it here
with the three squashed together.

[...]
> diff --git a/strbuf.h b/strbuf.h
> index b6d53c1cbe..f90da8859f 100644
> --- a/strbuf.h
> +++ b/strbuf.h
> @@ -283,7 +283,8 @@ void strbuf_splice(struct strbuf *sb, size_t pos, size_t len,
>   * by a comment character and a blank.
>   */
>  void strbuf_add_commented_lines(struct strbuf *out,
> -                               const char *buf, size_t size);
> +                               const char *buf, size_t size,
> +                               char comment_line_char);
>
>
>  /**
> @@ -412,8 +413,8 @@ void strbuf_addf(struct strbuf *sb, const char *fmt, ...);
>   * Add a formatted string prepended by a comment character and a
>   * blank to the buffer.
>   */
> -__attribute__((format (printf, 2, 3)))
> -void strbuf_commented_addf(struct strbuf *sb, const char *fmt, ...);
> +__attribute__((format (printf, 3, 4)))
> +void strbuf_commented_addf(struct strbuf *sb, char comment_line_char, const char *fmt, ...);
>
>  __attribute__((format (printf,2,0)))
>  void strbuf_vaddf(struct strbuf *sb, const char *fmt, va_list ap);
> @@ -538,7 +539,7 @@ int strbuf_normalize_path(struct strbuf *sb);
>   * Strip whitespace from a buffer. The second parameter controls if
>   * comments are considered contents to be removed or not.

Should this documentation string be updated, given that it previously
documented all arguments to the function?

>   */
> -void strbuf_stripspace(struct strbuf *buf, int skip_comments);
> +void strbuf_stripspace(struct strbuf *buf, int skip_comments, char comment_line_char);
>
>  static inline int strbuf_strip_suffix(struct strbuf *sb, const char *suffix)
>  {
[...]

The rest looks good to me.




[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]

  Powered by Linux