|
View:
New views
7 Messages
—
Rating Filter:
Alert me
|
|
|
mount.cifs - "Const" warnings patchDear mount.cifs maintainers,
we at the s4 side get always a "const" warning when compiling the "mount.cifs" tool. With this patch I substituted the existing "CONST_DISCARD" macro with the newer and better "discard_const_p" one developed by s4. When applying this one to the particular code line the warning goes away. Matthias |
|
|
Re: mount.cifs - "Const" warnings patchOn Fri, 30 Oct 2009 10:28:26 +0000 (GMT)
Matthias Dieter Wallnöfer <mdw@...> wrote: > Dear mount.cifs maintainers, > > we at the s4 side get always a "const" warning when compiling the "mount.cifs" tool. With this patch I substituted the existing "CONST_DISCARD" macro with the newer and better "discard_const_p" one developed by s4. When applying this one to the particular code line the warning goes away. > There was no patch in this mail. Could you resend? Thanks, -- Jeff Layton <jlayton@...> |
|
|
Re: mount.cifs - "Const" warnings patchHi Jeff,
sorry, sorry - sometimes I forget the attachments. Now it should be okay. Matthias Jeff Layton wrote: > On Fri, 30 Oct 2009 10:28:26 +0000 (GMT) > Matthias Dieter Wallnöfer<mdw@...> wrote: > > >> Dear mount.cifs maintainers, >> >> we at the s4 side get always a "const" warning when compiling the "mount.cifs" tool. With this patch I substituted the existing "CONST_DISCARD" macro with the newer and better "discard_const_p" one developed by s4. When applying this one to the particular code line the warning goes away. >> >> > There was no patch in this mail. Could you resend? > > Thanks, > |
|
|
Re: mount.cifs - "Const" warnings patchOn Mon, 02 Nov 2009 21:36:19 +0100
Matthias Dieter Wallnöfer <mdw@...> wrote: > Hi Jeff, > > sorry, sorry - sometimes I forget the attachments. > > Now it should be okay. > No problem, I do the same thing sometimes. The patch looks safe enough, but I wonder whether the problem is really in addmntent. Looking at a recent glibc, it doesn't look like addmntent ever changes any of the strings it gets passed. If any of them need to be reencoded, it uses alloca to get a new buffer and reencodes the string into that. Maybe the prototype for it should declare the struct as const. Fixing it there though may be problematic. Assuming that not stripping off the const generates a warning, maybe it would be a little more clear to just declare a non-const variable to hold a "cifs" string and pass that in instead. Something like this maybe? -- Jeff Layton <jlayton@...> From 13f490451f0bf536572a1f61cd0602410f8b1eff Mon Sep 17 00:00:00 2001 From: Jeff Layton <jlayton@...> Date: Sat, 7 Nov 2009 08:15:53 -0500 Subject: [PATCH] mount.cifs: get rid of CONST_DISCARD Apparently, we need to strip the "const" attribute off of the mnt_fstype before passing it to addmntent to prevent a (somewhat bogus) compiler warning. Rather than just stripping off the "const" attribute, clarify the code by declaring a new non-const char pointer that points to the same string. We can also use that same pointer in the mount(2) call too. Signed-off-by: Jeff Layton <jlayton@...> --- client/mount.cifs.c | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-) diff --git a/client/mount.cifs.c b/client/mount.cifs.c index 3baaad7..a9c1827 100644 --- a/client/mount.cifs.c +++ b/client/mount.cifs.c @@ -76,8 +76,6 @@ #define MAX_UNC_LEN 1024 -#define CONST_DISCARD(type, ptr) ((type) ((void *) (ptr))) - #ifndef SAFE_FREE #define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0) #endif @@ -123,6 +121,7 @@ static char * user_name = NULL; static char * mountpassword = NULL; char * domain_name = NULL; char * prefixpath = NULL; +char *cifs_fstype = "cifs"; /* glibc doesn't have strlcpy, strlcat. Ensure we do. JRA. We * don't link to libreplace so need them here. */ @@ -1590,7 +1589,7 @@ mount_retry: if (verboseflag) fprintf(stderr, "\n"); - if (!fakemnt && mount(dev_name, mountpoint, "cifs", flags, options)) { + if (!fakemnt && mount(dev_name, mountpoint, cifs_fstype, flags, options)) { switch (errno) { case ECONNREFUSED: case EHOSTUNREACH: @@ -1638,7 +1637,7 @@ mount_retry: } mountent.mnt_fsname = dev_name; mountent.mnt_dir = mountpoint; - mountent.mnt_type = CONST_DISCARD(char *,"cifs"); + mountent.mnt_type = cifs_fstype; mountent.mnt_opts = (char *)malloc(220); if(mountent.mnt_opts) { char * mount_user = getusername(); -- 1.6.0.6 |
|
|
Re: mount.cifs - "Const" warnings patchHi Jeff!
Yeah, please apply! My mission of this patch(set) was to prevent "CONST" warnings. Your solution does it in a very elegant manner (I would have only introduced another discard-const macro - which is far from perfect). Therefore it should be perfectly okay! Thanks for working with me on the CONST issue. Matthias --- Jeff Layton <jlayton@...> schrieb am Sa, 7.11.2009: Von: Jeff Layton <jlayton@...> Betreff: Re: mount.cifs - "Const" warnings patch An: "Matthias Dieter Wallnöfer" <mdw@...> CC: "Samba Technical Mailinglist" <samba-technical@...> Datum: Samstag, 7. November 2009, 14:19 On Mon, 02 Nov 2009 21:36:19 +0100 Matthias Dieter Wallnöfer <mdw@...> wrote: > Hi Jeff, > > sorry, sorry - sometimes I forget the attachments. > > Now it should be okay. > No problem, I do the same thing sometimes. The patch looks safe enough, but I wonder whether the problem is really in addmntent. Looking at a recent glibc, it doesn't look like addmntent ever changes any of the strings it gets passed. If any of them need to be reencoded, it uses alloca to get a new buffer and reencodes the string into that. Maybe the prototype for it should declare the struct as const. Fixing it there though may be problematic. Assuming that not stripping off the const generates a warning, maybe it would be a little more clear to just declare a non-const variable to hold a "cifs" string and pass that in instead. Something like this maybe? -- Jeff Layton <jlayton@...> |
|
|
Re: mount.cifs - "Const" warnings patchOn Sat, 7 Nov 2009 15:45:45 +0000 (GMT)
Matthias Dieter Wallnöfer <mdw@...> wrote: > Hi Jeff! > > Yeah, please apply! My mission of this patch(set) was to prevent "CONST" warnings. Your solution does it in a very elegant manner (I would have only introduced another discard-const macro - which is far from perfect). Therefore it should be perfectly okay! > > Thanks for working with me on the CONST issue. > > Matthias > > --- Jeff Layton <jlayton@...> schrieb am Sa, 7.11.2009: > > Von: Jeff Layton <jlayton@...> > Betreff: Re: mount.cifs - "Const" warnings patch > An: "Matthias Dieter Wallnöfer" <mdw@...> > CC: "Samba Technical Mailinglist" <samba-technical@...> > Datum: Samstag, 7. November 2009, 14:19 > > On Mon, 02 Nov 2009 21:36:19 +0100 > Matthias Dieter Wallnöfer <mdw@...> wrote: > > > Hi Jeff, > > > > sorry, sorry - sometimes I forget the attachments. > > > > Now it should be okay. > > > > No problem, I do the same thing sometimes. > > The patch looks safe enough, but I wonder whether the problem is really > in addmntent. Looking at a recent glibc, it doesn't look like addmntent > ever changes any of the strings it gets passed. If any of them need to > be reencoded, it uses alloca to get a new buffer and reencodes the > string into that. Maybe the prototype for it should declare the struct > as const. > > Fixing it there though may be problematic. Assuming that not stripping > off the const generates a warning, maybe it would be a little more > clear to just declare a non-const variable to hold a "cifs" string and > pass that in instead. Something like this maybe? > Pushed to master. Matthias, do you think this needs to go to any other branches? -- Jeff Layton <jlayton@...> |
|
|
Re: mount.cifs - "Const" warnings patchHi Jeff,
Jeff Layton wrote: > Pushed to master. > > Matthias, do you think this needs to go to any other branches? > I'm not aware of any other locations. Matthias |
| Free embeddable forum powered by Nabble | Forum Help |