* [PATCH 2/6] path: Make the 'get_st_mode_bits' symbol a file static
@ 2013-04-27 18:42 Ramsay Jones
2013-04-28 2:26 ` Eric Sunshine
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Ramsay Jones @ 2013-04-27 18:42 UTC (permalink / raw)
To: Junio C Hamano; +Cc: tboegi, GIT Mailing-list
On MinGW, sparse issues an "'get_st_mode_bits' not declared. Should
it be static?" warning. The MinGW and MSVC builds do not see the
declaration of this function, within git-compat-util.h, due to it's
placement within an preprocessor conditional. (So, one solution would
be to simply move the declaration to the top level of the header.)
In order to suppress the warning, since this symbol does not need
more than file visibility, we simply remove the declaration from
the header and add the static modifier to the function definition.
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
---
git-compat-util.h | 1 -
path.c | 2 +-
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/git-compat-util.h b/git-compat-util.h
index e955bb5..3a990b3 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -163,7 +163,6 @@
typedef long intptr_t;
typedef unsigned long uintptr_t;
#endif
-int get_st_mode_bits(const char *path, int *mode);
#if defined(__CYGWIN__)
#undef _XOPEN_SOURCE
#include <grp.h>
diff --git a/path.c b/path.c
index 04ff148..cc2e9ac 100644
--- a/path.c
+++ b/path.c
@@ -11,7 +11,7 @@
* may return wrong permission bits. Most of the time we do not care,
* but the callsites of this wrapper do care.
*/
-int get_st_mode_bits(const char *path, int *mode)
+static int get_st_mode_bits(const char *path, int *mode)
{
struct stat st;
if (lstat(path, &st) < 0)
--
1.8.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 2/6] path: Make the 'get_st_mode_bits' symbol a file static
2013-04-27 18:42 [PATCH 2/6] path: Make the 'get_st_mode_bits' symbol a file static Ramsay Jones
@ 2013-04-28 2:26 ` Eric Sunshine
2013-04-28 6:02 ` Torsten Bögershausen
2013-04-28 19:06 ` Junio C Hamano
2 siblings, 0 replies; 8+ messages in thread
From: Eric Sunshine @ 2013-04-28 2:26 UTC (permalink / raw)
To: Ramsay Jones; +Cc: Junio C Hamano, Torsten Bögershausen, GIT Mailing-list
On Sat, Apr 27, 2013 at 2:42 PM, Ramsay Jones
<ramsay@ramsay1.demon.co.uk> wrote:
>
> On MinGW, sparse issues an "'get_st_mode_bits' not declared. Should
> it be static?" warning. The MinGW and MSVC builds do not see the
> declaration of this function, within git-compat-util.h, due to it's
s/it's/its/
> placement within an preprocessor conditional. (So, one solution would
> be to simply move the declaration to the top level of the header.)
>
> In order to suppress the warning, since this symbol does not need
> more than file visibility, we simply remove the declaration from
> the header and add the static modifier to the function definition.
>
> Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/6] path: Make the 'get_st_mode_bits' symbol a file static
2013-04-27 18:42 [PATCH 2/6] path: Make the 'get_st_mode_bits' symbol a file static Ramsay Jones
2013-04-28 2:26 ` Eric Sunshine
@ 2013-04-28 6:02 ` Torsten Bögershausen
2013-04-28 11:32 ` Torsten Bögershausen
2013-04-29 21:57 ` Ramsay Jones
2013-04-28 19:06 ` Junio C Hamano
2 siblings, 2 replies; 8+ messages in thread
From: Torsten Bögershausen @ 2013-04-28 6:02 UTC (permalink / raw)
To: Ramsay Jones; +Cc: Junio C Hamano, tboegi, GIT Mailing-list
On 2013-04-27 20.42, Ramsay Jones wrote:
>
> On MinGW, sparse issues an "'get_st_mode_bits' not declared. Should
> it be static?" warning. The MinGW and MSVC builds do not see the
> declaration of this function, within git-compat-util.h, due to it's
> placement within an preprocessor conditional. (So, one solution would
> be to simply move the declaration to the top level of the header.)
>
> In order to suppress the warning, since this symbol does not need
> more than file visibility, we simply remove the declaration from
> the header and add the static modifier to the function definition.
>
> Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
> ---
> git-compat-util.h | 1 -
> path.c | 2 +-
> 2 files changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/git-compat-util.h b/git-compat-util.h
> index e955bb5..3a990b3 100644
> --- a/git-compat-util.h
> +++ b/git-compat-util.h
> @@ -163,7 +163,6 @@
> typedef long intptr_t;
> typedef unsigned long uintptr_t;
> #endif
> -int get_st_mode_bits(const char *path, int *mode);
> #if defined(__CYGWIN__)
> #undef _XOPEN_SOURCE
> #include <grp.h>
> diff --git a/path.c b/path.c
> index 04ff148..cc2e9ac 100644
> --- a/path.c
> +++ b/path.c
> @@ -11,7 +11,7 @@
> * may return wrong permission bits. Most of the time we do not care,
> * but the callsites of this wrapper do care.
> */
> -int get_st_mode_bits(const char *path, int *mode)
> +static int get_st_mode_bits(const char *path, int *mode)
> {
> struct stat st;
> if (lstat(path, &st) < 0)
>
Sorry for breaking the MiNGW/MSVC builds.
It seams that the get_st_mode_bits is badly placed.
It should be in git compat-util.h, so that both compat/cygwin.c and path.c can see it.
So from my understanding, it should be placed here:
(I will send an official patch later)
/Torsten
diff -C 3 git-compat-util.h.~9526aa461f6c6900cb892a6fe248150ad436c0d~ git-compat-util.h.new
*** git-compat-util.h.~9526aa461f6c6900cb892a6fe248150ad436c0d~ 2013-04-28 07:53:28.000000000 +0200
--- git-compat-util.h.new 2013-04-28 07:53:58.000000000 +0200
***************
*** 127,132 ****
--- 127,133 ----
#else
#include <poll.h>
#endif
+ int get_st_mode_bits(const char *path, int *mode);
#if defined(__MINGW32__)
/* pull in Windows compatibility stuff */
#include "compat/mingw.h"
***************
*** 163,169 ****
typedef long intptr_t;
typedef unsigned long uintptr_t;
#endif
- int get_st_mode_bits(const char *path, int *mode);
#if defined(__CYGWIN__)
#undef _XOPEN_SOURCE
#include <grp.h>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/6] path: Make the 'get_st_mode_bits' symbol a file static
2013-04-28 6:02 ` Torsten Bögershausen
@ 2013-04-28 11:32 ` Torsten Bögershausen
2013-04-29 21:57 ` Ramsay Jones
1 sibling, 0 replies; 8+ messages in thread
From: Torsten Bögershausen @ 2013-04-28 11:32 UTC (permalink / raw)
To: Torsten Bögershausen; +Cc: Ramsay Jones, Junio C Hamano, GIT Mailing-list
On 2013-04-28 08.02, Torsten Bögershausen wrote:
> On 2013-04-27 20.42, Ramsay Jones wrote:
>>
>> On MinGW, sparse issues an "'get_st_mode_bits' not declared. Should
>> it be static?" warning. The MinGW and MSVC builds do not see the
>> declaration of this function, within git-compat-util.h, due to it's
>> placement within an preprocessor conditional. (So, one solution would
>> be to simply move the declaration to the top level of the header.)
>>
>> In order to suppress the warning, since this symbol does not need
>> more than file visibility, we simply remove the declaration from
>> the header and add the static modifier to the function definition.
>>
>> Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
>> ---
>> git-compat-util.h | 1 -
>> path.c | 2 +-
>> 2 files changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/git-compat-util.h b/git-compat-util.h
>> index e955bb5..3a990b3 100644
>> --- a/git-compat-util.h
>> +++ b/git-compat-util.h
>> @@ -163,7 +163,6 @@
>> typedef long intptr_t;
>> typedef unsigned long uintptr_t;
>> #endif
>> -int get_st_mode_bits(const char *path, int *mode);
>> #if defined(__CYGWIN__)
>> #undef _XOPEN_SOURCE
>> #include <grp.h>
>> diff --git a/path.c b/path.c
>> index 04ff148..cc2e9ac 100644
>> --- a/path.c
>> +++ b/path.c
>> @@ -11,7 +11,7 @@
>> * may return wrong permission bits. Most of the time we do not care,
>> * but the callsites of this wrapper do care.
>> */
>> -int get_st_mode_bits(const char *path, int *mode)
>> +static int get_st_mode_bits(const char *path, int *mode)
>> {
>> struct stat st;
>> if (lstat(path, &st) < 0)
>>
> Sorry for breaking the MiNGW/MSVC builds.
> It seams that the get_st_mode_bits is badly placed.
>
> It should be in git compat-util.h, so that both compat/cygwin.c and path.c can see it.
> So from my understanding, it should be placed here:
> (I will send an official patch later)
> /Torsten
>
>
> diff -C 3 git-compat-util.h.~9526aa461f6c6900cb892a6fe248150ad436c0d~ git-compat-util.h.new
> *** git-compat-util.h.~9526aa461f6c6900cb892a6fe248150ad436c0d~ 2013-04-28 07:53:28.000000000 +0200
> --- git-compat-util.h.new 2013-04-28 07:53:58.000000000 +0200
> ***************
> *** 127,132 ****
> --- 127,133 ----
> #else
> #include <poll.h>
> #endif
> + int get_st_mode_bits(const char *path, int *mode);
> #if defined(__MINGW32__)
> /* pull in Windows compatibility stuff */
> #include "compat/mingw.h"
> ***************
> *** 163,169 ****
> typedef long intptr_t;
> typedef unsigned long uintptr_t;
> #endif
> - int get_st_mode_bits(const char *path, int *mode);
> #if defined(__CYGWIN__)
> #undef _XOPEN_SOURCE
> #include <grp.h>
I probably change my mind:
Declaring get_st_mode_bits() static in path.c makes sense.
And for cygwin we have the re-define in compat/cygwin.h:
int cygwin_get_st_mode_bits(const char *path, int *mode);
#define get_st_mode_bits(p,m) cygwin_get_st_mode_bits((p),(m))
So, (besides the typo found by Eric),
Thanks. Reviewed,and tested OK here. In short:
Acked-By: Torsten Bögershausen <tboegi@web.de>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/6] path: Make the 'get_st_mode_bits' symbol a file static
2013-04-27 18:42 [PATCH 2/6] path: Make the 'get_st_mode_bits' symbol a file static Ramsay Jones
2013-04-28 2:26 ` Eric Sunshine
2013-04-28 6:02 ` Torsten Bögershausen
@ 2013-04-28 19:06 ` Junio C Hamano
2013-04-29 22:53 ` Ramsay Jones
2 siblings, 1 reply; 8+ messages in thread
From: Junio C Hamano @ 2013-04-28 19:06 UTC (permalink / raw)
To: Ramsay Jones; +Cc: tboegi, GIT Mailing-list
Ramsay Jones <ramsay@ramsay1.demon.co.uk> writes:
> On MinGW, sparse issues an "'get_st_mode_bits' not declared. Should
> it be static?" warning. The MinGW and MSVC builds do not see the
> declaration of this function, within git-compat-util.h, due to it's
> placement within an preprocessor conditional. (So, one solution would
> be to simply move the declaration to the top level of the header.)
Well, the idea was that the user of this function in path.c will
call get_st_mode_bits(), and whatever platform that provides a
replacement implementation would do
#define get_st_mode_bits(a,b) cygwin_get_st_mode_bits((a),(b))
so that the calling site in path.c will end up calling that
replacement implementation. So if anything get_st_mode_bits()
declaration may want to go at the _end_ (not top) after including
all the compatibility crufts.
We could make the declaration static to path.c, but then nobody
other than path.c would be able to make use of it in the future,
and we'll have the same discussion when somebody wants to hoist the
declaration to git-compat-util.h, no?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/6] path: Make the 'get_st_mode_bits' symbol a file static
2013-04-28 6:02 ` Torsten Bögershausen
2013-04-28 11:32 ` Torsten Bögershausen
@ 2013-04-29 21:57 ` Ramsay Jones
1 sibling, 0 replies; 8+ messages in thread
From: Ramsay Jones @ 2013-04-29 21:57 UTC (permalink / raw)
To: Torsten Bögershausen; +Cc: Junio C Hamano, GIT Mailing-list
Torsten Bögershausen wrote:
> On 2013-04-27 20.42, Ramsay Jones wrote:
>>
>> On MinGW, sparse issues an "'get_st_mode_bits' not declared. Should
>> it be static?" warning. The MinGW and MSVC builds do not see the
>> declaration of this function, within git-compat-util.h, due to it's
>> placement within an preprocessor conditional. (So, one solution would
>> be to simply move the declaration to the top level of the header.)
>>
>> In order to suppress the warning, since this symbol does not need
>> more than file visibility, we simply remove the declaration from
>> the header and add the static modifier to the function definition.
>>
>> Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
>> ---
>> git-compat-util.h | 1 -
>> path.c | 2 +-
>> 2 files changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/git-compat-util.h b/git-compat-util.h
>> index e955bb5..3a990b3 100644
>> --- a/git-compat-util.h
>> +++ b/git-compat-util.h
>> @@ -163,7 +163,6 @@
>> typedef long intptr_t;
>> typedef unsigned long uintptr_t;
>> #endif
>> -int get_st_mode_bits(const char *path, int *mode);
>> #if defined(__CYGWIN__)
>> #undef _XOPEN_SOURCE
>> #include <grp.h>
>> diff --git a/path.c b/path.c
>> index 04ff148..cc2e9ac 100644
>> --- a/path.c
>> +++ b/path.c
>> @@ -11,7 +11,7 @@
>> * may return wrong permission bits. Most of the time we do not care,
>> * but the callsites of this wrapper do care.
>> */
>> -int get_st_mode_bits(const char *path, int *mode)
>> +static int get_st_mode_bits(const char *path, int *mode)
>> {
>> struct stat st;
>> if (lstat(path, &st) < 0)
>>
> Sorry for breaking the MiNGW/MSVC builds.
> It seams that the get_st_mode_bits is badly placed.
You didn't break the build; simply provoked a warning.
As I said in the commit message, an alternative is to
simply move the declaration to the top level of the
header (out of the preprocessor conditional).
ATB,
Ramsay Jones
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/6] path: Make the 'get_st_mode_bits' symbol a file static
2013-04-28 19:06 ` Junio C Hamano
@ 2013-04-29 22:53 ` Ramsay Jones
2013-04-30 17:00 ` Junio C Hamano
0 siblings, 1 reply; 8+ messages in thread
From: Ramsay Jones @ 2013-04-29 22:53 UTC (permalink / raw)
To: Junio C Hamano; +Cc: tboegi, GIT Mailing-list
Junio C Hamano wrote:
> Ramsay Jones <ramsay@ramsay1.demon.co.uk> writes:
>
>> On MinGW, sparse issues an "'get_st_mode_bits' not declared. Should
>> it be static?" warning. The MinGW and MSVC builds do not see the
>> declaration of this function, within git-compat-util.h, due to it's
>> placement within an preprocessor conditional. (So, one solution would
>> be to simply move the declaration to the top level of the header.)
>
> Well, the idea was that the user of this function in path.c will
> call get_st_mode_bits(), and whatever platform that provides a
> replacement implementation would do
>
> #define get_st_mode_bits(a,b) cygwin_get_st_mode_bits((a),(b))
>
> so that the calling site in path.c will end up calling that
> replacement implementation. So if anything get_st_mode_bits()
> declaration may want to go at the _end_ (not top) after including
> all the compatibility crufts.
>
> We could make the declaration static to path.c, but then nobody
> other than path.c would be able to make use of it in the future,
> and we'll have the same discussion when somebody wants to hoist the
> declaration to git-compat-util.h, no?
I don't have a problem with keeping the declaration in git-compat-util.h
(after moving it so that the MinGW and MSVC builds can see it, of course)
if you would rather do that.
However, I'm always a little wary when I hear someone say "this may be
useful to others in the future, so lets do X to make it easier ...".
I have noticed that, much more often than not, that future user never
does materialise ... ;-)
Having said that ...
Back in 2011, when I was trying to fix t7606-merge-custom.sh (see
commit b8a9733377, "help.c: Fix detection of custom merge strategy
on cygwin", 16-06-2011), I had a patch that looked very similar to
the solution Torsten has arrived at here! (The main difference was
that I called stat() rather than lstat() to get the mode bits).
I decided to go with the simpler solution in commit b8a9733377.
ATB,
Ramsay Jones
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/6] path: Make the 'get_st_mode_bits' symbol a file static
2013-04-29 22:53 ` Ramsay Jones
@ 2013-04-30 17:00 ` Junio C Hamano
0 siblings, 0 replies; 8+ messages in thread
From: Junio C Hamano @ 2013-04-30 17:00 UTC (permalink / raw)
To: Ramsay Jones; +Cc: tboegi, GIT Mailing-list
Ramsay Jones <ramsay@ramsay1.demon.co.uk> writes:
> However, I'm always a little wary when I hear someone say "this may be
> useful to others in the future, so lets do X to make it easier ...".
> I have noticed that, much more often than not, that future user never
> does materialise ... ;-)
I do not think you are reading the reason for the function
correctly. It is not "We may find it useful elsewhere".
It is "We knew Windows benefits from having a 'quick, incorrect, but
the incorrectness happens not matter to the caller' hack, and we
used to use it everywhere. But we identified one location we need
to disable the hack for correctness, hence this 'slow-but-correct'
function. There may still be other places that needs fixing by
calling it".
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2013-04-30 17:00 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-27 18:42 [PATCH 2/6] path: Make the 'get_st_mode_bits' symbol a file static Ramsay Jones
2013-04-28 2:26 ` Eric Sunshine
2013-04-28 6:02 ` Torsten Bögershausen
2013-04-28 11:32 ` Torsten Bögershausen
2013-04-29 21:57 ` Ramsay Jones
2013-04-28 19:06 ` Junio C Hamano
2013-04-29 22:53 ` Ramsay Jones
2013-04-30 17:00 ` 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).