diff options
author | Jeff King <peff@peff.net> | 2016-06-17 19:38:39 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-06-17 17:03:56 -0700 |
commit | c752fcc8e0df02c6b1bd4daec1d08f0f2bcca58a (patch) | |
tree | 0a0ac84dda11ce94bfdec9d4d66c35d5c458259b /gpg-interface.c | |
parent | aedb5dc343be58c17dc974be401f6d2a9fa26d1e (diff) | |
download | git-c752fcc8e0df02c6b1bd4daec1d08f0f2bcca58a.tar.gz |
verify_signed_buffer: drop pbuf variable
If our caller gave us a non-NULL gpg_status parameter, we
write the gpg status into their strbuf. If they didn't, then
we write it to a temporary local strbuf (since we still need
to look at it). The variable "pbuf" adds an extra layer of
indirection so that the rest of the function can just access
whichever is appropriate.
However, the name "pbuf" isn't very descriptive, and it's
easy to get confused about what is supposed to be in it
(especially because we are reading both "status" and
"output" from gpg).
Rather than give it a more descriptive name, we can just use
gpg_status as our indirection pointer. Either it points to
the caller's input, or we can point it directly to our
temporary buffer.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'gpg-interface.c')
-rw-r--r-- | gpg-interface.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/gpg-interface.c b/gpg-interface.c index 0ed9fa75ff..216cad85be 100644 --- a/gpg-interface.c +++ b/gpg-interface.c @@ -211,7 +211,6 @@ int verify_signed_buffer(const char *payload, size_t payload_size, char path[PATH_MAX]; int fd, ret; struct strbuf buf = STRBUF_INIT; - struct strbuf *pbuf = &buf; fd = git_mkstemp(path, PATH_MAX, ".git_vtag_tmpXXXXXX"); if (fd < 0) @@ -242,9 +241,9 @@ int verify_signed_buffer(const char *payload, size_t payload_size, strbuf_read(gpg_output, gpg.err, 0); close(gpg.err); } - if (gpg_status) - pbuf = gpg_status; - strbuf_read(pbuf, gpg.out, 0); + if (!gpg_status) + gpg_status = &buf; + strbuf_read(gpg_status, gpg.out, 0); close(gpg.out); ret = finish_command(&gpg); @@ -252,7 +251,7 @@ int verify_signed_buffer(const char *payload, size_t payload_size, unlink_or_warn(path); - ret |= !strstr(pbuf->buf, "\n[GNUPG:] GOODSIG "); + ret |= !strstr(gpg_status->buf, "\n[GNUPG:] GOODSIG "); strbuf_release(&buf); /* no matter it was used or not */ return ret; |