Skip to contentSkip to conversation

ifstat: handle unlink return value

PATCH Superseded Denis Kirjanov 2 participants 2 messages Feb 29, 2024

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ifstat: handle unlink return value

v2: exit if unlink failed

---
 misc/ifstat.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
misc/ifstat.c +4 -2
index 767cedd4..72901097 100644
@@ -937,8 +937,10 @@ int main(int argc, char *argv[])
 				 "%s/.%s_ifstat.u%d", P_tmpdir, stats_type,
 				 getuid());
 
-	if (reset_history)
-		unlink(hist_name);
+	if (reset_history && unlink(hist_name) < 0) {
+		perror("ifstat: unlink history file");
+		exit(-1);
+	}
 
 	if (!ignore_history || !no_update) {
 		struct stat stb;
Signature · 1 line
2.30.2
#1 lore raw
Quoted 1 line · Denis Kirjanov

v2: exit if unlink failed

please ignore

Quoted 22 lines
---
 misc/ifstat.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
misc/ifstat.c +4 -2
index 767cedd4..72901097 100644
@@ -937,8 +937,10 @@ int main(int argc, char *argv[])
 				 "%s/.%s_ifstat.u%d", P_tmpdir, stats_type,
 				 getuid());
 
-	if (reset_history)
-		unlink(hist_name);
+	if (reset_history && unlink(hist_name) < 0) {
+		perror("ifstat: unlink history file");
+		exit(-1);
+	}
 
 	if (!ignore_history || !no_update) {
 		struct stat stb;