From: Jonathan Nieder <jrnieder@gmail.com>
To: Justin Frankel <justin@cockos.com>
Cc: git@vger.kernel.org, eyvind.bernhardsen@gmail.com,
Bert Wesarg <bert.wesarg@googlemail.com>
Subject: Re: [PATCH v2] git-merge: ignore space support
Date: Tue, 24 Aug 2010 23:40:06 -0500 [thread overview]
Message-ID: <20100825044006.GJ11619@burratino> (raw)
In-Reply-To: <5F681E95-9369-490A-84FE-55B99EA8FE63@cockos.com>
Justin Frankel wrote:
> Fine by me... (ok if I were to nitpick I would probably make most of
> the internal static functions check that opts was non-NULL before
> dereferencing, in case the calling code ever changed
Not a bad idea. I'll squash in something like this.
A real BUG_ON macro would make this less ugly.
-- 8< --
Subject: ll-merge: BUG_ON(!opts) in internal functions
If one of the functions used to implement ll_merge() gets exposed,
callers would be likely to pass a NULL options argument, resulting in
segfaults. Die with a more meaningful message in that case.
Suggested-by: Justin Frankel <justin@cockos.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
ll-merge.c | 18 ++++++++++++++++--
1 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/ll-merge.c b/ll-merge.c
index 98f353a..8ff0b27 100644
--- a/ll-merge.c
+++ b/ll-merge.c
@@ -42,12 +42,17 @@ static int ll_binary_merge(const struct ll_merge_driver *drv_unused,
const struct ll_merge_options *opts,
int marker_size)
{
+ mmfile_t *stolen;
+
+ if (!opts)
+ die("BUG: !opts in binary merge driver");
+
/*
* The tentative merge result is "ours" for the final round,
* or common ancestor for an internal merge. Still return
* "conflicted merge" status.
*/
- mmfile_t *stolen = opts->virtual_ancestor ? orig : src1;
+ stolen = opts->virtual_ancestor ? orig : src1;
result->ptr = stolen->ptr;
result->size = stolen->size;
@@ -66,6 +71,9 @@ static int ll_xdl_merge(const struct ll_merge_driver *drv_unused,
{
xmparam_t xmp;
+ if (!opts)
+ die("BUG: !opts in xdiff merge driver");
+
if (buffer_is_binary(orig->ptr, orig->size) ||
buffer_is_binary(src1->ptr, src1->size) ||
buffer_is_binary(src2->ptr, src2->size)) {
@@ -102,7 +110,10 @@ static int ll_union_merge(const struct ll_merge_driver *drv_unused,
int marker_size)
{
/* Use union favor */
- struct ll_merge_options o = *opts;
+ struct ll_merge_options o;
+ if (!opts)
+ die("BUG: !opts in union merge driver");
+ o = *opts;
o.variant = XDL_MERGE_FAVOR_UNION;
return ll_xdl_merge(drv_unused, result, path_unused,
orig, NULL, src1, NULL, src2, NULL,
@@ -149,6 +160,9 @@ static int ll_ext_merge(const struct ll_merge_driver *fn,
int status, fd, i;
struct stat st;
+ if (!opts)
+ die("BUG: !opts in custom merge driver");
+
dict[0].placeholder = "O"; dict[0].value = temp[0];
dict[1].placeholder = "A"; dict[1].value = temp[1];
dict[2].placeholder = "B"; dict[2].value = temp[2];
--
1.7.2.2
next prev parent reply other threads:[~2010-08-25 4:42 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-23 20:59 [PATCH v2] git-merge: ignore space support Justin Frankel
2010-08-24 2:28 ` Jonathan Nieder
2010-08-24 3:39 ` [RFC/PATCH jn/merge-renormalize] merge-recursive: expose merge options for builtin merge Jonathan Nieder
2010-08-24 18:52 ` Junio C Hamano
2010-08-25 4:29 ` Jonathan Nieder
2010-08-24 4:30 ` [PATCH v2] git-merge: ignore space support Justin Frankel
2010-08-25 4:40 ` Jonathan Nieder [this message]
2010-08-25 7:22 ` Bert Wesarg
2010-08-25 15:51 ` Justin Frankel
2010-08-25 17:55 ` Junio C Hamano
2010-08-25 18:21 ` Justin Frankel
2010-08-24 19:01 ` Junio C Hamano
2010-08-24 20:01 ` Bert Wesarg
2010-08-25 3:57 ` Jonathan Nieder
2010-08-26 5:41 ` [PATCH v3 0/4] " Jonathan Nieder
2010-08-26 5:47 ` [PATCH 1/4] merge-recursive: expose merge options for builtin merge Jonathan Nieder
2010-08-26 5:49 ` [PATCH 2/4] ll-merge: replace flag argument with options struct Jonathan Nieder
2010-08-26 16:39 ` Junio C Hamano
2011-01-16 1:08 ` [PATCH v1.7.4-rc2] ll-merge: simplify opts == NULL case Jonathan Nieder
2010-08-26 5:50 ` [PATCH 3/4] merge-recursive --patience Jonathan Nieder
2010-08-26 5:51 ` [PATCH 4/4] merge-recursive: options to ignore whitespace changes Jonathan Nieder
2010-08-26 16:39 ` Junio C Hamano
2010-08-27 8:24 ` Jonathan Nieder
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100825044006.GJ11619@burratino \
--to=jrnieder@gmail.com \
--cc=bert.wesarg@googlemail.com \
--cc=eyvind.bernhardsen@gmail.com \
--cc=git@vger.kernel.org \
--cc=justin@cockos.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.
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 NNTP newsgroup(s).