From 29d0e8936431479617b9576b8d741bf83f500702 Mon Sep 17 00:00:00 2001 From: Tom Cherry Date: Tue, 8 Oct 2019 10:18:20 -0700 Subject: [PATCH] liblog: remove code checking for fd = 0 Fix a typo where I check socket()'s return value for 0 instead of -1 as an error. Remove code that checks if socket() returns 0 as the actual fd that it returns. This should not happen in any well formed program. Test: liblog unit tests Change-Id: I1d878e85d9a39155d68c6c84e9cf9b0db8d1b3a4 --- liblog/logd_reader.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/liblog/logd_reader.cpp b/liblog/logd_reader.cpp index 916a42819..d4c280c03 100644 --- a/liblog/logd_reader.cpp +++ b/liblog/logd_reader.cpp @@ -107,7 +107,7 @@ static int socket_local_client(const std::string& name, int type) { strlcpy(addr.sun_path, path.c_str(), sizeof(addr.sun_path)); int fd = socket(AF_LOCAL, type | SOCK_CLOEXEC, 0); - if (fd == 0) { + if (fd == -1) { return -1; } @@ -337,12 +337,6 @@ static int logdOpen(struct android_log_logger_list* logger_list, } sock = socket_local_client("logdr", SOCK_SEQPACKET); - if (sock == 0) { - /* Guarantee not file descriptor zero */ - int newsock = socket_local_client("logdr", SOCK_SEQPACKET); - close(sock); - sock = newsock; - } if (sock <= 0) { if ((sock == -1) && errno) { return -errno;