From: Junio C Hamano <junkio@cox.net>
To: Morten Welinder <mwelinder@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Add compat/setenv.c, use in git.c.
Date: Tue, 06 Dec 2005 13:41:48 -0800 [thread overview]
Message-ID: <7vwtih299f.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <118833cc0512061310r6398f812ia47a84d3cfad1564@mail.gmail.com> (Morten Welinder's message of "Tue, 6 Dec 2005 16:10:56 -0500")
Morten Welinder <mwelinder@gmail.com> writes:
> The code looks wrong. It assumes that pointers are no larger than ints.
> If pointers are larger than ints, the code does not necessarily compute
> a consistent ordering and qsort is allowed to do whatever it wants.
>
> Morten
>
>
>
> static int compare_object_pointers(const void *a, const void *b)
> {
> const struct object * const *pa = a;
> const struct object * const *pb = b;
> return *pa - *pb;
> }
Are you suggesting it to be done like this?
---
git diff
diff --git a/object.c b/object.c
index 427e14c..dac5c92 100644
--- a/object.c
+++ b/object.c
@@ -82,7 +82,12 @@ static int compare_object_pointers(const
{
const struct object * const *pa = a;
const struct object * const *pb = b;
- return *pa - *pb;
+ if (*pa == *pb)
+ return 0;
+ else if (*pa < *pb)
+ return -1;
+ else
+ return 1;
}
void set_object_refs(struct object *obj, struct object_refs *refs)
next prev parent reply other threads:[~2005-12-06 21:41 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-12-02 23:08 [PATCH] Add compat/setenv.c, use in git.c Jason Riedy
2005-12-04 6:26 ` Junio C Hamano
2005-12-04 21:07 ` H. Peter Anvin
2005-12-04 22:24 ` Junio C Hamano
2005-12-04 22:31 ` Junio C Hamano
2005-12-04 23:34 ` H. Peter Anvin
2005-12-05 18:07 ` Jason Riedy
2005-12-05 18:39 ` H. Peter Anvin
2005-12-06 3:35 ` Junio C Hamano
2005-12-06 19:59 ` Jason Riedy
2005-12-06 21:10 ` Morten Welinder
2005-12-06 21:41 ` Junio C Hamano [this message]
2005-12-06 22:18 ` Jason Riedy
2005-12-07 0:58 ` Morten Welinder
2005-12-04 23:01 ` [PATCH] compat/setenv: do not free what we fed putenv(3) Junio C Hamano
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=7vwtih299f.fsf@assigned-by-dhcp.cox.net \
--to=junkio@cox.net \
--cc=git@vger.kernel.org \
--cc=mwelinder@gmail.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).