diff options
author | René Scharfe <l.s.r@web.de> | 2014-08-19 21:09:35 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-08-20 09:53:37 -0700 |
commit | d3180279322c7450a47decf8833de47f444ca93f (patch) | |
tree | 6b15045aef08b51a0831ee75bb67fd0beddc0d0c /gpg-interface.c | |
parent | 6c4ab27f2378ce67940b4496365043119d7ffff2 (diff) | |
download | git-d3180279322c7450a47decf8833de47f444ca93f.tar.gz |
run-command: introduce CHILD_PROCESS_INIT
Most struct child_process variables are cleared using memset first after
declaration. Provide a macro, CHILD_PROCESS_INIT, that can be used to
initialize them statically instead. That's shorter, doesn't require a
function call and is slightly more readable (especially given that we
already have STRBUF_INIT, ARGV_ARRAY_INIT etc.).
Helped-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'gpg-interface.c')
-rw-r--r-- | gpg-interface.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/gpg-interface.c b/gpg-interface.c index ff07012726..1ef73fb7df 100644 --- a/gpg-interface.c +++ b/gpg-interface.c @@ -55,12 +55,11 @@ const char *get_signing_key(void) */ int sign_buffer(struct strbuf *buffer, struct strbuf *signature, const char *signing_key) { - struct child_process gpg; + struct child_process gpg = CHILD_PROCESS_INIT; const char *args[4]; ssize_t len; size_t i, j, bottom; - memset(&gpg, 0, sizeof(gpg)); gpg.argv = args; gpg.in = -1; gpg.out = -1; @@ -116,7 +115,7 @@ int verify_signed_buffer(const char *payload, size_t payload_size, const char *signature, size_t signature_size, struct strbuf *gpg_output, struct strbuf *gpg_status) { - struct child_process gpg; + struct child_process gpg = CHILD_PROCESS_INIT; const char *args_gpg[] = {NULL, "--status-fd=1", "--verify", "FILE", "-", NULL}; char path[PATH_MAX]; int fd, ret; @@ -133,7 +132,6 @@ int verify_signed_buffer(const char *payload, size_t payload_size, path, strerror(errno)); close(fd); - memset(&gpg, 0, sizeof(gpg)); gpg.argv = args_gpg; gpg.in = -1; gpg.out = -1; |