Re: [PATCH v2] cifs: fix charset issue in reconnection

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 20 Jul 2023 10:32:46 -0400
Tom Talpey <tom@xxxxxxxxxx> wrote:

> On 7/19/2023 12:31 AM, Winston Wen wrote:
> > On Tue, 18 Jul 2023 10:42:27 -0500
> > Steve French <smfrench@xxxxxxxxx> wrote:
> >   
> >> I get compile warning:
> >>
> >> /home/smfrench/cifs-2.6/fs/smb/client/connect.c: In function
> >> ‘cifs_get_smb_ses’:
> >> /home/smfrench/cifs-2.6/fs/smb/client/connect.c:2293:49: warning:
> >> passing argument 1 of ‘load_nls’ discards ‘const’ qualifier from
> >> pointer target type [-Wdiscarded-qualifiers]  
> > 
> >   
> >>   2293 |         ses->local_nls =
> >> load_nls(ctx->local_nls->charset);  
> > 
> > Hi Steve,
> > 
> > Sorry about the mistake I made. I updated the patch with a very
> > small change:
> > 
> > 	ses->local_nls = load_nls((char *)ctx->local_nls->charset);
> >  
> 
> I don't like this approach. Removing a const via casting is not
> a good idea. It invites write faults or outright bugs down
> the call stack.

Agreed, I've sent a patch that make load_nls() take a const parameter,
so we don't need to do the cast any more:

https://lore.kernel.org/linux-cifs/20230720063414.2546451-1-wentao@xxxxxxxxxxxxx/T/#u

> 
> Why is the charset not const itself?
> 
> Tom.
> 
> > It works, but I'm not sure whether it's clean enough.
> > 
> > Perhaps I should make a change to load_nls() to take a const char *
> > instead of char *? If this make sense, I'll do it soon.
> > 
> > Find the updated patch as attachment.
> >   
> 



-- 
Thanks,
Winston




[Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux