From: Junio C Hamano Date: Sun, 18 Nov 2018 09:23:57 +0000 (+0900) Subject: Merge branch 'cb/notes-freeing-always-null-fix' X-Git-Tag: v2.20.0-rc0~13 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/e14af5f7aa31e4377ac016b8df83ec70de8899fd?ds=inline;hp=-c Merge branch 'cb/notes-freeing-always-null-fix' Code cleanup. * cb/notes-freeing-always-null-fix: builtin/notes: remove unnecessary free --- e14af5f7aa31e4377ac016b8df83ec70de8899fd diff --combined builtin/notes.c index 91faa514aa,68062f7475..c78b7a0c5b --- a/builtin/notes.c +++ b/builtin/notes.c @@@ -215,8 -215,6 +215,8 @@@ static int parse_msg_arg(const struct o { struct note_data *d = opt->value; + BUG_ON_OPT_NEG(unset); + strbuf_grow(&d->buf, strlen(arg) + 2); if (d->buf.len) strbuf_addch(&d->buf, '\n'); @@@ -231,8 -229,6 +231,8 @@@ static int parse_file_arg(const struct { struct note_data *d = opt->value; + BUG_ON_OPT_NEG(unset); + if (d->buf.len) strbuf_addch(&d->buf, '\n'); if (!strcmp(arg, "-")) { @@@ -254,17 -250,13 +254,15 @@@ static int parse_reuse_arg(const struc enum object_type type; unsigned long len; + BUG_ON_OPT_NEG(unset); + if (d->buf.len) strbuf_addch(&d->buf, '\n'); if (get_oid(arg, &object)) die(_("failed to resolve '%s' as a valid ref."), arg); - if (!(buf = read_object_file(&object, &type, &len))) { - free(buf); + if (!(buf = read_object_file(&object, &type, &len))) die(_("failed to read object '%s'."), arg); - } if (type != OBJ_BLOB) { free(buf); die(_("cannot read note data from non-blob object '%s'."), arg); @@@ -279,7 -271,6 +277,7 @@@ static int parse_reedit_arg(const struct option *opt, const char *arg, int unset) { struct note_data *d = opt->value; + BUG_ON_OPT_NEG(unset); d->use_editor = 1; return parse_reuse_arg(opt, arg, unset); }