summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNoriko Hosoi <nhosoi@redhat.com>2010-07-02 15:13:19 -0700
committerNoriko Hosoi <nhosoi@redhat.com>2010-07-23 13:25:28 -0700
commit2c2b3ecea9f478bc0e7308ace741ee9e2429acb7 (patch)
treed16907e289632694ac30ff4ee589244ab6019a44
parent7a5db43cc8dd899b62416a683c701416dd5d96e7 (diff)
610281 - fix coverity Defect Type: Control flow issues
https://bugzilla.redhat.com/show_bug.cgi?id=610281 11806 DEADCODE Triaged Unassigned Bug Moderate Fix Required agmt_set_last_init_status() ds/ldap/servers/plugins/replication/repl5_agmt.c Comment: macro NSDS50_REPL_REPLICA_READY is 0 repl5.h:#define NSDS50_REPL_REPLICA_READY 0x00 /* Replica ready, go ahead */ Because of this if expression: 1991 else if (replrc != 0) "Replica acquired successfully" never be set to last_init_status. Removed (replrc == NSDS50_REPL_REPLICA_READY) checking from the else if (replrc != 0) clause and added "Replica acquired successfully" to the string to print message since replrc == NSDS50_REPL_REPLICA_READY there. 11807 DEADCODE Triaged Unassigned Bug Moderate Fix Required agmt_set_last_update_status() ds/ldap/servers/plugins/replication/repl5_agmt.c Comment: macro NSDS50_REPL_REPLICA_READY is 0 repl5.h:#define NSDS50_REPL_REPLICA_READY 0x00 /* Replica ready, go ahead */ Because of this if expression: 1991 else if (replrc != 0) "Replica acquired successfully" never be set to last_update_status. Removed (replrc == NSDS50_REPL_REPLICA_READY) checking from the else if (replrc != 0) clause and added "Replica acquired successfully" to the string to print message since replrc == NSDS50_REPL_REPLICA_READY there.
-rw-r--r--ldap/servers/plugins/replication/repl5_agmt.c42
1 files changed, 20 insertions, 22 deletions
diff --git a/ldap/servers/plugins/replication/repl5_agmt.c b/ldap/servers/plugins/replication/repl5_agmt.c
index 890452dd..b5fcf957 100644
--- a/ldap/servers/plugins/replication/repl5_agmt.c
+++ b/ldap/servers/plugins/replication/repl5_agmt.c
@@ -1921,14 +1921,10 @@ agmt_set_last_update_status (Repl_Agmt *ra, int ldaprc, int replrc, const char *
replmsg ? " - " : "", replmsg ? replmsg : "");
}
}
+ /* ldaprc == LDAP_SUCCESS */
else if (replrc != 0)
{
- if (replrc == NSDS50_REPL_REPLICA_READY)
- {
- PR_snprintf(ra->last_update_status, STATUS_LEN, "%d %s",
- ldaprc, "Replica acquired successfully");
- }
- else if (replrc == NSDS50_REPL_REPLICA_BUSY)
+ if (replrc == NSDS50_REPL_REPLICA_BUSY)
{
PR_snprintf(ra->last_update_status, STATUS_LEN,
"%d Can't acquire busy replica", replrc );
@@ -1941,8 +1937,8 @@ agmt_set_last_update_status (Repl_Agmt *ra, int ldaprc, int replrc, const char *
else if (replrc == NSDS50_REPL_DISABLED)
{
PR_snprintf(ra->last_update_status, STATUS_LEN, "%d Incremental update aborted: "
- "Replication agreement for %s\n can not be updated while the replica is disabled.\n"
- "(If the suffix is disabled you must enable it then restart the server for replication to take place).",
+ "Replication agreement for %s\n can not be updated while the replica is disabled.\n"
+ "(If the suffix is disabled you must enable it then restart the server for replication to take place).",
replrc, ra->long_name ? ra->long_name : "a replica");
/* Log into the errors log, as "ra->long_name" is not accessible from the caller */
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
@@ -1959,11 +1955,14 @@ agmt_set_last_update_status (Repl_Agmt *ra, int ldaprc, int replrc, const char *
message?" - ":"",message?message:"");
}
}
- else if (message != NULL)
+ else if (message != NULL) /* replrc == NSDS50_REPL_REPLICA_READY == 0 */
{
- PR_snprintf(ra->last_update_status, STATUS_LEN, "%d %s", ldaprc, message);
+ PR_snprintf(ra->last_update_status, STATUS_LEN,
+ "%d Replica acquired successfully: %s",
+ ldaprc, message);
}
- else { /* agmt_set_last_update_status(0,0,NULL) to reset agmt */
+ else
+ { /* agmt_set_last_update_status(0,0,NULL) to reset agmt */
PR_snprintf(ra->last_update_status, STATUS_LEN, "%d", ldaprc);
}
}
@@ -1999,14 +1998,10 @@ agmt_set_last_init_status (Repl_Agmt *ra, int ldaprc, int replrc, const char *me
replmsg ? " - " : "", replmsg ? replmsg : "");
}
}
+ /* ldaprc == LDAP_SUCCESS */
else if (replrc != 0)
{
- if (replrc == NSDS50_REPL_REPLICA_READY)
- {
- PR_snprintf(ra->last_init_status, STATUS_LEN, "%d %s",
- ldaprc, "Replica acquired successfully");
- }
- else if (replrc == NSDS50_REPL_REPLICA_RELEASE_SUCCEEDED)
+ if (replrc == NSDS50_REPL_REPLICA_RELEASE_SUCCEEDED)
{
PR_snprintf(ra->last_init_status, STATUS_LEN, "%d %s",
ldaprc, "Replication session successful");
@@ -2014,8 +2009,8 @@ agmt_set_last_init_status (Repl_Agmt *ra, int ldaprc, int replrc, const char *me
else if (replrc == NSDS50_REPL_DISABLED)
{
PR_snprintf(ra->last_init_status, STATUS_LEN, "%d Total update aborted: "
- "Replication agreement for %s\n can not be updated while the replica is disabled.\n"
- "(If the suffix is disabled you must enable it then restart the server for replication to take place).",
+ "Replication agreement for %s\n can not be updated while the replica is disabled.\n"
+ "(If the suffix is disabled you must enable it then restart the server for replication to take place).",
replrc, ra->long_name ? ra->long_name : "a replica");
/* Log into the errors log, as "ra->long_name" is not accessible from the caller */
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
@@ -2032,11 +2027,14 @@ agmt_set_last_init_status (Repl_Agmt *ra, int ldaprc, int replrc, const char *me
message?" - ":"",message?message:"");
}
}
- else if (message != NULL)
+ else if (message != NULL) /* replrc == NSDS50_REPL_REPLICA_READY == 0 */
{
- PR_snprintf(ra->last_init_status, STATUS_LEN, "%d %s", ldaprc, message);
+ PR_snprintf(ra->last_init_status, STATUS_LEN,
+ "%d Replica acquired successfully: %s",
+ ldaprc, message);
}
- else { /* agmt_set_last_init_status(0,0,NULL) to reset agmt */
+ else
+ { /* agmt_set_last_init_status(0,0,NULL) to reset agmt */
PR_snprintf(ra->last_init_status, STATUS_LEN, "%d", ldaprc);
}
}