@cryptotaxi247 / netdata-1 / commits / bf0dcdcc0

another round on coverity findings

Costa Tsaousis (ktsaou) committed Sep 6, 2017 at 01:28 UTC bf0dcdcc0e6bc0dab2e45f2d95334909fa2a862b
1 file changed +3 -6
src/socket.c
+3 -6
@@ -99,12 +99,9 @@ int create_listen_socket_unix(const char *path, int listen_backlog) {
99 name.sun_family = AF_UNIX;
100 strncpy(name.sun_path, path, sizeof(name.sun_path)-1);
101
102 - struct stat stbuf;
103 - if(stat(path, &stbuf) == 0) {
104 - // we have to delete any old socket, or bind() will fail
105 - if (unlink(path) == -1)
106 - error("LISTENER: failed to remove existing (probably obsolete or left-over) file on UNIX socket path '%s'.", path);
107 - }
102 + errno = 0;
103 + if (unlink(path) == -1 && errno != ENOENT)
104 + error("LISTENER: failed to remove existing (probably obsolete or left-over) file on UNIX socket path '%s'.", path);
105
106 if(bind (sock, (struct sockaddr *) &name, sizeof (name)) < 0) {
107 close(sock);