Re: [PATCH 4/5] cifs: clean up unaligned accesses in cifs_unicode.c

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

 



On Wed, 19 Jan 2011 09:58:45 -0600
Shirish Pargaonkar <shirishpargaonkar@xxxxxxxxx> wrote:

> On Tue, Jan 18, 2011 at 2:33 PM, Jeff Layton <jlayton@xxxxxxxxxx> wrote:
> > Make sure we use get/put_unaligned routines when accessing wide
> > character strings.
> >
> > Signed-off-by: Jeff Layton <jlayton@xxxxxxxxxx>

[...]

> > @@ -60,7 +64,7 @@ cifs_ucs2_bytes(const __le16 *from, int maxbytes,
> >  /*
> >  * cifs_mapchar - convert a little-endian char to proper char in codepage
> 
> I think this wording is now incorrect since src_char is not le anymore.
> 

Good catch. I'll fix it.


[...]

> > @@ -158,19 +162,23 @@ cifs_from_ucs2(char *to, const __le16 *from, int tolen, int fromlen,
> >         */
> >        safelen = tolen - (NLS_MAX_CHARSET_SIZE + nullsize);
> >
> > -       for (i = 0; i < fromwords && from[i]; i++) {
> > +       for (i = 0; i < fromwords; i++) {
> > +               ftmp = get_unaligned_le16(&from[i]);
> > +               if (ftmp == 0)
> > +                       break;
> > +
> 
> Can the contents of from[i] be 0 so ftmp is 0 but we did
> not want to break out until fromwords?
> 

I don't quite understand what you're asking. The code should be
equivalent to what was there before except that we use
get_unaligned_le16 to get the value and store it in a variable on the
stack. Note that the '&& from[i]' condition was removed from the "for"
statement.


-- 
Jeff Layton <jlayton@xxxxxxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

  Powered by Linux