Skip to contentSkip to conversation

drivers/staging/wfx/main.c:47:14-21: ERROR: PTR_ERR applied after initialization to constant on line 42

PATCH Greg Kroah-Hartman 2 participants 2 messages Oct 7, 2019 – Oct 9, 2019 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 3767201.AobC1b7GVW@pc-42

#1 lore raw
Quoted 35 lines · Jerome Pouiller

On Friday 4 October 2019 12:48:32 CEST kbuild test robot wrote:
[...]

Quoted 22 lines
Quoted 1 line
Quoted 1 line

drivers/staging/wfx/main.c:47:14-21: ERROR: PTR_ERR applied after initialization to constant on line 42

vim +47 drivers/staging/wfx/main.c

    30
    31  struct gpio_desc *wfx_get_gpio(struct device *dev, int override, const char *label)
    32  {
    33          struct gpio_desc *ret;
    34          char label_buf[256];
    35
    36          if (override >= 0) {
    37                  snprintf(label_buf, sizeof(label_buf), "wfx_%s", label);
    38                  ret = ERR_PTR(devm_gpio_request_one(dev, override, GPIOF_OUT_INIT_LOW, label_buf));
    39                  if (!ret)
    40                          ret = gpio_to_desc(override);
    41          } else if (override == -1) {
Quoted 1 line

42 ret = NULL;

    43          } else {
    44                  ret = devm_gpiod_get(dev, label, GPIOD_OUT_LOW);
    45          }
    46          if (IS_ERR(ret) || !ret) {
Quoted 1 line

47 if (!ret || PTR_ERR(ret) == -ENOENT)

Quoted 10 lines
    48                          dev_warn(dev, "gpio %s is not defined\n", label);
    49                  else
    50                          dev_warn(dev, "error while requesting gpio %s\n", label);
    51                  ret = NULL;
    52          } else {
    53                  dev_dbg(dev, "using gpio %d for %s\n", desc_to_gpio(ret), label);
    54          }
    55          return ret;
    56  }
    57
Quoted 1 line

I think that this report is a false positive or I missed something?

No idea, but I really can not understand that code at all, so it does need to be simplified no matter what :)

thanks,

greg k-h

#2 lore raw
In reply to a message not in the archive
Quoted 33 lines · Jerome Pouiller

On Friday 4 October 2019 12:48:32 CEST kbuild test robot wrote:
[...]

Quoted 21 lines
Quoted 1 line
Quoted 1 line

drivers/staging/wfx/main.c:47:14-21: ERROR: PTR_ERR applied after initialization to constant on line 42

vim +47 drivers/staging/wfx/main.c

     30
     31  struct gpio_desc *wfx_get_gpio(struct device *dev, int override, const char *label)
     32  {
     33          struct gpio_desc *ret;
     34          char label_buf[256];
     35
     36          if (override >= 0) {
     37                  snprintf(label_buf, sizeof(label_buf), "wfx_%s", label);
     38                  ret = ERR_PTR(devm_gpio_request_one(dev, override, GPIOF_OUT_INIT_LOW, label_buf));
     39                  if (!ret)
     40                          ret = gpio_to_desc(override);
     41          } else if (override == -1) {
Quoted 1 line

42 ret = NULL;

     43          } else {
     44                  ret = devm_gpiod_get(dev, label, GPIOD_OUT_LOW);
     45          }
     46          if (IS_ERR(ret) || !ret) {
Quoted 1 line

47 if (!ret || PTR_ERR(ret) == -ENOENT)

Quoted 10 lines
     48                          dev_warn(dev, "gpio %s is not defined\n", label);
     49                  else
     50                          dev_warn(dev, "error while requesting gpio %s\n", label);
     51                  ret = NULL;
     52          } else {
     53                  dev_dbg(dev, "using gpio %d for %s\n", desc_to_gpio(ret), label);
     54          }
     55          return ret;
     56  }
     57
Quoted 2 lines

I think that this report is a false positive or I missed something?

Hi,

Sorry for the inconvenience, but we confirmed that the error first appeared since commit 0096214a59.

Best Regards,
Rong Chen