Skip to content

Commit

Permalink
Fix signed/unsigned pointer warning
Browse files Browse the repository at this point in the history
Commit 2ae83bf ("[CIFS] Fix setting time before epoch (negative
time values)") changed "u64 t" to "s64 t", which makes do_div() complain
about a pointer signedness mismatch:

      CC      fs/cifs/netmisc.o
    In file included from ./arch/mips/include/asm/div64.h:12:0,
                     from include/linux/kernel.h:124,
                     from include/linux/list.h:8,
                     from include/linux/wait.h:6,
                     from include/linux/net.h:23,
                     from fs/cifs/netmisc.c:25:
    fs/cifs/netmisc.c: In function ‘cifs_NTtimeToUnix’:
    include/asm-generic/div64.h:43:28: warning: comparison of distinct pointer types lacks a cast [enabled by default]
      (void)(((typeof((n)) *)0) == ((uint64_t *)0)); \
                                ^
    fs/cifs/netmisc.c:941:22: note: in expansion of macro ‘do_div’
       ts.tv_nsec = (long)do_div(t, 10000000) * 100;

Introduce a temporary "u64 abs_t" variable to fix this.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: Steve French <steve.french@primarydata.com>
  • Loading branch information
Kevin Cernekee authored and Steve French committed Dec 14, 2014
1 parent 9235d09 commit 97c7134
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions fs/cifs/netmisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -926,20 +926,22 @@ cifs_NTtimeToUnix(__le64 ntutc)

/* Subtract the NTFS time offset, then convert to 1s intervals. */
s64 t = le64_to_cpu(ntutc) - NTFS_TIME_OFFSET;
u64 abs_t;

/*
* Unfortunately can not use normal 64 bit division on 32 bit arch, but
* the alternative, do_div, does not work with negative numbers so have
* to special case them
*/
if (t < 0) {
t = -t;
ts.tv_nsec = (long)(do_div(t, 10000000) * 100);
abs_t = -t;
ts.tv_nsec = (long)(do_div(abs_t, 10000000) * 100);
ts.tv_nsec = -ts.tv_nsec;
ts.tv_sec = -t;
ts.tv_sec = -abs_t;
} else {
ts.tv_nsec = (long)do_div(t, 10000000) * 100;
ts.tv_sec = t;
abs_t = t;
ts.tv_nsec = (long)do_div(abs_t, 10000000) * 100;
ts.tv_sec = abs_t;
}

return ts;
Expand Down

0 comments on commit 97c7134

Please sign in to comment.