git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: David Michael Barr <davidbarr@google.com>
To: Jonathan Nieder <jrnieder@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH 7/7] vcs-svn: fix clang-analyzer warning
Date: Thu, 31 May 2012 21:34:59 +1000	[thread overview]
Message-ID: <CAFfmPPPmnS4f4+JVhLFqcNM+taj4VO6ZVMv8RCoEiQqKHGy_1g@mail.gmail.com> (raw)
In-Reply-To: <20120524143337.GB3732@burratino>

On Fri, May 25, 2012 at 12:33 AM, Jonathan Nieder <jrnieder@gmail.com> wrote:
> David Barr wrote:
>
>> vcs-svn/svndiff.c:278:3: warning: expression result unused [-Wunused-value]
>>                 error("invalid delta: incorrect postimage length");
>>                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> In file included from vcs-svn/svndiff.c:6:
>> vcs-svn/compat-util.h:18:61: note: instantiated from:
>> #define error(...) (fprintf(stderr, "error: " __VA_ARGS__), -1)
>>                                                             ^~
>
> Yuck.  Would you be ok with an inline variadic function?
>
>  static inline int error(const char *fmt, ...)
>  {
>        va_list ap;
>
>        fprintf(stderr, "error: ");
>
>        va_start(ap, fmt);
>        vfprintf(stderr, fmt, ap)
>        va_end(ap);
>
>        fprintf(stderr, "\n");
>
>        return -1;
>  }
>
> The error() macro above also seems to leave out a newline.
>
>> --- a/vcs-svn/svndiff.c
>> +++ b/vcs-svn/svndiff.c
>> @@ -258,6 +258,7 @@ static int apply_window_in_core(struct window *ctx)
> [...]
>> @@ -275,16 +276,15 @@ static int apply_one_window(struct line_buffer *delta, off_t *delta_len,
>>       if (apply_window_in_core(&ctx))
>>               goto error_out;
>>       if (ctx.out.len != out_len) {
>> -             error("invalid delta: incorrect postimage length");
>> +             rv = error("invalid delta: incorrect postimage length");
>>               goto error_out;
>>       }
>>       if (write_strbuf(&ctx.out, out))
>>               goto error_out;
>> -     window_release(&ctx);
>> -     return 0;
>> +     rv = 0;
>>  error_out:
>>       window_release(&ctx);
>> -     return -1;
>> +     return rv;
>
> That said, if this change is justified by saying that it avoids having
> to repeat the cleanup code, it already looks like a good change.  The
> commit message could mention that the original motivation and a
> side-benefit is to help the standalone version that has a slightly
> crazier definition of error().

I'll rework the commit message and requeue.

--
David Barr.

      reply	other threads:[~2012-05-31 11:35 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-24 14:04 [PATCH 0/7] vcs-svn: housekeeping David Barr
2012-05-24 14:04 ` [PATCH 1/7] vcs-svn: prefer constcmp to prefixcmp David Barr
2012-05-24 14:04 ` [PATCH 2/7] vcs-svn: prefer strstr over memmem David Barr
2012-05-24 14:04 ` [PATCH 3/7] vcs-svn: fix signedness warnings David Barr
2012-05-24 14:48   ` Jonathan Nieder
2012-05-31 13:14     ` David Michael Barr
2012-05-24 14:04 ` [PATCH 4/7] vcs-svn: drop no-op reset methods David Barr
2012-05-24 14:04 ` [PATCH 5/7] vcs-svn: fix cppcheck warning David Barr
2012-05-24 14:20   ` Jonathan Nieder
2012-05-31 11:17     ` David Michael Barr
2012-05-24 14:04 ` [PATCH 6/7] vcs-svn: fix clang-analyzer error David Barr
2012-05-24 14:04 ` [PATCH 7/7] vcs-svn: fix clang-analyzer warning David Barr
2012-05-24 14:33   ` Jonathan Nieder
2012-05-31 11:34     ` David Michael Barr [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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFfmPPPmnS4f4+JVhLFqcNM+taj4VO6ZVMv8RCoEiQqKHGy_1g@mail.gmail.com \
    --to=davidbarr@google.com \
    --cc=git@vger.kernel.org \
    --cc=jrnieder@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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).