On Mon, 16 Dec 2019 20:34:33 -0800, Richard Cochran wrote: > On Mon, Dec 16, 2019 at 04:11:14PM -0800, Jakub Kicinski wrote: > > On Mon, 16 Dec 2019 08:13:26 -0800, Richard Cochran wrote: > > > + clkid = (u64 *)(data + offset + OFF_PTP_CLOCK_ID); > > > + portn = (u16 *)(data + offset + OFF_PTP_PORT_NUM); > > > + seqid = (u16 *)(data + offset + OFF_PTP_SEQUENCE_ID); > > > > These should perhaps be __be types? > > > > Looks like there is a few other sparse warnings in ptp_ines.c, would > > you mind addressing those? > > I saw the sparse warnings before (from one of the robots), but I > decided that they are false positives. Or perhaps I don't appreciate > what the warnings mean... > > Take the 'clkid' pointer for example: > > > > + if (cpu_to_be64(ts->clkid) != *clkid) { > > > + pr_debug("clkid mismatch ts %llx != skb %llx\n", > > > + cpu_to_be64(ts->clkid), *clkid); > > > + return false; > > > + } > > The field that to which 'clkid' points is in network byte order. The > code correctly converts ts->clkid (in CPU byte order) to network byte > order before comparing it with the field. > > So where is the error? Not necessarily an error as much as a sparse warning, if the type of clkid was __be64 that'd make sparse happy. This is what my build system spat out for a W=1 C=1 build: ../drivers/ptp/ptp_ines.c:490:13: warning: restricted __be64 degrades to integer ../drivers/ptp/ptp_ines.c:495:28: warning: cast to restricted __be16 ../drivers/ptp/ptp_ines.c:495:28: warning: cast to restricted __be16 ../drivers/ptp/ptp_ines.c:495:28: warning: cast to restricted __be16 ../drivers/ptp/ptp_ines.c:495:28: warning: cast to restricted __be16 ../drivers/ptp/ptp_ines.c:496:17: warning: cast to restricted __be16 ../drivers/ptp/ptp_ines.c:496:17: warning: cast to restricted __be16 ../drivers/ptp/ptp_ines.c:496:17: warning: cast to restricted __be16 ../drivers/ptp/ptp_ines.c:496:17: warning: cast to restricted __be16 ../drivers/ptp/ptp_ines.c:500:26: warning: cast to restricted __be16 ../drivers/ptp/ptp_ines.c:500:26: warning: cast to restricted __be16 ../drivers/ptp/ptp_ines.c:500:26: warning: cast to restricted __be16 ../drivers/ptp/ptp_ines.c:500:26: warning: cast to restricted __be16 ../drivers/ptp/ptp_ines.c:501:17: warning: cast to restricted __be16 ../drivers/ptp/ptp_ines.c:501:17: warning: cast to restricted __be16 ../drivers/ptp/ptp_ines.c:501:17: warning: cast to restricted __be16 ../drivers/ptp/ptp_ines.c:501:17: warning: cast to restricted __be16 ../drivers/ptp/ptp_ines.c:543:28: warning: incorrect type in argument 1 (different address spaces) ../drivers/ptp/ptp_ines.c:543:28: expected void const volatile [noderef] <asn:2> *addr ../drivers/ptp/ptp_ines.c:543:28: got unsigned int * ../drivers/ptp/ptp_ines.c:547:30: warning: incorrect type in argument 1 (different address spaces) ../drivers/ptp/ptp_ines.c:547:30: expected void const volatile [noderef] <asn:2> *addr ../drivers/ptp/ptp_ines.c:547:30: got unsigned int * ../drivers/ptp/ptp_ines.c:557:31: warning: incorrect type in argument 1 (different address spaces) ../drivers/ptp/ptp_ines.c:557:31: expected void const volatile [noderef] <asn:2> *addr ../drivers/ptp/ptp_ines.c:557:31: got unsigned int * ../drivers/ptp/ptp_ines.c:561:31: warning: incorrect type in argument 1 (different address spaces) ../drivers/ptp/ptp_ines.c:561:31: expected void const volatile [noderef] <asn:2> *addr ../drivers/ptp/ptp_ines.c:561:31: got unsigned int * ../drivers/ptp/ptp_ines.c:562:31: warning: incorrect type in argument 1 (different address spaces) ../drivers/ptp/ptp_ines.c:562:31: expected void const volatile [noderef] <asn:2> *addr ../drivers/ptp/ptp_ines.c:562:31: got unsigned int * ../drivers/ptp/ptp_ines.c:579:16: warning: incorrect type in argument 1 (different address spaces) ../drivers/ptp/ptp_ines.c:579:16: expected void const volatile [noderef] <asn:2> *addr ../drivers/ptp/ptp_ines.c:579:16: got unsigned int * ../drivers/ptp/ptp_ines.c:583:24: warning: incorrect type in argument 1 (different address spaces) ../drivers/ptp/ptp_ines.c:583:24: expected void const volatile [noderef] <asn:2> *addr ../drivers/ptp/ptp_ines.c:583:24: got unsigned int * ../drivers/ptp/ptp_ines.c:626:16: warning: incorrect type in argument 1 (different address spaces) ../drivers/ptp/ptp_ines.c:626:16: expected void const volatile [noderef] <asn:2> *addr ../drivers/ptp/ptp_ines.c:626:16: got unsigned int * ../drivers/ptp/ptp_ines.c:630:24: warning: incorrect type in argument 1 (different address spaces) ../drivers/ptp/ptp_ines.c:630:24: expected void const volatile [noderef] <asn:2> *addr ../drivers/ptp/ptp_ines.c:630:24: got unsigned int * ../drivers/ptp/ptp_ines.c:208:21: warning: incorrect type in assignment (different address spaces) ../drivers/ptp/ptp_ines.c:208:21: expected struct ines_global_registers *regs ../drivers/ptp/ptp_ines.c:208:21: got void [noderef] <asn:2> *base ../drivers/ptp/ptp_ines.c:225:9: warning: incorrect type in argument 2 (different address spaces) ../drivers/ptp/ptp_ines.c:225:9: expected void volatile [noderef] <asn:2> *addr ../drivers/ptp/ptp_ines.c:225:9: got unsigned int * ../drivers/ptp/ptp_ines.c:226:9: warning: incorrect type in argument 2 (different address spaces) ../drivers/ptp/ptp_ines.c:226:9: expected void volatile [noderef] <asn:2> *addr ../drivers/ptp/ptp_ines.c:226:9: got unsigned int * ../drivers/ptp/ptp_ines.c:228:9: warning: incorrect type in argument 1 (different address spaces) ../drivers/ptp/ptp_ines.c:228:9: expected void const volatile [noderef] <asn:2> *addr ../drivers/ptp/ptp_ines.c:228:9: got unsigned int * ../drivers/ptp/ptp_ines.c:229:9: warning: incorrect type in argument 1 (different address spaces) ../drivers/ptp/ptp_ines.c:229:9: expected void const volatile [noderef] <asn:2> *addr ../drivers/ptp/ptp_ines.c:229:9: got unsigned int * ../drivers/ptp/ptp_ines.c:230:9: warning: incorrect type in argument 1 (different address spaces) ../drivers/ptp/ptp_ines.c:230:9: expected void const volatile [noderef] <asn:2> *addr ../drivers/ptp/ptp_ines.c:230:9: got unsigned int * ../drivers/ptp/ptp_ines.c:231:9: warning: incorrect type in argument 1 (different address spaces) ../drivers/ptp/ptp_ines.c:231:9: expected void const volatile [noderef] <asn:2> *addr ../drivers/ptp/ptp_ines.c:231:9: got unsigned int * ../drivers/ptp/ptp_ines.c:235:17: warning: incorrect type in argument 2 (different address spaces) ../drivers/ptp/ptp_ines.c:235:17: expected void volatile [noderef] <asn:2> *addr ../drivers/ptp/ptp_ines.c:235:17: got unsigned int * ../drivers/ptp/ptp_ines.c:313:28: warning: incorrect type in argument 1 (different address spaces) ../drivers/ptp/ptp_ines.c:313:28: expected void const volatile [noderef] <asn:2> *addr ../drivers/ptp/ptp_ines.c:313:28: got unsigned int * ../drivers/ptp/ptp_ines.c:318:30: warning: incorrect type in argument 1 (different address spaces) ../drivers/ptp/ptp_ines.c:318:30: expected void const volatile [noderef] <asn:2> *addr ../drivers/ptp/ptp_ines.c:318:30: got unsigned int * ../drivers/ptp/ptp_ines.c:326:30: warning: incorrect type in argument 1 (different address spaces) ../drivers/ptp/ptp_ines.c:326:30: expected void const volatile [noderef] <asn:2> *addr ../drivers/ptp/ptp_ines.c:326:30: got unsigned int * ../drivers/ptp/ptp_ines.c:330:30: warning: incorrect type in argument 1 (different address spaces) ../drivers/ptp/ptp_ines.c:330:30: expected void const volatile [noderef] <asn:2> *addr ../drivers/ptp/ptp_ines.c:330:30: got unsigned int * ../drivers/ptp/ptp_ines.c:331:30: warning: incorrect type in argument 1 (different address spaces) ../drivers/ptp/ptp_ines.c:331:30: expected void const volatile [noderef] <asn:2> *addr ../drivers/ptp/ptp_ines.c:331:30: got unsigned int * ../drivers/ptp/ptp_ines.c:401:21: warning: incorrect type in argument 1 (different address spaces) ../drivers/ptp/ptp_ines.c:401:21: expected void const volatile [noderef] <asn:2> *addr ../drivers/ptp/ptp_ines.c:401:21: got unsigned int * ../drivers/ptp/ptp_ines.c:405:9: warning: incorrect type in argument 2 (different address spaces) ../drivers/ptp/ptp_ines.c:405:9: expected void volatile [noderef] <asn:2> *addr ../drivers/ptp/ptp_ines.c:405:9: got unsigned int * ../drivers/ptp/ptp_ines.c:406:9: warning: incorrect type in argument 2 (different address spaces) ../drivers/ptp/ptp_ines.c:406:9: expected void volatile [noderef] <asn:2> *addr ../drivers/ptp/ptp_ines.c:406:9: got unsigned int * ../drivers/ptp/ptp_ines.c:407:9: warning: incorrect type in argument 2 (different address spaces) ../drivers/ptp/ptp_ines.c:407:9: expected void volatile [noderef] <asn:2> *addr ../drivers/ptp/ptp_ines.c:407:9: got unsigned int * ../drivers/ptp/ptp_ines.c:440:21: warning: incorrect type in argument 1 (different address spaces) ../drivers/ptp/ptp_ines.c:440:21: expected void const volatile [noderef] <asn:2> *addr ../drivers/ptp/ptp_ines.c:440:21: got unsigned int * ../drivers/ptp/ptp_ines.c:444:9: warning: incorrect type in argument 2 (different address spaces) ../drivers/ptp/ptp_ines.c:444:9: expected void volatile [noderef] <asn:2> *addr ../drivers/ptp/ptp_ines.c:444:9: got unsigned int * ../drivers/ptp/ptp_ines.c:643:21: warning: incorrect type in argument 1 (different address spaces) ../drivers/ptp/ptp_ines.c:643:21: expected void const volatile [noderef] <asn:2> *addr ../drivers/ptp/ptp_ines.c:643:21: got unsigned int * New errors added