git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] transport-helper: avoid dependency on thread-utils.h
@ 2010-12-10 11:48 Jonathan Nieder
  2010-12-10 18:21 ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Jonathan Nieder @ 2010-12-10 11:48 UTC (permalink / raw)
  To: git; +Cc: Ilari Liusvaara

Since the transport-helper does not use recursive mutexes or ask the
number of cores, it does not require any declarations from the
thread-utils lib.  Removing the unnecessary #include avoids false
positives from "make CHECK_HEADER_DEPENDENCIES=1".

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
The #include directive in question was added in 7851b1e60
(remote-fd/ext: finishing touches after code review, 2010-11-17),
at the same times as the necessary #include for <pthread.h>.
This patch seems to work for me, but I wouldn't be surprised if
to be missing something.

 transport-helper.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/transport-helper.c b/transport-helper.c
index 3a50856..7c99051 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -11,7 +11,6 @@
 
 #ifndef NO_PTHREADS
 #include <pthread.h>
-#include "thread-utils.h"
 #endif
 
 static int debug;
-- 
1.7.2.4

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

* Re: [PATCH] transport-helper: avoid dependency on thread-utils.h
  2010-12-10 11:48 [PATCH] transport-helper: avoid dependency on thread-utils.h Jonathan Nieder
@ 2010-12-10 18:21 ` Junio C Hamano
  2010-12-10 19:46   ` [PATCH 0/2] " Jonathan Nieder
  0 siblings, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2010-12-10 18:21 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: git, Ilari Liusvaara

Jonathan Nieder <jrnieder@gmail.com> writes:

> Since the transport-helper does not use recursive mutexes or ask the
> number of cores, it does not require any declarations from the
> thread-utils lib.  Removing the unnecessary #include avoids false
> positives from "make CHECK_HEADER_DEPENDENCIES=1".

Sorry, I was slow and took me some time to realize what is going on.

Isn't it more like "Makefile does not say transport-helper.o depends on
thread-utils.h, but transport-helper.c does include it"?  IOW, it not a
false positive; perhaps a real but an unnecessary positive.

> The #include directive in question was added in 7851b1e60
> (remote-fd/ext: finishing touches after code review, 2010-11-17),
> at the same times as the necessary #include for <pthread.h>.

I think the whole four-line block was cut & paste from other places that
use the threading, namely grep.c and pack-objects.c.

I wonder if it is better to do something like this instead.  This way, we
can later add more things that threaded part of the system would need to
thread-utils.h inside "ifndef NO_PTHREADS" and they will automatically get
included by all the threaders.


 builtin/grep.c         |    4 ----
 builtin/pack-objects.c |    4 ----
 thread-utils.h         |    4 ++++
 transport-helper.c     |    4 ----
 4 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/builtin/grep.c b/builtin/grep.c
index adb5424..fdf7131 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -17,11 +17,7 @@
 #include "grep.h"
 #include "quote.h"
 #include "dir.h"
-
-#ifndef NO_PTHREADS
-#include <pthread.h>
 #include "thread-utils.h"
-#endif
 
 static char const * const grep_usage[] = {
 	"git grep [options] [-e] <pattern> [<rev>...] [[--] <path>...]",
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index f027b3a..b0503b2 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -16,11 +16,7 @@
 #include "list-objects.h"
 #include "progress.h"
 #include "refs.h"
-
-#ifndef NO_PTHREADS
-#include <pthread.h>
 #include "thread-utils.h"
-#endif
 
 static const char pack_usage[] =
   "git pack-objects [ -q | --progress | --all-progress ]\n"
diff --git a/thread-utils.h b/thread-utils.h
index 1727a03..6fb98c3 100644
--- a/thread-utils.h
+++ b/thread-utils.h
@@ -1,7 +1,11 @@
 #ifndef THREAD_COMPAT_H
 #define THREAD_COMPAT_H
 
+#ifndef NO_PTHREADS
+#include <pthread.h>
+
 extern int online_cpus(void);
 extern int init_recursive_mutex(pthread_mutex_t*);
 
+#endif
 #endif /* THREAD_COMPAT_H */
diff --git a/transport-helper.c b/transport-helper.c
index 3a50856..4e4754c 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -8,11 +8,7 @@
 #include "quote.h"
 #include "remote.h"
 #include "string-list.h"
-
-#ifndef NO_PTHREADS
-#include <pthread.h>
 #include "thread-utils.h"
-#endif
 
 static int debug;
 

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

* [PATCH 0/2] Re: transport-helper: avoid dependency on thread-utils.h
  2010-12-10 18:21 ` Junio C Hamano
@ 2010-12-10 19:46   ` Jonathan Nieder
  2010-12-10 19:47     ` [PATCH 1/2] simplify inclusion of pthread.h Jonathan Nieder
  2010-12-10 19:48     ` [PATCH 2/2] Makefile: transport-helper uses thread-utils.h Jonathan Nieder
  0 siblings, 2 replies; 6+ messages in thread
From: Jonathan Nieder @ 2010-12-10 19:46 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Ilari Liusvaara

Junio C Hamano wrote:

> I wonder if it is better to do something like this instead.

Yes, I think so.  How about this?

Jonathan Nieder (1):
  Makefile: transport-helper uses thread-utils.h

Junio C Hamano (1):
  simplify inclusion of pthread.h

 Makefile               |    3 +--
 builtin/grep.c         |    4 ----
 builtin/pack-objects.c |    4 ----
 thread-utils.h         |    4 ++++
 transport-helper.c     |    4 ----
 5 files changed, 5 insertions(+), 14 deletions(-)

-- 
1.7.2.4

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

* [PATCH 1/2] simplify inclusion of pthread.h
  2010-12-10 19:46   ` [PATCH 0/2] " Jonathan Nieder
@ 2010-12-10 19:47     ` Jonathan Nieder
  2010-12-10 19:51       ` Jonathan Nieder
  2010-12-10 19:48     ` [PATCH 2/2] Makefile: transport-helper uses thread-utils.h Jonathan Nieder
  1 sibling, 1 reply; 6+ messages in thread
From: Jonathan Nieder @ 2010-12-10 19:47 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Ilari Liusvaara

In v1.7.1.1~56^2 (Thread-safe xmalloc and xrealloc needs a recursive
mutex, 2010-04-08), the thread-utils header started using
pthread_mutex_t, so callers, which generally had been using

	#ifndef NO_PTHREADS
	#include "thread-utils.h"
	#include <pthread.h>
	#endif

before, were changed to include <pthread.h> first.  It is simpler to
let thread-utils.h take care of the whole matter.  This way, we can
later add more things that the threaded part of the system would need
to thread-utils.h inside "ifndef NO_PTHREADS" and they will
automatically get included by all headers.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
 builtin/grep.c         |    4 ----
 builtin/pack-objects.c |    4 ----
 thread-utils.h         |    4 ++++
 transport-helper.c     |    4 ----
 4 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/builtin/grep.c b/builtin/grep.c
index adb5424..fdf7131 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -17,11 +17,7 @@
 #include "grep.h"
 #include "quote.h"
 #include "dir.h"
-
-#ifndef NO_PTHREADS
-#include <pthread.h>
 #include "thread-utils.h"
-#endif
 
 static char const * const grep_usage[] = {
 	"git grep [options] [-e] <pattern> [<rev>...] [[--] <path>...]",
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index f027b3a..b0503b2 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -16,11 +16,7 @@
 #include "list-objects.h"
 #include "progress.h"
 #include "refs.h"
-
-#ifndef NO_PTHREADS
-#include <pthread.h>
 #include "thread-utils.h"
-#endif
 
 static const char pack_usage[] =
   "git pack-objects [ -q | --progress | --all-progress ]\n"
diff --git a/thread-utils.h b/thread-utils.h
index 1727a03..6fb98c3 100644
--- a/thread-utils.h
+++ b/thread-utils.h
@@ -1,7 +1,11 @@
 #ifndef THREAD_COMPAT_H
 #define THREAD_COMPAT_H
 
+#ifndef NO_PTHREADS
+#include <pthread.h>
+
 extern int online_cpus(void);
 extern int init_recursive_mutex(pthread_mutex_t*);
 
+#endif
 #endif /* THREAD_COMPAT_H */
diff --git a/transport-helper.c b/transport-helper.c
index 3a50856..4e4754c 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -8,11 +8,7 @@
 #include "quote.h"
 #include "remote.h"
 #include "string-list.h"
-
-#ifndef NO_PTHREADS
-#include <pthread.h>
 #include "thread-utils.h"
-#endif
 
 static int debug;
 
-- 
1.7.2.4

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

* [PATCH 2/2] Makefile: transport-helper uses thread-utils.h
  2010-12-10 19:46   ` [PATCH 0/2] " Jonathan Nieder
  2010-12-10 19:47     ` [PATCH 1/2] simplify inclusion of pthread.h Jonathan Nieder
@ 2010-12-10 19:48     ` Jonathan Nieder
  1 sibling, 0 replies; 6+ messages in thread
From: Jonathan Nieder @ 2010-12-10 19:48 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Ilari Liusvaara

transport-helper.o gained a dependency on thread-utils.h in
7851b1e (remote-fd/ext: finishing touches after code review,
2010-11-17).

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
 Makefile |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 1fe1a3b..41ab490 100644
--- a/Makefile
+++ b/Makefile
@@ -1937,13 +1937,12 @@ builtin/branch.o builtin/checkout.o builtin/clone.o builtin/reset.o branch.o tra
 builtin/bundle.o bundle.o transport.o: bundle.h
 builtin/bisect--helper.o builtin/rev-list.o bisect.o: bisect.h
 builtin/clone.o builtin/fetch-pack.o transport.o: fetch-pack.h
-builtin/grep.o: thread-utils.h
+builtin/grep.o builtin/pack-objects.o transport-helper.o: thread-utils.h
 builtin/send-pack.o transport.o: send-pack.h
 builtin/log.o builtin/shortlog.o: shortlog.h
 builtin/prune.o builtin/reflog.o reachable.o: reachable.h
 builtin/commit.o builtin/revert.o wt-status.o: wt-status.h
 builtin/tar-tree.o archive-tar.o: tar.h
-builtin/pack-objects.o: thread-utils.h
 connect.o transport.o http-backend.o: url.h
 http-fetch.o http-walker.o remote-curl.o transport.o walker.o: walker.h
 http.o http-walker.o http-push.o http-fetch.o remote-curl.o: http.h
-- 
1.7.2.4

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

* Re: [PATCH 1/2] simplify inclusion of pthread.h
  2010-12-10 19:47     ` [PATCH 1/2] simplify inclusion of pthread.h Jonathan Nieder
@ 2010-12-10 19:51       ` Jonathan Nieder
  0 siblings, 0 replies; 6+ messages in thread
From: Jonathan Nieder @ 2010-12-10 19:51 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Ilari Liusvaara

Jonathan Nieder wrote:

> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>

This one is of course

	From: Junio C Hamano <gitster@pobox.com>

Often enough I remind myself to include the pseudo-header but when the
rapid cutting-and-pasting time comes it is easy to forget. :/

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

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

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-10 11:48 [PATCH] transport-helper: avoid dependency on thread-utils.h Jonathan Nieder
2010-12-10 18:21 ` Junio C Hamano
2010-12-10 19:46   ` [PATCH 0/2] " Jonathan Nieder
2010-12-10 19:47     ` [PATCH 1/2] simplify inclusion of pthread.h Jonathan Nieder
2010-12-10 19:51       ` Jonathan Nieder
2010-12-10 19:48     ` [PATCH 2/2] Makefile: transport-helper uses thread-utils.h Jonathan Nieder

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).