git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] trace.c: mark file-local function static
@ 2010-12-16 22:38 Vasyl'
  2010-12-16 23:43 ` Thiago Farina
  0 siblings, 1 reply; 14+ messages in thread
From: Vasyl' @ 2010-12-16 22:38 UTC (permalink / raw)
  To: git

Signed-off-by: Vasyl' Vavrychuk <vvavrychuk@gmail.com>
---
 trace.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/trace.c b/trace.c
index 1e560cb..62586fa 100644
--- a/trace.c
+++ b/trace.c
@@ -25,7 +25,7 @@
 #include "cache.h"
 #include "quote.h"

-void do_nothing(size_t unused)
+static void do_nothing(size_t unused)
 {
 }

-- 
1.7.1

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH] trace.c: mark file-local function static
  2010-12-16 22:38 [PATCH] trace.c: mark file-local function static Vasyl'
@ 2010-12-16 23:43 ` Thiago Farina
  2010-12-20 12:00   ` Drew Northup
  0 siblings, 1 reply; 14+ messages in thread
From: Thiago Farina @ 2010-12-16 23:43 UTC (permalink / raw)
  To: Vasyl'; +Cc: git

On Thu, Dec 16, 2010 at 8:38 PM, Vasyl' <vvavrychuk@gmail.com> wrote:
> Signed-off-by: Vasyl' Vavrychuk <vvavrychuk@gmail.com>
> ---
>  trace.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/trace.c b/trace.c
> index 1e560cb..62586fa 100644
> --- a/trace.c
> +++ b/trace.c
> @@ -25,7 +25,7 @@
>  #include "cache.h"
>  #include "quote.h"
>
> -void do_nothing(size_t unused)
> +static void do_nothing(size_t unused)
>  {
>  }
>
If it means something, this looks sane to me.

Acked-by: Thiago Farina <tfransosi@gmail.com>

> --
> 1.7.1
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] trace.c: mark file-local function static
  2010-12-16 23:43 ` Thiago Farina
@ 2010-12-20 12:00   ` Drew Northup
  2010-12-20 15:17     ` Thiago Farina
  0 siblings, 1 reply; 14+ messages in thread
From: Drew Northup @ 2010-12-20 12:00 UTC (permalink / raw)
  To: Thiago Farina; +Cc: Vasyl', git


On Thu, 2010-12-16 at 21:43 -0200, Thiago Farina wrote:
> On Thu, Dec 16, 2010 at 8:38 PM, Vasyl' <vvavrychuk@gmail.com> wrote:
> > Signed-off-by: Vasyl' Vavrychuk <vvavrychuk@gmail.com>
> > ---
> >  trace.c |    2 +-
> >  1 files changed, 1 insertions(+), 1 deletions(-)
> >
> > diff --git a/trace.c b/trace.c
> > index 1e560cb..62586fa 100644
> > --- a/trace.c
> > +++ b/trace.c
> > @@ -25,7 +25,7 @@
> >  #include "cache.h"
> >  #include "quote.h"
> >
> > -void do_nothing(size_t unused)
> > +static void do_nothing(size_t unused)
> >  {
> >  }
> >
> If it means something, this looks sane to me.
> 
> Acked-by: Thiago Farina <tfransosi@gmail.com>

It may be sane, but why should we trust that it is without a commit
message?

-- 
-Drew Northup N1XIM
   AKA RvnPhnx on OPN
________________________________________________
"As opposed to vegetable or mineral error?"
-John Pescatore, SANS NewsBites Vol. 12 Num. 59

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] trace.c: mark file-local function static
  2010-12-20 12:00   ` Drew Northup
@ 2010-12-20 15:17     ` Thiago Farina
  2010-12-20 16:53       ` Drew Northup
  0 siblings, 1 reply; 14+ messages in thread
From: Thiago Farina @ 2010-12-20 15:17 UTC (permalink / raw)
  To: Drew Northup; +Cc: Vasyl', git

On Mon, Dec 20, 2010 at 10:00 AM, Drew Northup <drew.northup@maine.edu> wrote:
>
> On Thu, 2010-12-16 at 21:43 -0200, Thiago Farina wrote:
>> On Thu, Dec 16, 2010 at 8:38 PM, Vasyl' <vvavrychuk@gmail.com> wrote:
>> > Signed-off-by: Vasyl' Vavrychuk <vvavrychuk@gmail.com>
>> > ---
>> >  trace.c |    2 +-
>> >  1 files changed, 1 insertions(+), 1 deletions(-)
>> >
>> > diff --git a/trace.c b/trace.c
>> > index 1e560cb..62586fa 100644
>> > --- a/trace.c
>> > +++ b/trace.c
>> > @@ -25,7 +25,7 @@
>> >  #include "cache.h"
>> >  #include "quote.h"
>> >
>> > -void do_nothing(size_t unused)
>> > +static void do_nothing(size_t unused)
>> >  {
>> >  }
>> >
>> If it means something, this looks sane to me.
>>
>> Acked-by: Thiago Farina <tfransosi@gmail.com>
>
> It may be sane, but why should we trust that it is without a commit
> message?

Why such trivial thing needs further explanation?

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] trace.c: mark file-local function static
  2010-12-20 15:17     ` Thiago Farina
@ 2010-12-20 16:53       ` Drew Northup
  2010-12-21  0:28         ` Thiago Farina
  2010-12-21 14:52         ` Nguyen Thai Ngoc Duy
  0 siblings, 2 replies; 14+ messages in thread
From: Drew Northup @ 2010-12-20 16:53 UTC (permalink / raw)
  To: Thiago Farina; +Cc: Vasyl', git


On Mon, 2010-12-20 at 13:17 -0200, Thiago Farina wrote:
> On Mon, Dec 20, 2010 at 10:00 AM, Drew Northup <drew.northup@maine.edu> wrote:
> >
> > On Thu, 2010-12-16 at 21:43 -0200, Thiago Farina wrote:
> >> On Thu, Dec 16, 2010 at 8:38 PM, Vasyl' <vvavrychuk@gmail.com> wrote:
> >> > Signed-off-by: Vasyl' Vavrychuk <vvavrychuk@gmail.com>
> >> > ---
> >> >  trace.c |    2 +-
> >> >  1 files changed, 1 insertions(+), 1 deletions(-)
> >> >
> >> > diff --git a/trace.c b/trace.c
> >> > index 1e560cb..62586fa 100644
> >> > --- a/trace.c
> >> > +++ b/trace.c
> >> > @@ -25,7 +25,7 @@
> >> >  #include "cache.h"
> >> >  #include "quote.h"
> >> >
> >> > -void do_nothing(size_t unused)
> >> > +static void do_nothing(size_t unused)
> >> >  {
> >> >  }
> >> >
> >> If it means something, this looks sane to me.
> >>
> >> Acked-by: Thiago Farina <tfransosi@gmail.com>
> >
> > It may be sane, but why should we trust that it is without a commit
> > message?
> 
> Why such trivial thing needs further explanation?

Because even trivial fixes may break non-trivial things. 
In addition, without justification we'd just as soon have somebody come
back with another patch six months down the road that changes it back to
the original code. Now that wouldn't make a whole lot of sense, now
would it?
Alas the best way to avoid such a situation is to explain why a change
was made to begin with.

-- 
-Drew Northup N1XIM
   AKA RvnPhnx on OPN
________________________________________________
"As opposed to vegetable or mineral error?"
-John Pescatore, SANS NewsBites Vol. 12 Num. 59

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] trace.c: mark file-local function static
  2010-12-20 16:53       ` Drew Northup
@ 2010-12-21  0:28         ` Thiago Farina
  2010-12-21 12:29           ` Drew Northup
  2010-12-21 14:52         ` Nguyen Thai Ngoc Duy
  1 sibling, 1 reply; 14+ messages in thread
From: Thiago Farina @ 2010-12-21  0:28 UTC (permalink / raw)
  To: Drew Northup; +Cc: Vasyl', git

On Mon, Dec 20, 2010 at 2:53 PM, Drew Northup <drew.northup@maine.edu> wrote:
>
> On Mon, 2010-12-20 at 13:17 -0200, Thiago Farina wrote:
>> On Mon, Dec 20, 2010 at 10:00 AM, Drew Northup <drew.northup@maine.edu> wrote:
>> >
>> > On Thu, 2010-12-16 at 21:43 -0200, Thiago Farina wrote:
>> >> On Thu, Dec 16, 2010 at 8:38 PM, Vasyl' <vvavrychuk@gmail.com> wrote:
>> >> > Signed-off-by: Vasyl' Vavrychuk <vvavrychuk@gmail.com>
>> >> > ---
>> >> >  trace.c |    2 +-
>> >> >  1 files changed, 1 insertions(+), 1 deletions(-)
>> >> >
>> >> > diff --git a/trace.c b/trace.c
>> >> > index 1e560cb..62586fa 100644
>> >> > --- a/trace.c
>> >> > +++ b/trace.c
>> >> > @@ -25,7 +25,7 @@
>> >> >  #include "cache.h"
>> >> >  #include "quote.h"
>> >> >
>> >> > -void do_nothing(size_t unused)
>> >> > +static void do_nothing(size_t unused)
>> >> >  {
>> >> >  }
>> >> >
>> >> If it means something, this looks sane to me.
>> >>
>> >> Acked-by: Thiago Farina <tfransosi@gmail.com>
>> >
>> > It may be sane, but why should we trust that it is without a commit
>> > message?
>>
>> Why such trivial thing needs further explanation?
>
> Because even trivial fixes may break non-trivial things.
> In addition, without justification we'd just as soon have somebody come
> back with another patch six months down the road that changes it back to
> the original code. Now that wouldn't make a whole lot of sense, now
> would it?

I don't think so, it's making the function private, because the
function is used only in that file and as such if you see a function
marked as static you know that and doesn't need further explanation in
my pov (but it seems you don't think like that).

> Alas the best way to avoid such a situation is to explain why a change
> was made to begin with.
>

So, you are welcome to contribute and suggest such description for
this trivial (that may break non-trivial things) patch. So we can
please you and others in the future.


Thanks.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] trace.c: mark file-local function static
  2010-12-21  0:28         ` Thiago Farina
@ 2010-12-21 12:29           ` Drew Northup
  2010-12-21 15:59             ` Thiago Farina
  0 siblings, 1 reply; 14+ messages in thread
From: Drew Northup @ 2010-12-21 12:29 UTC (permalink / raw)
  To: Thiago Farina; +Cc: Vasyl', git


On Mon, 2010-12-20 at 22:28 -0200, Thiago Farina wrote:
> On Mon, Dec 20, 2010 at 2:53 PM, Drew Northup <drew.northup@maine.edu> wrote:
> >
> > On Mon, 2010-12-20 at 13:17 -0200, Thiago Farina wrote:
> >> On Mon, Dec 20, 2010 at 10:00 AM, Drew Northup <drew.northup@maine.edu> wrote:
> >> >
> >> > On Thu, 2010-12-16 at 21:43 -0200, Thiago Farina wrote:
> >> >> On Thu, Dec 16, 2010 at 8:38 PM, Vasyl' <vvavrychuk@gmail.com> wrote:
> >> >> > Signed-off-by: Vasyl' Vavrychuk <vvavrychuk@gmail.com>
> >> >> > ---
> >> >> >  trace.c |    2 +-
> >> >> >  1 files changed, 1 insertions(+), 1 deletions(-)
> >> >> >
> >> >> > diff --git a/trace.c b/trace.c
> >> >> > index 1e560cb..62586fa 100644
> >> >> > --- a/trace.c
> >> >> > +++ b/trace.c
> >> >> > @@ -25,7 +25,7 @@
> >> >> >  #include "cache.h"
> >> >> >  #include "quote.h"
> >> >> >
> >> >> > -void do_nothing(size_t unused)
> >> >> > +static void do_nothing(size_t unused)
> >> >> >  {
> >> >> >  }
> >> >> >
> >> >> If it means something, this looks sane to me.
> >> >>
> >> >> Acked-by: Thiago Farina <tfransosi@gmail.com>
> >> >
> >> > It may be sane, but why should we trust that it is without a commit
> >> > message?
> >>
> >> Why such trivial thing needs further explanation?
> >
> > Because even trivial fixes may break non-trivial things.
> > In addition, without justification we'd just as soon have somebody come
> > back with another patch six months down the road that changes it back to
> > the original code. Now that wouldn't make a whole lot of sense, now
> > would it?
> 
> I don't think so, it's making the function private, because the
> function is used only in that file and as such if you see a function
> marked as static you know that and doesn't need further explanation in
> my pov (but it seems you don't think like that).

All the patch above does is tell the compiler to enforce compilation of
that function as static. That is most definitely not the same thing as
making it private. (I think we can agree that it is being used as if it
were being enforced as private at some meta-level, but the compiler
isn't going to enforce it for us...) While I think the code change is
fairly clear, as I said earlier: without a commit message we don't have
a good reason for not making it non-static again later on, flip-flopping
ad-infinitum.

Commit messages for isolated changes such as this build up a story, if
you will, providing future contributors with insight as to why the group
made a change when it did--even when the change is minor (in fact often
most importantly when the change is minor)--by putting it in context.

> > Alas the best way to avoid such a situation is to explain why a change
> > was made to begin with.
> >
> 
> So, you are welcome to contribute and suggest such description for
> this trivial (that may break non-trivial things) patch. So we can
> please you and others in the future.

As I am complaining that I don't know what the submitter was thinking
that sounds particularly odd to me. How I am supposed to describe for
the group what the commit's author was thinking in a commit message that
I would like to see added to a patch when in fact the whole problem is
that I don't know specifically what he was thinking? "Changed function
to static for no known reason whatsoever" isn't much of a commit
message.

-- 
-Drew Northup N1XIM
   AKA RvnPhnx on OPN
________________________________________________
"As opposed to vegetable or mineral error?"
-John Pescatore, SANS NewsBites Vol. 12 Num. 59

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] trace.c: mark file-local function static
  2010-12-20 16:53       ` Drew Northup
  2010-12-21  0:28         ` Thiago Farina
@ 2010-12-21 14:52         ` Nguyen Thai Ngoc Duy
  2010-12-21 15:19           ` Drew Northup
  2010-12-21 17:24           ` Junio C Hamano
  1 sibling, 2 replies; 14+ messages in thread
From: Nguyen Thai Ngoc Duy @ 2010-12-21 14:52 UTC (permalink / raw)
  To: Drew Northup; +Cc: Thiago Farina, Vasyl', git

On Mon, Dec 20, 2010 at 11:53 PM, Drew Northup <drew.northup@maine.edu> wrote:
>> Why such trivial thing needs further explanation?
>
> Because even trivial fixes may break non-trivial things.

The only thing it could break is compilation.

> In addition, without justification we'd just as soon have somebody come
> back with another patch six months down the road that changes it back to
> the original code. Now that wouldn't make a whole lot of sense, now
> would it?

Yeah I would expect somebody reverting this patch _if_ this function
is useful outside trace.c again. On the other hand, this patch saves
do_nothing from global namespace so somewhere, some time, somebody can
use it.

This is pretty much a clean-up patch from my perspective. Do we really
need two paragraph explanation for marking a function static?
-- 
Duy

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] trace.c: mark file-local function static
  2010-12-21 14:52         ` Nguyen Thai Ngoc Duy
@ 2010-12-21 15:19           ` Drew Northup
  2010-12-21 17:24           ` Junio C Hamano
  1 sibling, 0 replies; 14+ messages in thread
From: Drew Northup @ 2010-12-21 15:19 UTC (permalink / raw)
  To: Nguyen Thai Ngoc Duy; +Cc: Thiago Farina, Vasyl', git


On Tue, 2010-12-21 at 21:52 +0700, Nguyen Thai Ngoc Duy wrote:
> On Mon, Dec 20, 2010 at 11:53 PM, Drew Northup <drew.northup@maine.edu> wrote:

> Yeah I would expect somebody reverting this patch _if_ this function
> is useful outside trace.c again. On the other hand, this patch saves
> do_nothing from global namespace so somewhere, some time, somebody can
> use it.
> 
> This is pretty much a clean-up patch from my perspective. Do we really
> need two paragraph explanation for marking a function static?

No, but 1 sentence would be dandy.

-- 
-Drew Northup N1XIM
   AKA RvnPhnx on OPN
________________________________________________
"As opposed to vegetable or mineral error?"
-John Pescatore, SANS NewsBites Vol. 12 Num. 59

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] trace.c: mark file-local function static
  2010-12-21 12:29           ` Drew Northup
@ 2010-12-21 15:59             ` Thiago Farina
  0 siblings, 0 replies; 14+ messages in thread
From: Thiago Farina @ 2010-12-21 15:59 UTC (permalink / raw)
  To: Drew Northup; +Cc: Vasyl', git

On Tue, Dec 21, 2010 at 10:29 AM, Drew Northup <drew.northup@maine.edu> wrote:
> While I think the code change is fairly clear, as I said earlier: without a commit message we don't have
> a good reason for not making it non-static again later on, flip-flopping
> ad-infinitum.
>

Why you are complain about a one word change at all? Are you the
maintainer? Are you going to make a change that uses do_nothing in
future? If for some reason someone needs to use this function in other
place, the problem is of this person not you, he you will have to
argue and defend his change for whatever reasons he has, and will be a
problem for the maintainer not for you.


> Commit messages for isolated changes such as this build up a story, if
> you will, providing future contributors with insight as to why the group
> made a change when it did--even when the change is minor (in fact often
> most importantly when the change is minor)--by putting it in context.
>
We all know that, and Junio is doing a good job enforcing GOOD commit
messages. But in this case this is STUPID in my pov (others can and
probably will disagree with me, but I don't care).

>> > Alas the best way to avoid such a situation is to explain why a change
>> > was made to begin with.
>> >
>>
>> So, you are welcome to contribute and suggest such description for
>> this trivial (that may break non-trivial things) patch. So we can
>> please you and others in the future.
>
> As I am complaining that I don't know what the submitter was thinking
> that sounds particularly odd to me. How I am supposed to describe for
> the group what the commit's author was thinking in a commit message that
> I would like to see added to a patch when in fact the whole problem is
> that I don't know specifically what he was thinking?

Well, what the hell we are talking about so? If you are arguing for a
commit message, I would expect that you would have a suggestion, at
least to show why you are so interested in this particular patch.

And many contributors here, besides suggesting BETTER commit messages,
they help others with how the patch could be written, and you are not
helping in either way.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] trace.c: mark file-local function static
  2010-12-21 14:52         ` Nguyen Thai Ngoc Duy
  2010-12-21 15:19           ` Drew Northup
@ 2010-12-21 17:24           ` Junio C Hamano
  2010-12-21 17:40             ` Thiago Farina
  2010-12-21 19:54             ` Johannes Sixt
  1 sibling, 2 replies; 14+ messages in thread
From: Junio C Hamano @ 2010-12-21 17:24 UTC (permalink / raw)
  To: Nguyen Thai Ngoc Duy, Johannes Sixt
  Cc: Drew Northup, Thiago Farina, Vasyl', git

Nguyen Thai Ngoc Duy <pclouds@gmail.com> writes:

> This is pretty much a clean-up patch from my perspective. Do we really
> need two paragraph explanation for marking a function static?

I've already applied it, but I think it is much better to do this instead
(on top of Vasyl' Vavrychuk's patch).

A more interesting topic is why the try-to-free-pack-memory logic needs to
be disabled in the first place.  3a09425 (Do not call release_pack_memory
in malloc wrappers when GIT_TRACE is used, 2010-05-08) explains that it is
to avoid a race on Windows, and it looks like a workaround not a solution
("can be called without locking"---"why aren't we locking then?").

Not that it matters in the context of "trace", which is a debugging
facility, that this is a workaround.

-- >8 --
Subject: set_try_to_free_routine(NULL) means "do nothing special"

This way, the next caller that wants to disable our memory reclamation
machinery does not have to define its own do_nothing() stub.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 trace.c   |    8 ++------
 wrapper.c |    2 ++
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/trace.c b/trace.c
index 62586fa..0fb2a2c 100644
--- a/trace.c
+++ b/trace.c
@@ -25,10 +25,6 @@
 #include "cache.h"
 #include "quote.h"
 
-static void do_nothing(size_t unused)
-{
-}
-
 /* Get a trace file descriptor from GIT_TRACE env variable. */
 static int get_trace_fd(int *need_close)
 {
@@ -76,7 +72,7 @@ void trace_printf(const char *fmt, ...)
 	if (!fd)
 		return;
 
-	set_try_to_free_routine(do_nothing);	/* is never reset */
+	set_try_to_free_routine(NULL);	/* is never reset */
 	strbuf_init(&buf, 64);
 	va_start(ap, fmt);
 	len = vsnprintf(buf.buf, strbuf_avail(&buf), fmt, ap);
@@ -108,7 +104,7 @@ void trace_argv_printf(const char **argv, const char *fmt, ...)
 	if (!fd)
 		return;
 
-	set_try_to_free_routine(do_nothing);	/* is never reset */
+	set_try_to_free_routine(NULL);	/* is never reset */
 	strbuf_init(&buf, 64);
 	va_start(ap, fmt);
 	len = vsnprintf(buf.buf, strbuf_avail(&buf), fmt, ap);
diff --git a/wrapper.c b/wrapper.c
index 4c1639f..8d7dd31 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -12,6 +12,8 @@ static void (*try_to_free_routine)(size_t size) = do_nothing;
 try_to_free_t set_try_to_free_routine(try_to_free_t routine)
 {
 	try_to_free_t old = try_to_free_routine;
+	if (!routine)
+		routine = do_nothing;
 	try_to_free_routine = routine;
 	return old;
 }

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH] trace.c: mark file-local function static
  2010-12-21 17:24           ` Junio C Hamano
@ 2010-12-21 17:40             ` Thiago Farina
  2010-12-21 17:50               ` Junio C Hamano
  2010-12-21 19:54             ` Johannes Sixt
  1 sibling, 1 reply; 14+ messages in thread
From: Thiago Farina @ 2010-12-21 17:40 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: Nguyen Thai Ngoc Duy, Johannes Sixt, Drew Northup, Vasyl',
	git

On Tue, Dec 21, 2010 at 3:24 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Nguyen Thai Ngoc Duy <pclouds@gmail.com> writes:
>
>> This is pretty much a clean-up patch from my perspective. Do we really
>> need two paragraph explanation for marking a function static?
>
> I've already applied it, but I think it is much better to do this instead
> (on top of Vasyl' Vavrychuk's patch).
>
> A more interesting topic is why the try-to-free-pack-memory logic needs to
> be disabled in the first place.  3a09425 (Do not call release_pack_memory
> in malloc wrappers when GIT_TRACE is used, 2010-05-08) explains that it is
> to avoid a race on Windows, and it looks like a workaround not a solution
> ("can be called without locking"---"why aren't we locking then?").
>
> Not that it matters in the context of "trace", which is a debugging
> facility, that this is a workaround.
>
> -- >8 --
> Subject: set_try_to_free_routine(NULL) means "do nothing special"
>
> This way, the next caller that wants to disable our memory reclamation
> machinery does not have to define its own do_nothing() stub.
>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
>  trace.c   |    8 ++------
>  wrapper.c |    2 ++
>  2 files changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/trace.c b/trace.c
> index 62586fa..0fb2a2c 100644
> --- a/trace.c
> +++ b/trace.c
> @@ -25,10 +25,6 @@
>  #include "cache.h"
>  #include "quote.h"
>
> -static void do_nothing(size_t unused)
> -{
> -}
> -
>  /* Get a trace file descriptor from GIT_TRACE env variable. */
>  static int get_trace_fd(int *need_close)
>  {
> @@ -76,7 +72,7 @@ void trace_printf(const char *fmt, ...)
>        if (!fd)
>                return;
>
> -       set_try_to_free_routine(do_nothing);    /* is never reset */
> +       set_try_to_free_routine(NULL);  /* is never reset */
>        strbuf_init(&buf, 64);
>        va_start(ap, fmt);
>        len = vsnprintf(buf.buf, strbuf_avail(&buf), fmt, ap);
> @@ -108,7 +104,7 @@ void trace_argv_printf(const char **argv, const char *fmt, ...)
>        if (!fd)
>                return;
>
> -       set_try_to_free_routine(do_nothing);    /* is never reset */
> +       set_try_to_free_routine(NULL);  /* is never reset */
>        strbuf_init(&buf, 64);
>        va_start(ap, fmt);
>        len = vsnprintf(buf.buf, strbuf_avail(&buf), fmt, ap);
> diff --git a/wrapper.c b/wrapper.c
> index 4c1639f..8d7dd31 100644
> --- a/wrapper.c
> +++ b/wrapper.c
> @@ -12,6 +12,8 @@ static void (*try_to_free_routine)(size_t size) = do_nothing;
>  try_to_free_t set_try_to_free_routine(try_to_free_t routine)
>  {
>        try_to_free_t old = try_to_free_routine;
> +       if (!routine)
> +               routine = do_nothing;

Maybe I'm missing something, or I'm confused (or I do not understand
what I'm reading), but how you are assign routine to do_nothing if you
have removed do_nothing above?

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] trace.c: mark file-local function static
  2010-12-21 17:40             ` Thiago Farina
@ 2010-12-21 17:50               ` Junio C Hamano
  0 siblings, 0 replies; 14+ messages in thread
From: Junio C Hamano @ 2010-12-21 17:50 UTC (permalink / raw)
  To: Thiago Farina
  Cc: Junio C Hamano, Nguyen Thai Ngoc Duy, Johannes Sixt, Drew Northup,
	Vasyl', git

Thiago Farina <tfransosi@gmail.com> writes:

> Maybe I'm missing something, or I'm confused (or I do not understand
> what I'm reading), but how you are assign routine to do_nothing if you
> have removed do_nothing above?

Apply the patch and read the first twenty lines of resulting wrapper.c

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] trace.c: mark file-local function static
  2010-12-21 17:24           ` Junio C Hamano
  2010-12-21 17:40             ` Thiago Farina
@ 2010-12-21 19:54             ` Johannes Sixt
  1 sibling, 0 replies; 14+ messages in thread
From: Johannes Sixt @ 2010-12-21 19:54 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: Nguyen Thai Ngoc Duy, Drew Northup, Thiago Farina, Vasyl',
	git

On Dienstag, 21. Dezember 2010, Junio C Hamano wrote:
> A more interesting topic is why the try-to-free-pack-memory logic needs to
> be disabled in the first place.  3a09425 (Do not call release_pack_memory
> in malloc wrappers when GIT_TRACE is used, 2010-05-08) explains that it is
> to avoid a race on Windows, and it looks like a workaround not a solution
> ("can be called without locking"---"why aren't we locking then?").
>
> Not that it matters in the context of "trace", which is a debugging
> facility, that this is a workaround.

Exactly. A clean implementation is not worth the effort for this debugging 
facility.

BTW, these days it is not just Windows that is affected because we use threads 
in start_async everywhere if possible.

-- Hannes

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2010-12-21 19:54 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-16 22:38 [PATCH] trace.c: mark file-local function static Vasyl'
2010-12-16 23:43 ` Thiago Farina
2010-12-20 12:00   ` Drew Northup
2010-12-20 15:17     ` Thiago Farina
2010-12-20 16:53       ` Drew Northup
2010-12-21  0:28         ` Thiago Farina
2010-12-21 12:29           ` Drew Northup
2010-12-21 15:59             ` Thiago Farina
2010-12-21 14:52         ` Nguyen Thai Ngoc Duy
2010-12-21 15:19           ` Drew Northup
2010-12-21 17:24           ` Junio C Hamano
2010-12-21 17:40             ` Thiago Farina
2010-12-21 17:50               ` Junio C Hamano
2010-12-21 19:54             ` Johannes Sixt

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).