Skip to content

Commit 45ec6c6

Browse files
sagigrimbergKeith Busch
authored andcommitted
nvme: fix compilation error
gcc 7.4.0. nvme.c: In function ‘print_relatives’: nvme.c:3505:3: error: ignoring return value of ‘asprintf’, declared with attribute warn_unused_result [-Werror=unused-result] asprintf(&path, "/sys/class/nvme/%s", devicename); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ nvme.c:3509:3: error: ignoring return value of ‘asprintf’, declared with attribute warn_unused_result [-Werror=unused-result] asprintf(&path, "/sys/block/%s/device", devicename); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors Makefile:57: recipe for target 'nvme' failed make: *** [nvme] Error 1 Signed-off-by: Sagi Grimberg <[email protected]>
1 parent d01d6a8 commit 45ec6c6

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

nvme.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3502,11 +3502,19 @@ static void print_relatives()
35023502
ret = sscanf(devicename, "nvme%dn%d", &id, &nsid);
35033503
switch (ret) {
35043504
case 1:
3505-
asprintf(&path, "/sys/class/nvme/%s", devicename);
3505+
ret = asprintf(&path, "/sys/class/nvme/%s", devicename);
3506+
if (ret < 0) {
3507+
perror("asprintf");
3508+
return;
3509+
}
35063510
block = false;
35073511
break;
35083512
case 2:
3509-
asprintf(&path, "/sys/block/%s/device", devicename);
3513+
ret = asprintf(&path, "/sys/block/%s/device", devicename);
3514+
if (ret < 0) {
3515+
perror("asprintf");
3516+
return;
3517+
}
35103518
break;
35113519
default:
35123520
return;

0 commit comments

Comments
 (0)