Skip to content

Commit 9b1d69a

Browse files
committed
utils/ps: fix a warning about read() return value not being used
Reading /proc/<pid>/status will hardly fail anyway. Signed-off-by: Brice Goglin <[email protected]>
1 parent c3111cd commit 9b1d69a

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

utils/hwloc/common-ps.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright © 2009-2022 Inria. All rights reserved.
2+
* Copyright © 2009-2023 Inria. All rights reserved.
33
* Copyright © 2009-2012 Université Bordeaux
44
* Copyright © 2009-2011 Cisco Systems, Inc. All rights reserved.
55
* See COPYING in top-level directory.
@@ -115,12 +115,13 @@ int hwloc_ps_read_process(hwloc_topology_t topology, hwloc_const_bitmap_t topocp
115115
if (fd >= 0) {
116116
char status[1024];
117117
char *uid;
118-
(void) read(fd, &status, sizeof(status));
119-
status[1023] = '\0';
120-
uid = strstr(status, "Uid:");
121-
if (uid)
122-
proc->uid = strtoul(uid+4, NULL, 0);
123-
close(fd);
118+
if (read(fd, &status, sizeof(status)) > 0) {
119+
status[1023] = '\0';
120+
uid = strstr(status, "Uid:");
121+
if (uid)
122+
proc->uid = strtoul(uid+4, NULL, 0);
123+
close(fd);
124+
}
124125
}
125126
free(path);
126127
#endif

0 commit comments

Comments
 (0)