Bug 622903

Summary: fix coverity Defect Type: Code maintainability issues
Product: [Retired] 389 Reporter: Noriko Hosoi <nhosoi>
Component: Directory ServerAssignee: Noriko Hosoi <nhosoi>
Status: CLOSED CURRENTRELEASE QA Contact: Chandrasekar Kannan <ckannan>
Severity: medium Docs Contact:
Priority: low    
Version: 1.2.6CC: benl
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
URL: http://10.16.47.145:8080/defects/index.htm?projectId=10030
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-05-17 14:08:15 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 576869, 639035    
Attachments:
Description Flags
git patch file (master)
nkinder: review+
git patch file (master)
nkinder: review+
git patch file (master)
none
git patch file (master)
nkinder: review+
git patch file (master)
none
git patch file (master)
nkinder: review+
git patch file (master)
nkinder: review+
git patch file (master)
nkinder: review+
git patch file (master)
nkinder: review+
git patch file (master)
nkinder: review+
git patch file (master)
nkinder: review+
git patch file (master)
nkinder: review+
git patch file (master)
nkinder: review+
git patch file (master)
nkinder: review+
git patch file (master)
nkinder: review+
git patch file (master)
nkinder: review+
git patch file (master) nkinder: review+

Description Noriko Hosoi 2010-08-10 18:22:10 UTC
Description of problem:
fix coverity Defect Type: Code maintainability issues

Comment 1 Noriko Hosoi 2010-08-10 18:34:01 UTC
Created attachment 437967 [details]
git patch file (master)

Comment:
The str assignment on line 1240 can be removed because the value
is not needed or will be overwritten.

Comment 2 Noriko Hosoi 2010-08-10 18:43:20 UTC
(In reply to comment #1)
> Created an attachment (id=437967) [details]
> git patch file (master)
> 
> Comment:
> The str assignment on line 1240 can be removed because the value
> is not needed or will be overwritten.    

http://10.16.47.145:8080/sourcebrowser.htm?projectId=10030#mergedDefectId=12248&streamDefectId=12434&defectInstanceId=14324&fileInstanceId=49281

Comment 3 Noriko Hosoi 2010-08-10 18:50:01 UTC
Created attachment 437971 [details]
git patch file (master)

http://10.16.47.145:8080/sourcebrowser.htm?projectId=10030#mergedDefectId=12249&streamDefectId=12435&defectInstanceId=14325&fileInstanceId=49281

Comment:
The call to strchr() is unnecessary because strcpy() will ensure
that string p is NULL-terminated.

http://10.16.47.145:8080/sourcebrowser.htm?projectId=10030#mergedDefectId=12250&streamDefectId=12436&defectInstanceId=14326&fileInstanceId=49281

Comment:
The call to strchr() is unnecessary because strcpy() will ensure
that string p is NULL-terminated.

Comment 4 Noriko Hosoi 2010-08-10 19:06:35 UTC
Created attachment 437974 [details]
git patch file (master)

http://10.16.47.145:8080/sourcebrowser.htm?projectId=10030#mergedDefectId=12251&streamDefectId=12437&defectInstanceId=14327&fileInstanceId=49278

Comment:
The "word" assignment on line 961 and 963 is unnecessary because
the value will be overwritten.

http://10.16.47.145:8080/sourcebrowser.htm?projectId=10030#mergedDefectId=12252&streamDefectId=12438&defectInstanceId=14329&fileInstanceId=49278

Comment:
The "s" assignments on line 271, 280, and 281 are unnecessary
because the value is never used.

Comment 5 Noriko Hosoi 2010-08-10 20:02:57 UTC
Comment on attachment 437974 [details]
git patch file (master)

Wrong attachment

Comment 6 Noriko Hosoi 2010-08-10 20:05:22 UTC
Created attachment 437988 [details]
git patch file (master)

git patch file (master)

http://10.16.47.145:8080/sourcebrowser.htm?projectId=10030#mergedDefectId=12251&streamDefectId=12437&defectInstanceId=14327&fileInstanceId=49278

Comment:
The "word" assignment on line 961 and 963 is unnecessary because
the value will be overwritten.

http://10.16.47.145:8080/sourcebrowser.htm?projectId=10030#mergedDefectId=12252&streamDefectId=12438&defectInstanceId=14329&fileInstanceId=49278

Comment:
The "s" assignments on line 271, 280, and 281 are unnecessary
because the value is never used.

Comment 7 Noriko Hosoi 2010-08-10 20:07:27 UTC
Created attachment 437989 [details]
git patch file (master)

http://10.16.47.145:8080/sourcebrowser.htm?projectId=10030#mergedDefectId=12253&streamDefectId=12439&defectInstanceId=14332&fileInstanceId=49208

Comment:
The result of PR_HashTableAdd() should be checked for NULL value.

Comment 8 Noriko Hosoi 2010-08-10 20:24:43 UTC
Created attachment 437992 [details]
git patch file (master)

12254
http://10.16.47.145:8080/sourcebrowser.htm?projectId=10030#mergedDefectId=12254&streamDefectId=12440&defectInstanceId=14333&fileInstanceId=49276
Comment:
The "ptr" assignment on line 2622 is unnecessary because the value is never used.

12255
http://10.16.47.145:8080/sourcebrowser.htm?projectId=10030#mergedDefectId=12255&streamDefectId=12441&defectInstanceId=14334&fileInstanceId=49276
Comment:
The "word" assignment on line 2630 can be removed because the first token is ignored. Alternatively the value should be validated.

12256
http://10.16.47.145:8080/sourcebrowser.htm?projectId=10030#mergedDefectId=12256&streamDefectId=12442&defectInstanceId=14335&fileInstanceId=49276
Comment:
The "ptr" assignment on line 1456 is unnecessary because the value is not used.

12257
http://10.16.47.145:8080/sourcebrowser.htm?projectId=10030#mergedDefectId=12257&streamDefectId=12443&defectInstanceId=14336&fileInstanceId=49276
Comment:
The "word" assignment on line 1463 can be removed because the first token is ignored. Alternatively the value should be validated.

12258
http://10.16.47.145:8080/sourcebrowser.htm?projectId=10030#mergedDefectId=12258&streamDefectId=12444&defectInstanceId=14337&fileInstanceId=49276
Comment:
The "ptr" assignment on line 1210 is unnecessary because the value is never used.

12259
http://10.16.47.145:8080/sourcebrowser.htm?projectId=10030#mergedDefectId=12259&streamDefectId=12445&defectInstanceId=14338&fileInstanceId=49276
Comment:
The "word" assignment on line 1217 can be removed because the first token is ignored. Alternatively the value should be validated.

Comment 9 Noriko Hosoi 2010-08-10 20:42:26 UTC
Created attachment 437996 [details]
git patch file (master)

12260
http://10.16.47.145:8080/sourcebrowser.htm?projectId=10030#mergedDefectId=12260&streamDefectId=12446&defectInstanceId=14339&fileInstanceId=49364

Comment:
The "bval" assignment on line 636 can be removed because any value is accepted.
Note: This is to set debug mode "cb_set_debug(1)" which is enabled by having nsDebug in the chaining config entry.

Comment 10 Noriko Hosoi 2010-08-10 21:01:00 UTC
Created attachment 438002 [details]
git patch file (master)

12261
http://10.16.47.145:8080/sourcebrowser.htm?projectId=10030#mergedDefectId=12261&streamDefectId=12447&defectInstanceId=14340&fileInstanceId=49519

Comment:
Pointer "replica" returned by "object_get_data(prp->replica_object)" (line 826) is never used.
In "case STATE_READY_TO_ACQUIRE", Replica object "replica" is not needed.

Comment 11 Noriko Hosoi 2010-08-10 22:29:19 UTC
Created attachment 438016 [details]
git patch file (master)

12262
http://10.16.47.145:8080/sourcebrowser.htm?projectId=10030#mergedDefectId=12262&streamDefectId=12448&defectInstanceId=14341&fileInstanceId=49526

Comment:
The return value from object_get_data is assigend to ruv just
to check if repl_ruv object exists or not with PR_ASSERT in
the DEBUG mode (line 218).  Passing the object_get_data call
to PR_ASSERT directly.

Comment 12 Noriko Hosoi 2010-08-10 22:43:39 UTC
Created attachment 438018 [details]
git patch file (master)

12263
http://10.16.47.145:8080/sourcebrowser.htm?projectId=10030#mergedDefectId=12263&streamDefectId=12449&defectInstanceId=14342&fileInstanceId=49541

Comment:
Pointer "replica" returned by "object_get_data(prp->replica_object)"
(line 502) is never used.  In "case STATE_READY_TO_ACQUIRE", Replica
object "replica" is not needed.

Comment 13 Noriko Hosoi 2010-08-10 22:57:59 UTC
Created attachment 438021 [details]
git patch file (master)

12264
http://10.16.47.145:8080/sourcebrowser.htm?projectId=10030#mergedDefectId=12264&streamDefectId=12450&defectInstanceId=14343&fileInstanceId=49587

Comment:
The "cn" assignment on line 221 can be removed because it is not needed.

Comment 14 Noriko Hosoi 2010-08-10 23:57:36 UTC
Created attachment 438029 [details]
git patch file (master)

12265
http://10.16.47.145:8080/sourcebrowser.htm?projectId=10030#mergedDefectId=12265&streamDefectId=12451&defectInstanceId=14344&fileInstanceId=49296

Comment:
Pointer "log_dir" returned by "dblayer_get_home_dir(li, NULL)" is never used (line 1492).
Removing the unnecessary else clause.

Comment 15 Noriko Hosoi 2010-08-11 00:08:48 UTC
Created attachment 438031 [details]
git patch file (master)

12266
http://10.16.47.145:8080/sourcebrowser.htm?projectId=10030#mergedDefectId=12266&streamDefectId=12452&defectInstanceId=14345&fileInstanceId=49321

Comment:
The "p" assignments on line 260, 264, and 268 can be removed because they are not needed.

Comment 16 Noriko Hosoi 2010-08-11 00:27:52 UTC
Created attachment 438034 [details]
git patch file (master)

12267
http://10.16.47.145:8080/sourcebrowser.htm?projectId=10030#mergedDefectId=12267&streamDefectId=12453&defectInstanceId=14348&fileInstanceId=49335

Comment:
Calling slapi_sdn_get_dn and assigning the return value to base is not needed.

Comment 17 Noriko Hosoi 2010-08-11 01:14:24 UTC
Created attachment 438042 [details]
git patch file (master)

12268
http://10.16.47.145:8080/sourcebrowser.htm?projectId=10030#mergedDefectId=12268&streamDefectId=12454&defectInstanceId=14349&fileInstanceId=49648

Comment:
Pointer "slapdFrontendConfig" returned by "init_config" is never used (line 244).

Comment 18 Noriko Hosoi 2010-08-11 17:22:14 UTC
Created attachment 438237 [details]
git patch file (master)

12269
http://10.16.47.145:8080/sourcebrowser.htm?projectId=10030#mergedDefectId=12269&streamDefectId=12455&defectInstanceId=14350&fileInstanceId=49809

Comment:
The "new_row" assignment on line 87 can be removed because it is
not needed.

Comment 19 Noriko Hosoi 2010-08-11 17:51:31 UTC
Created attachment 438247 [details]
git patch file (master)

12253
http://10.16.47.145:8080/sourcebrowser.htm?projectId=10030#mergedDefectId=12253&streamDefectId=12439&defectInstanceId=14332&fileInstanceId=49208

12270
http://10.16.47.145:8080/sourcebrowser.htm?projectId=10030#mergedDefectId=12270&streamDefectId=12456&defectInstanceId=14351&fileInstanceId=49208

Comment:
The result of PR_HashTableAdd() should be checked for NULL value.
Applied the change to all the PR_HashTableAdd calls in this file
lib/libaccess/register.cpp.

Comment 20 Noriko Hosoi 2010-08-11 22:53:56 UTC
Reviewed by Nathan (Thank you!!!)

Pushed to master.

$ git push
Counting objects: 130, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (101/101), done.
Writing objects: 100% (102/102), 11.25 KiB, done.
Total 102 (delta 78), reused 0 (delta 0)
To ssh://git.fedorahosted.org/git/389/ds.git
   100785a..79e2e7d  master -> master