On Thu, Jan 05, 2012 at 04:49:41PM +0100, Cyril Hrubis wrote: > Hi! > > +#include "test.h" > > +#include "usctest.h" > > + > > +#define XATTR_TEST_KEY "user.testkey" > > +#define XATTR_TEST_VALUE "this is a test value" > > +#define XATTR_TEST_VALUE_SIZE 20 > > + > > +static void setup(void); > > +static void cleanup(void); > > + > > +char *TCID = "setxattr02"; > > + > > +char file[] = "setxattr02testfile"; > > +char dir[] = "setxattr02testdir"; > > +char sym[] = "setxattr02symlink"; > > +char fifo[] = "setxattr02fifo"; > > +char chr[] = "setxattr02chr"; > > +char blk[] = "setxattr02blk"; > > +char sock[] = "setxattr02sock"; > > Just to be extra correct here, there is a difference between > > char *var = "foo"; > > and > > char var[] = "foo"; > > The first one is const and thus not modifiable while the second > is an array and as a such it may be modified at the runtime. > > I think we should rather use *var = "foo" here.
Yes, I know the difference, but 'char *file = "foo"' will generate a compiling error like: setxattr02.c:88:3: error: initializer element is not constant setxattr02.c:88:3: error: (near initialization for ‘tc[0].fname’) So I used 'char file[] = "foo"'. That turns out to be a limitation of the C language. Quote the spec "All the expressions in an initializer for an object that has static storage duration shall be constant expressions or string literals." Will macro be a better way? Like: #define FILENAME "setxattr02testfile" #define DIRNAME "setxattr02testdir" > > Also I tend to declare global variables static as that way compiler > prints warning when they became unused. Ok, I'll fix this in next version. Thanks! Eryu Guan > > -- > Cyril Hrubis > [email protected] ------------------------------------------------------------------------------ Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex infrastructure or vast IT resources to deliver seamless, secure access to virtual desktops. With this all-in-one solution, easily deploy virtual desktops for less than the cost of PCs and save 60% on VDI infrastructure costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
