From 9174cc61589ef4fc554ca82077bbddabc06e617b Mon Sep 17 00:00:00 2001 From: Rich Megginson Date: Fri, 13 Aug 2010 14:32:22 -0600 Subject: Bug 610281 - fix coverity Defect Type: Control flow issues - daemon.c:write_function() https://bugzilla.redhat.com/show_bug.cgi?id=610281 Resolves: bug 610281 Bug Description: fix coverity Defect Type: Control flow issues - daemon.c:write_function() Reviewed by: nhosoi (Thanks!) Branch: master Fix Description: sentbytes < count is ok in the non error case - it just means we need to send some more data. Move the checking to the error case so we can print the number of bytes sent and expected. Platforms tested: RHEL5 x86_64, Fedora 14 x86_64 Flag Day: no Doc impact: no --- ldap/servers/slapd/daemon.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c index 783aaaed..249f247e 100644 --- a/ldap/servers/slapd/daemon.c +++ b/ldap/servers/slapd/daemon.c @@ -1712,6 +1712,11 @@ write_function( int ignore, const void *buffer, int count, struct lextiof_socket LDAPDebug(LDAP_DEBUG_ANY, "PR_Write(%d) " SLAPI_COMPONENT_NAME_NSPR " error %d (%s)\n", fd, prerr, slapd_pr_strerror( prerr )); + if (sentbytes < count) { + LDAPDebug(LDAP_DEBUG_CONNS, + "PR_Write(%d) - wrote only %d bytes (expected %d bytes) - 0 (EOF)\n", /* disconnected */ + fd, sentbytes, count); + } break; /* fatal error */ } } else if (bytes == 0) { /* disconnect */ @@ -1731,12 +1736,6 @@ write_function( int ignore, const void *buffer, int count, struct lextiof_socket fd, sentbytes, count); PR_SetError(PR_BUFFER_OVERFLOW_ERROR, EMSGSIZE); break; - } else if (sentbytes < count) { - LDAPDebug(LDAP_DEBUG_CONNS, - "PR_Write(%d) - wrote only %d bytes (expected %d bytes) - 0 (EOF)\n", /* disconnected */ - fd, sentbytes, count); - PR_SetError(PR_PIPE_ERROR, EPIPE); - break; } } } -- cgit