summaryrefslogtreecommitdiffstats
path: root/ldap
diff options
context:
space:
mode:
authorNathan Kinder <nkinder@redhat.com>2010-09-08 14:01:47 -0700
committerNathan Kinder <nkinder@redhat.com>2010-09-09 13:40:35 -0700
commitd02e95349a038ca3f096b5432c8604b8ca478e1c (patch)
tree4109621d18c878593aa7ecdf0b0ac70df79b9a99 /ldap
parent07d7c8977e783d1e9c34c25ce09f7a162a391c4a (diff)
downloadds-d02e95349a038ca3f096b5432c8604b8ca478e1c.tar.gz
ds-d02e95349a038ca3f096b5432c8604b8ca478e1c.tar.xz
ds-d02e95349a038ca3f096b5432c8604b8ca478e1c.zip
Bug 630094 - (cov#11818) Fix unreachable return in snmp subagent
The return statement at the end of agt_mopen_stats() is unreachable according to coverity. This return was removed before to fix the coverity defect, but it was added back to fix a compiler warning. We can satisfy both the compiler and coverity by adding a rc variable to hold the return code. We can then return rc at the end of the function. This also allows us to clean up all of the return calls in this function by having all of them set rc and jump to a label at the function end.
Diffstat (limited to 'ldap')
-rw-r--r--ldap/servers/slapd/agtmmap.c50
1 files changed, 33 insertions, 17 deletions
diff --git a/ldap/servers/slapd/agtmmap.c b/ldap/servers/slapd/agtmmap.c
index 9303bb5b..82862513 100644
--- a/ldap/servers/slapd/agtmmap.c
+++ b/ldap/servers/slapd/agtmmap.c
@@ -101,6 +101,7 @@ agt_mopen_stats (char * statsfile, int mode, int *hdl)
{
caddr_t fp;
char *path;
+ int rc = 0;
#ifndef _WIN32
int fd;
char *buf;
@@ -115,7 +116,8 @@ agt_mopen_stats (char * statsfile, int mode, int *hdl)
if (mmap_tbl [0].maptype != AGT_MAP_UNINIT)
{
*hdl = 0;
- return (EEXIST); /* We already mapped it once */
+ rc = EEXIST; /* We already mapped it once */
+ goto bail;
}
break;
@@ -123,12 +125,14 @@ agt_mopen_stats (char * statsfile, int mode, int *hdl)
if (mmap_tbl [1].maptype != AGT_MAP_UNINIT)
{
*hdl = 1;
- return (EEXIST); /* We already mapped it once */
+ rc = EEXIST; /* We already mapped it once */
+ goto bail;
}
break;
- default:
- return (EINVAL); /* Invalid (mode) parameter */
+ default:
+ rc = EINVAL; /* Invalid (mode) parameter */
+ goto bail;
} /* end switch */
@@ -149,7 +153,8 @@ agt_mopen_stats (char * statsfile, int mode, int *hdl)
#if (0)
fprintf (stderr, "returning errno =%d from %s(line: %d)\n", err, __FILE__, __LINE__);
#endif
- return (err);
+ rc = err;
+ goto bail;
}
fp = mmap (NULL, sizeof (struct agt_stats_t), PROT_READ, MAP_PRIVATE, fd, 0);
@@ -161,7 +166,8 @@ agt_mopen_stats (char * statsfile, int mode, int *hdl)
#if (0)
fprintf (stderr, "returning errno =%d from %s(line: %d)\n", err, __FILE__, __LINE__);
#endif
- return (err);
+ rc = err;
+ goto bail;
}
mmap_tbl [0].maptype = AGT_MAP_READ;
@@ -171,7 +177,7 @@ agt_mopen_stats (char * statsfile, int mode, int *hdl)
#if (0)
fprintf (stderr, "%s@%d> opened fp = %d\n", __FILE__, __LINE__, fp);
#endif
- return (0);
+ rc = 0;
case O_RDWR:
fd = open (path,
@@ -184,7 +190,8 @@ agt_mopen_stats (char * statsfile, int mode, int *hdl)
#if (0)
fprintf (stderr, "returning errno =%d from %s(line: %d)\n", err, __FILE__, __LINE__);
#endif
- return (err);
+ rc = err;
+ goto bail;
}
fstat (fd, &fileinfo);
@@ -208,14 +215,16 @@ agt_mopen_stats (char * statsfile, int mode, int *hdl)
#if (0)
fprintf (stderr, "returning errno =%d from %s(line: %d)\n", err, __FILE__, __LINE__);
#endif
- return (err);
+ rc = err;
+ goto bail;
}
mmap_tbl [1].maptype = AGT_MAP_RDWR;
mmap_tbl [1].fd = fd;
mmap_tbl [1].fp = fp;
*hdl = 1;
- return (0);
+
+ rc = 0;
} /* end switch */
#else
@@ -242,7 +251,8 @@ agt_mopen_stats (char * statsfile, int mode, int *hdl)
NULL);
if ( hMapFile == NULL ) {
CloseHandle( hFile );
- return GetLastError();
+ rc = GetLastError();
+ goto bail;
}
/* Create addr ptr to the start of the file */
@@ -251,7 +261,8 @@ agt_mopen_stats (char * statsfile, int mode, int *hdl)
if ( fp == NULL ) {
CloseHandle( hMapFile );
CloseHandle( hFile );
- return GetLastError();
+ rc = GetLastError();
+ goto bail;
}
/* Fill in info on this opaque handle */
@@ -260,7 +271,8 @@ agt_mopen_stats (char * statsfile, int mode, int *hdl)
mmap_tbl[0].fp = fp;
mmap_tbl[0].mfh = hMapFile;
*hdl = 0;
- return 0;
+
+ rc = 0;
}
case O_RDWR:
@@ -284,7 +296,8 @@ agt_mopen_stats (char * statsfile, int mode, int *hdl)
NULL );
if ( hMapFile == NULL ) {
CloseHandle( hFile );
- return GetLastError();
+ rc = GetLastError();
+ goto bail;
}
/* Create addr ptr to the start of the file */
@@ -293,7 +306,8 @@ agt_mopen_stats (char * statsfile, int mode, int *hdl)
if ( fp == NULL ) {
CloseHandle( hMapFile );
CloseHandle( hFile );
- return GetLastError();
+ rc = GetLastError();
+ goto bail;
}
mmap_tbl[1].maptype = AGT_MAP_RDWR;
@@ -301,7 +315,8 @@ agt_mopen_stats (char * statsfile, int mode, int *hdl)
mmap_tbl[1].fp = fp;
mmap_tbl[1].mfh = hMapFile;
*hdl = 1;
- return 0;
+
+ rc = 0;
}
@@ -310,7 +325,8 @@ agt_mopen_stats (char * statsfile, int mode, int *hdl)
#endif /* !__WINNT__ */
- return 0;
+bail:
+ return rc;
} /* agt_mopen_stats () */