This is the mail archive of the cygwin-patches@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: w32api compiler warning fix.


On Thu, 2001-11-08 at 01:30, Corinna Vinschen wrote:
> On Thu, Nov 08, 2001 at 01:13:22AM +1100, Robert Collins wrote:
> > On Thu, 2001-11-08 at 01:07, Earnie Boyd wrote:
> > > Check this in.
> > Done
> 
> Did you actually check if Cygwin still compiles with that change?
> 
> /src/cygwin/src/winsup/cygwin/sec_helper.cc:45: initializer for scalar variable requires one element
> make: *** [sec_helper.o] Error 1
> 
> These *_SID_AUTHORITY defines are defined using only one brace
> even in the MS Platform SDK.

Well, I resarched the error before posting. The error is caused by
initialising a nested struct or multidimensional array with a single
array.

ie for a type that is an [3][2] array, initialising with {0,0,0,0,0,0}
will usually get the right bits into memory, but always generate the
compiler warning.

The typedef for SID_IDENTIFIER_AUTHORITY is

typedef struct _SID_IDENTIFIER_AUTHORITY {
        BYTE Value[6];
}, which as you can see is a nested struct.

The outer brace is the struct, the inner brace is the array.

Therefore, the double {} is correct if these initalisers are meant to be
used as they are in cinstall - which is where I got the warning.
 (in main.c, it's used as
SID_IDENTIFIER_AUTHORITY sid_auth = SECURITY_WORLD_SID_AUTHORITY;
)
 
> The usage of these symbolds is as in sec_helper.cc:
> 
> SID_IDENTIFIER_AUTHORITY sid_auth[] = {
>         {SECURITY_NULL_SID_AUTHORITY},
>         {SECURITY_WORLD_SID_AUTHORITY},
>         {SECURITY_LOCAL_SID_AUTHORITY},
>         {SECURITY_CREATOR_SID_AUTHORITY},
>         {SECURITY_NON_UNIQUE_AUTHORITY},
>         {SECURITY_NT_AUTHORITY}
> };
> 
> Could you please revert that patch?

What about this instead?

Index: sec_helper.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/sec_helper.cc,v
retrieving revision 1.13
diff -u -p -r1.13 sec_helper.cc
--- sec_helper.cc	2001/09/11 20:01:00	1.13
+++ sec_helper.cc	2001/11/07 15:00:41
@@ -36,12 +36,12 @@ details. */
 #include "cygheap.h"
 
 SID_IDENTIFIER_AUTHORITY sid_auth[] = {
-	{SECURITY_NULL_SID_AUTHORITY},
-	{SECURITY_WORLD_SID_AUTHORITY},
-	{SECURITY_LOCAL_SID_AUTHORITY},
-	{SECURITY_CREATOR_SID_AUTHORITY},
-	{SECURITY_NON_UNIQUE_AUTHORITY},
-	{SECURITY_NT_AUTHORITY}
+	SECURITY_NULL_SID_AUTHORITY,
+	SECURITY_WORLD_SID_AUTHORITY,
+	SECURITY_LOCAL_SID_AUTHORITY,
+	SECURITY_CREATOR_SID_AUTHORITY,
+	SECURITY_NON_UNIQUE_AUTHORITY,
+	SECURITY_NT_AUTHORITY
 };
 
 cygsid well_known_null_sid ("S-1-0-0");

Rob


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]