From c135f989ec779f1f2d6438c2220156baaf616065 Mon Sep 17 00:00:00 2001 From: Michael Vetter Date: Fri, 4 Oct 2019 23:29:10 +0200 Subject: Check errors in is_dir() is_regular_file() In case of error print the error. And return right value. Improvement based on @pasis advice in https://github.com/profanity-im/profanity/pull/1036 Applying in preparation to merge that PR. --- src/common.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/common.c b/src/common.c index 2a4da006..d8ee9915 100644 --- a/src/common.c +++ b/src/common.c @@ -443,7 +443,11 @@ int is_regular_file(const char *path) { struct stat st; - stat(path, &st); + int ret = stat(path, &st); + if (ret != 0) { + perror(NULL); + return 0; + } return S_ISREG(st.st_mode); } @@ -451,7 +455,11 @@ int is_dir(const char *path) { struct stat st; - stat(path, &st); + int ret = stat(path, &st); + if (ret != 0) { + perror(NULL); + return 0; + } return S_ISDIR(st.st_mode); } -- cgit 1.4.1-2-gfad0 chine. More thorough tests → More comprehensible and rewrite-friendly software → More resilient society.Kartik K. Agaram <vc@akkartik.com>
about summary refs log tree commit diff stats
path: root/cpp/.traces/new_array
blob: e692fc3839168d52776a25a0c7376e044b1e399b (plain) (blame)
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