From 2df96bf6ee14a1e6a67ba7bea7124bb6f2300e28 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 12 Dec 2017 12:51:54 -0500 Subject: [PATCH] use the return value of stat --- src/zm_event.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/zm_event.cpp b/src/zm_event.cpp index b371cd09d..b86c2f18f 100644 --- a/src/zm_event.cpp +++ b/src/zm_event.cpp @@ -143,9 +143,7 @@ Event::Event( Monitor *p_monitor, struct timeval p_start_time, const std::string } else { snprintf( path, sizeof(path), "%s/%d/%d", storage->Path(), monitor->Id(), id ); - errno = 0; - stat( path, &statbuf ); - if ( errno == ENOENT || errno == ENOTDIR ) { + if ( stat( path, &statbuf ) && ( errno == ENOENT || errno == ENOTDIR ) ) { if ( mkdir( path, 0755 ) ) { Error( "Can't mkdir %s: %s", path, strerror(errno)); }