File: 07_fix_read_warning.patch

package info (click to toggle)
fspy 0.1.1-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 728 kB
  • sloc: ansic: 1,425; makefile: 41
file content (33 lines) | stat: -rw-r--r-- 778 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Description: Fix read() return value warning in enumdirs.c
 Detailed description of the changes made.
 .
 This patch implements the following:
 - (Add details here as needed)
Author: Bean Huo <beanhuo@micron.com>
Forwarded: no
Last-Update: 2025-11-12

diff --git a/src/enumdirs.c b/src/enumdirs.c
index a8a7b9c..7046bd0 100644
--- a/src/enumdirs.c
+++ b/src/enumdirs.c
@@ -61,11 +61,18 @@ int grab_max_element_count(void)
 {
 
 	int fd;
+	ssize_t bytes_read;
 	char buf[64]= {0};
 
 	fd = open("/proc/sys/fs/inotify/max_user_watches", O_RDONLY);
 	if(fd >= 0) {
-		read(fd, buf, 64);
+		bytes_read = read(fd, buf, 64);
+		if(bytes_read < 0) {
+			perror("read()");
+			close(fd);
+			exit(EXIT_FAILURE);
+		}
+		close(fd);
 	} else {
 		perror("open()");
 		exit(EXIT_FAILURE);