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
diff --git a/liblog/logd_reader.cpp b/liblog/logd_reader.cpp
index 916a428..d4c280c 100644
--- a/liblog/logd_reader.cpp
+++ b/liblog/logd_reader.cpp
@@ -107,7 +107,7 @@
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 @@
}
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;