Skip to content

Commit c752fcc

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent aedb5dc commit c752fcc

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

gpg-interface.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,6 @@ int verify_signed_buffer(const char *payload, size_t payload_size,
211211
char path[PATH_MAX];
212212
int fd, ret;
213213
struct strbuf buf = STRBUF_INIT;
214-
struct strbuf *pbuf = &buf;
215214

216215
fd = git_mkstemp(path, PATH_MAX, ".git_vtag_tmpXXXXXX");
217216
if (fd < 0)
@@ -242,17 +241,17 @@ int verify_signed_buffer(const char *payload, size_t payload_size,
242241
strbuf_read(gpg_output, gpg.err, 0);
243242
close(gpg.err);
244243
}
245-
if (gpg_status)
246-
pbuf = gpg_status;
247-
strbuf_read(pbuf, gpg.out, 0);
244+
if (!gpg_status)
245+
gpg_status = &buf;
246+
strbuf_read(gpg_status, gpg.out, 0);
248247
close(gpg.out);
249248

250249
ret = finish_command(&gpg);
251250
sigchain_pop(SIGPIPE);
252251

253252
unlink_or_warn(path);
254253

255-
ret |= !strstr(pbuf->buf, "\n[GNUPG:] GOODSIG ");
254+
ret |= !strstr(gpg_status->buf, "\n[GNUPG:] GOODSIG ");
256255
strbuf_release(&buf); /* no matter it was used or not */
257256

258257
return ret;

0 commit comments

Comments
 (0)