RE: nes_store_flash_data() bugged?

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

 



Hi Alexey,

You are right and the flash code is with 0[xX] and not starting with xX and p[0] checks are useless on marked line. This is from early development and did not get changed.

Thanks
Faisal

>-----Original Message-----
>From: Alexey Dobriyan [mailto:adobriyan@xxxxxxxxx]
>Sent: Friday, July 17, 2015 7:02 AM
>To: gstreiff@xxxxxxxxxxxxx; Latif, Faisal
>Cc: linux-rdma@xxxxxxxxxxxxxxx
>Subject: nes_store_flash_data() bugged?
>
>I've been converting nes.c driver and stumbled upon the following bit of code
>(below).
>
>What does marked line is supposed to mean?
>If it's usual 0[xX] check, then there are a lot of typos.
>If it is not and p[0] is, say, 'x', then simple_strtoul() will return 0 because 'x' is not
>valid start for hex integer.
>
>Can someone describe what the real format of this flash data is?
>
>  Alexey
>------------------
>static ssize_t nes_store_flash_data(struct device_driver *ddp,
>        const char *buf, size_t count)
>{
>        char *p = (char *)buf;
>        u32 val;
>        u32 i = 0;
>        struct nes_device *nesdev;
>
>        if (p[1] == 'x' || p[1] == 'X' || p[0] == 'x' || p[0] == 'X') {
>
>^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
>                val = simple_strtoul(p, &p, 16);
>                list_for_each_entry(nesdev, &nes_dev_list, list) {
>                        if (i == ee_flsh_adapter) {
>                                nes_write32(nesdev->regs + NES_FLASH_DATA, val);
>                                break;
>                        }
>                        i++;
>                }
>        }
>        return strnlen(buf, count);
>}
��.n��������+%������w��{.n�����{���fk��ܨ}���Ơz�j:+v�����w����ޙ��&�)ߡ�a����z�ޗ���ݢj��w�f




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux