Re: [PATCH] Add qword read/write support.

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

 



Hello!

>  #elif defined(PCI_HAVE_STDINT_H) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
> -#include <stdint.h>
> +#include <inttypes.h>

Even though it is probably OK to assume that <inttypes.h> exists whenever
<stdint.h> does, keeping using PCI_HAVE_STDINT_H for that is confusing :)

>  #else
> +#include <inttypes.h>
>  typedef u_int8_t u8;
>  typedef u_int16_t u16;
>  typedef u_int32_t u32;
> +typedef u_int64_t u64;

As I already said, we cannot rely on <inttypes.h> on non-C99 systems.

Also, we have to define the printf sequences ourselves.

>  #ifdef PCI_HAVE_64BIT_ADDRESS
>  #include <limits.h>
>  #if ULONG_MAX > 0xffffffff
> -typedef unsigned long u64;
> -#define PCI_U64_FMT "l"
> +typedef unsigned long pciaddr_t;
>  #else
> -typedef unsigned long long u64;
> -#define PCI_U64_FMT "ll"
> -#endif
> +typedef unsigned long long pciaddr_t;
>  #endif
>  
> -#endif	/* PCI_HAVE_Uxx_TYPES */
> +#define PCIADDR_T_FMT "%08" PRIu64 "x"
> +#define PCIADDR_PORT_FMT "%04" PRIu64 "x"

No, this is wrong. Since pciaddr_t is no longer u64, we must not use u64
printf sequences for it.

> -  const char * const formats[] = { NULL, " %02x", " %04x", NULL, " %08x" };
> -  const char * const mask_formats[] = { NULL, " %02x->(%02x:%02x)->%02x", " %04x->(%04x:%04x)->%04x", NULL, " %08x->(%08x:%08x)->%08x" };
> -  unsigned int i, x, y;
> +  const char * const formats[] = { NULL, " %02x", " %04x", NULL, " %08x", NULL, NULL, NULL, " %016" PRIu64 "x"};
> +  const char * const mask_formats[] = { NULL, " %02x->(%02x:%02x)->%02x", " %04x->(%04x:%04x)->%04x", NULL, " %08x->(%08x:%08x)->%08x", NULL, NULL, NULL, " %016" PRIu64 "x->(%016" PRIu64 "x:%016" PRIu64 "x)->%016" PRIu64 "x"};
> +  unsigned int i;
> +  u64 x, y;
>    int addr = 0;
>    int width = op->width;
>    char slot[16];
> @@ -120,6 +121,9 @@ exec_op(struct op *op, struct pci_dev *dev)
>  		case 2:
>  		  y = pci_read_word(dev, addr);
>  		  break;
> +		case 8:
> +		  y = pci_read_quad(dev, addr);
> +		  break;

This is also wrong. You have changed x,y to u64, but when you read a smaller
value to them, you try to print them with a non-u64 format string.

				Have a nice fortnight
-- 
Martin `MJ' Mares                          <mj@xxxxxx>   http://mj.ucw.cz/
Faculty of Math and Physics, Charles University, Prague, Czech Rep., Earth
The better the better, the better the bet.
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux