git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Include headers for getrlimit() in sha1_file.c
@ 2011-03-16 10:37 Stefan Sperling
  2011-03-18 20:23 ` Jonathan Nieder
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Sperling @ 2011-03-16 10:37 UTC (permalink / raw)
  To: git; +Cc: Stefan Sperling

Fixes compilation error on OpenBSD:
sha1_file.c: In function 'open_packed_git_1':
sha1_file.c:718: error: storage size of 'lim' isn't known
sha1_file.c:721: warning: implicit declaration of function 'getrlimit'
sha1_file.c:721: error: 'RLIMIT_NOFILE' undeclared (first use in this function)
sha1_file.c:718: warning: unused variable 'lim'

Signed-off-by: Stefan Sperling <stsp@stsp.name>
---
 sha1_file.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/sha1_file.c b/sha1_file.c
index b4fcca8..f969b10 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -18,6 +18,10 @@
 #include "pack-revindex.h"
 #include "sha1-lookup.h"
 
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+
 #ifndef O_NOATIME
 #if defined(__linux__) && (defined(__i386__) || defined(__PPC__))
 #define O_NOATIME 01000000
-- 
1.7.3.5

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

* Re: [PATCH] Include headers for getrlimit() in sha1_file.c
  2011-03-16 10:37 [PATCH] Include headers for getrlimit() in sha1_file.c Stefan Sperling
@ 2011-03-18 20:23 ` Jonathan Nieder
  2011-03-19  0:22   ` Arnaud Lacombe
                     ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Jonathan Nieder @ 2011-03-18 20:23 UTC (permalink / raw)
  To: Stefan Sperling; +Cc: git, Shawn O. Pearce, Erik Faye-Lund

(+cc: Shawn, Erik)
Hi Stefan,

Stefan Sperling wrote:

> Fixes compilation error on OpenBSD:
> sha1_file.c: In function 'open_packed_git_1':
> sha1_file.c:718: error: storage size of 'lim' isn't known
> sha1_file.c:721: warning: implicit declaration of function 'getrlimit'
> sha1_file.c:721: error: 'RLIMIT_NOFILE' undeclared (first use in this function)
> sha1_file.c:718: warning: unused variable 'lim'

Good catch.

> --- a/sha1_file.c
> +++ b/sha1_file.c
> @@ -18,6 +18,10 @@
>  #include "pack-revindex.h"
>  #include "sha1-lookup.h"
>  
> +#include <sys/types.h>
> +#include <sys/time.h>
> +#include <sys/resource.h>

System headers like this tend to go in git-compat-util.h, so
portability fixes having to do with compatibility replacements or
order of inclusion only need to happen in one place.

In this case, afaict sys/resource.h is not available on mingw, meaning
the #include would probably go in the "#ifndef __MINGW32__" block.
Maybe something like this (untested)?

-- 8< --
Subject: compat: add missing #include <sys/resource.h>

Starting with commit c793430 (Limit file descriptors used by packs,
2011-02-28), git uses getrlimit to tell how many file descriptors it
can use.  Unfortunately it does not include the header declaring that
function, resulting in compilation errors on OpenBSD:

 sha1_file.c: In function 'open_packed_git_1':
 sha1_file.c:718: error: storage size of 'lim' isn't known
 sha1_file.c:721: warning: implicit declaration of function 'getrlimit'
 sha1_file.c:721: error: 'RLIMIT_NOFILE' undeclared (first use in this function)
 sha1_file.c:718: warning: unused variable 'lim'

The standard header to include for this is <sys/resource.h> (which on
some systems itself requires declarations from <sys/types.h> or
<sys/time.h>).  Probably the problem was missed until now because in
current glibc sys/resource.h happens to be included by sys/wait.h.

MinGW does not provide sys/resource.h (and compat/mingw takes care of
providing getrlimit some other way), so add the missing #include to
the "#ifndef __MINGW32__" block in git-compat-util.h.

Reported-by: Stefan Sperling <stsp@stsp.name>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
 git-compat-util.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/git-compat-util.h b/git-compat-util.h
index 49b50ee..40498b3 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -118,6 +118,7 @@
 #endif
 #ifndef __MINGW32__
 #include <sys/wait.h>
+#include <sys/resource.h>
 #include <sys/socket.h>
 #include <sys/ioctl.h>
 #include <termios.h>
-- 
1.7.4.1

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

* Re: [PATCH] Include headers for getrlimit() in sha1_file.c
  2011-03-18 20:23 ` Jonathan Nieder
@ 2011-03-19  0:22   ` Arnaud Lacombe
  2011-03-19  9:09   ` Stefan Sperling
  2011-03-31 22:59   ` [PATCH maint resend] compat: add missing #include <sys/resource.h> Jonathan Nieder
  2 siblings, 0 replies; 7+ messages in thread
From: Arnaud Lacombe @ 2011-03-19  0:22 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: Stefan Sperling, git, Shawn O. Pearce, Erik Faye-Lund

Hi,

On Fri, Mar 18, 2011 at 4:23 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:
> (+cc: Shawn, Erik)
> Hi Stefan,
>
> Stefan Sperling wrote:
>
>> Fixes compilation error on OpenBSD:
>> sha1_file.c: In function 'open_packed_git_1':
>> sha1_file.c:718: error: storage size of 'lim' isn't known
>> sha1_file.c:721: warning: implicit declaration of function 'getrlimit'
>> sha1_file.c:721: error: 'RLIMIT_NOFILE' undeclared (first use in this function)
>> sha1_file.c:718: warning: unused variable 'lim'
>
This also fix the build on FreeBSD 8 (did not test other version).

 - Arnaud

> Good catch.
>
>> --- a/sha1_file.c
>> +++ b/sha1_file.c
>> @@ -18,6 +18,10 @@
>>  #include "pack-revindex.h"
>>  #include "sha1-lookup.h"
>>
>> +#include <sys/types.h>
>> +#include <sys/time.h>
>> +#include <sys/resource.h>
>
> System headers like this tend to go in git-compat-util.h, so
> portability fixes having to do with compatibility replacements or
> order of inclusion only need to happen in one place.
>
> In this case, afaict sys/resource.h is not available on mingw, meaning
> the #include would probably go in the "#ifndef __MINGW32__" block.
> Maybe something like this (untested)?
>
> -- 8< --
> Subject: compat: add missing #include <sys/resource.h>
>
> Starting with commit c793430 (Limit file descriptors used by packs,
> 2011-02-28), git uses getrlimit to tell how many file descriptors it
> can use.  Unfortunately it does not include the header declaring that
> function, resulting in compilation errors on OpenBSD:
>
>  sha1_file.c: In function 'open_packed_git_1':
>  sha1_file.c:718: error: storage size of 'lim' isn't known
>  sha1_file.c:721: warning: implicit declaration of function 'getrlimit'
>  sha1_file.c:721: error: 'RLIMIT_NOFILE' undeclared (first use in this function)
>  sha1_file.c:718: warning: unused variable 'lim'
>
> The standard header to include for this is <sys/resource.h> (which on
> some systems itself requires declarations from <sys/types.h> or
> <sys/time.h>).  Probably the problem was missed until now because in
> current glibc sys/resource.h happens to be included by sys/wait.h.
>
> MinGW does not provide sys/resource.h (and compat/mingw takes care of
> providing getrlimit some other way), so add the missing #include to
> the "#ifndef __MINGW32__" block in git-compat-util.h.
>
> Reported-by: Stefan Sperling <stsp@stsp.name>
> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
> ---
>  git-compat-util.h |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/git-compat-util.h b/git-compat-util.h
> index 49b50ee..40498b3 100644
> --- a/git-compat-util.h
> +++ b/git-compat-util.h
> @@ -118,6 +118,7 @@
>  #endif
>  #ifndef __MINGW32__
>  #include <sys/wait.h>
> +#include <sys/resource.h>
>  #include <sys/socket.h>
>  #include <sys/ioctl.h>
>  #include <termios.h>
> --
> 1.7.4.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] 7+ messages in thread

* Re: [PATCH] Include headers for getrlimit() in sha1_file.c
  2011-03-18 20:23 ` Jonathan Nieder
  2011-03-19  0:22   ` Arnaud Lacombe
@ 2011-03-19  9:09   ` Stefan Sperling
  2011-03-31 22:59   ` [PATCH maint resend] compat: add missing #include <sys/resource.h> Jonathan Nieder
  2 siblings, 0 replies; 7+ messages in thread
From: Stefan Sperling @ 2011-03-19  9:09 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: git, Shawn O. Pearce, Erik Faye-Lund

On Fri, Mar 18, 2011 at 03:23:52PM -0500, Jonathan Nieder wrote:
> diff --git a/git-compat-util.h b/git-compat-util.h
> index 49b50ee..40498b3 100644
> --- a/git-compat-util.h
> +++ b/git-compat-util.h
> @@ -118,6 +118,7 @@
>  #endif
>  #ifndef __MINGW32__
>  #include <sys/wait.h>
> +#include <sys/resource.h>
>  #include <sys/socket.h>
>  #include <sys/ioctl.h>
>  #include <termios.h>

Works for me. Thanks.

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

* [PATCH maint resend] compat: add missing #include <sys/resource.h>
  2011-03-18 20:23 ` Jonathan Nieder
  2011-03-19  0:22   ` Arnaud Lacombe
  2011-03-19  9:09   ` Stefan Sperling
@ 2011-03-31 22:59   ` Jonathan Nieder
  2011-04-03 19:13     ` Jonathan Nieder
  2 siblings, 1 reply; 7+ messages in thread
From: Jonathan Nieder @ 2011-03-31 22:59 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: git, Shawn O. Pearce, Erik Faye-Lund, Stefan Sperling,
	Arnaud Lacombe

Date: Fri, 18 Mar 2011 15:23:52 -0500

Starting with commit c793430 (Limit file descriptors used by packs,
2011-02-28), git uses getrlimit to tell how many file descriptors it
can use.  Unfortunately it does not include the header declaring that
function, resulting in compilation errors:

 sha1_file.c: In function 'open_packed_git_1':
 sha1_file.c:718: error: storage size of 'lim' isn't known
 sha1_file.c:721: warning: implicit declaration of function 'getrlimit'
 sha1_file.c:721: error: 'RLIMIT_NOFILE' undeclared (first use in this function)
 sha1_file.c:718: warning: unused variable 'lim'

The standard header to include for this is <sys/resource.h> (which on
some systems itself requires declarations from <sys/types.h> or
<sys/time.h>).  Probably the problem was missed until now because in
current glibc sys/resource.h happens to be included by sys/wait.h.

MinGW does not provide sys/resource.h (and compat/mingw takes care of
providing getrlimit some other way), so add the missing #include to
the "#ifndef __MINGW32__" block in git-compat-util.h.

Reported-by: Stefan Sperling <stsp@stsp.name>
Tested-by: Stefan Sperling <stsp@stsp.name> [on OpenBSD]
Tested-by: Arnaud Lacombe <lacombar@gmail.com> [on FreeBSD 8]
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Oops, should have sent this as its own message before.  Thanks to
doug on irc for a ping.

 git-compat-util.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/git-compat-util.h b/git-compat-util.h
index bf947b1..79b5122 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -118,6 +118,7 @@
 #endif
 #ifndef __MINGW32__
 #include <sys/wait.h>
+#include <sys/resource.h>
 #include <sys/socket.h>
 #include <sys/ioctl.h>
 #include <termios.h>
-- 
1.7.4.2

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

* Re: [PATCH maint resend] compat: add missing #include <sys/resource.h>
  2011-03-31 22:59   ` [PATCH maint resend] compat: add missing #include <sys/resource.h> Jonathan Nieder
@ 2011-04-03 19:13     ` Jonathan Nieder
  2011-04-03 19:27       ` Junio C Hamano
  0 siblings, 1 reply; 7+ messages in thread
From: Jonathan Nieder @ 2011-04-03 19:13 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: git, Shawn O. Pearce, Erik Faye-Lund, Stefan Sperling,
	Arnaud Lacombe

Hi Junio,

Jonathan Nieder wrote:

> Date: Fri, 18 Mar 2011 15:23:52 -0500
[...]
>  sha1_file.c:721: error: 'RLIMIT_NOFILE' undeclared (first use in this function)
[...]
> Reported-by: Stefan Sperling <stsp@stsp.name>
> Tested-by: Stefan Sperling <stsp@stsp.name> [on OpenBSD]
> Tested-by: Arnaud Lacombe <lacombar@gmail.com> [on FreeBSD 8]
> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>

Ping?  Would you like a shorter commit message, or was this just lost
in the noise?

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

* Re: [PATCH maint resend] compat: add missing #include <sys/resource.h>
  2011-04-03 19:13     ` Jonathan Nieder
@ 2011-04-03 19:27       ` Junio C Hamano
  0 siblings, 0 replies; 7+ messages in thread
From: Junio C Hamano @ 2011-04-03 19:27 UTC (permalink / raw)
  To: Jonathan Nieder
  Cc: Junio C Hamano, git, Shawn O. Pearce, Erik Faye-Lund,
	Stefan Sperling, Arnaud Lacombe

Jonathan Nieder <jrnieder@gmail.com> writes:

> Ping?  Would you like a shorter commit message, or was this just lost
> in the noise?

No, it was sitting in my to-be-applied box.  Thanks.

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

end of thread, other threads:[~2011-04-03 19:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-16 10:37 [PATCH] Include headers for getrlimit() in sha1_file.c Stefan Sperling
2011-03-18 20:23 ` Jonathan Nieder
2011-03-19  0:22   ` Arnaud Lacombe
2011-03-19  9:09   ` Stefan Sperling
2011-03-31 22:59   ` [PATCH maint resend] compat: add missing #include <sys/resource.h> Jonathan Nieder
2011-04-03 19:13     ` Jonathan Nieder
2011-04-03 19:27       ` Junio C Hamano

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