remove unused hsearch.c DBM code



13 years ago
10 years ago


(Reporter: Julien Pierre, Assigned: Biswatosh Chakraborty)


Firefox Tracking Flags

(Not tracked)



(1 attachment, 1 obsolete attachment)



13 years ago
The following serious warning occurs when compiling DBM on AMD64 :

../../../dbm/src/hsearch.c: In function `hcreate':
../../../dbm/src/hsearch.c:68: warning: cast from pointer to integer of
different size

The code is casting a DB* to int . This is very bad and won't work on platforms
where sizeof(int) != sizeof(void*).

However, the good news is that the hcreate function seems to have no callers in
NSS, and thus this bad code doesn't currently cause a problem.

Comment 1

13 years ago
The return value of hcreate is used as a boolean:
non-zero on success and 0 on failure.

If dbp is 0x100000000, (int)dbp will be 0, which
is the wrong return value.

A fix is the following:
    return (dbp ? 1: 0);
QA Contact: bishakhabanerjee → jason.m.reid
Assignee: wtchang → nobody
QA Contact: jason.m.reid → libraries
Priority: -- → P3

Comment 2

10 years ago
Since no one else is using DBM except NSS now, and it doesn't call hcreate, I believe we can just delete this function.


10 years ago
Assignee: nobody → biswatosh2001

Comment 3

10 years ago

We can remove hsearch.c and change the  security/dbm/src/
to delist hsearch.c from the list of source files to be compiled.
I did that, it is able to build nss successfully.

Just like hcreate(), other two functions in the same source file
(namely hsearch() and hdestroy()) are also not called anywhere 
else. However, dbm/src/hash.c does define another function hdestroy(HTAB*),
which is different from hdestroy(void) defined in hsearch.c. 

Thus, hdestroy(void), hsearch() and hcreate() defined in hsearch.c
are not getting called anywhere. 
Hence, if comment #2 proposes removal of hcreate(),
we can remove the source file  dbm/src/hsearch.c as well.

Attaching the patch for security/dbm/src/


Comment 4

10 years ago
Created attachment 282401 [details] [diff] [review]
Patch containing changes in security/dbm/src/

Please refer comment #3 for details on this attachment.
Attachment #282401 - Flags: review?(julien.pierre.boogz)
Comment on attachment 282401 [details] [diff] [review]
Patch containing changes in security/dbm/src/

Biswatosh, If dbm really doesn't need it, then eliminating hsearch.c 
altogether seems like a good idea.

Your patch needs to remove it from the manifest, AND also to cvs remove
the file. In your workarea, remove that file, and issue the command
  cvs remove hsearch.c 
to schedule it to be removed from the workarea when you commit.  
Then you make a patch that shows that it has been removed. To do that,
in the dbm/src directory, use the command
   cvs diff -Npu5 > some_patch_file_name
then attach that new patch to this bug.
Attachment #282401 - Flags: review?(julien.pierre.boogz) → review-

Comment 6

10 years ago
Created attachment 282504 [details] [diff] [review]
Patch2. Shows removal of hsearch.c as well.


I did the steps you suggested and now the patch shows
change of the manifest and removal of hsearch.c. Is it 
Attachment #282401 - Attachment is obsolete: true
Attachment #282504 - Flags: review?(nelson)
Comment on attachment 282504 [details] [diff] [review]
Patch2. Shows removal of hsearch.c as well.

Attachment #282504 - Flags: review?(nelson) → review+
Summary: bogus cast in unused DBM code → remove unused hsearch.c DBM code
Target Milestone: --- → 3.12

Comment 8

10 years ago
Checking in;
/cvsroot/mozilla/security/dbm/src/,v  <--
new revision: 1.8; previous revision: 1.7

Removing hsearch.c;
/cvsroot/mozilla/dbm/src/hsearch.c,v  <--  hsearch.c
new revision: delete; previous revision: 3.3

Comment 9

10 years ago
Wan-Teh had told me that it is not necessary to fix non-critical bugs on the NSS_3_11_BRANCH.
I think this bug is also non-critical and hence am not fixing this on the 
So, marking this bug as closed.
Last Resolved: 10 years ago
Resolution: --- → FIXED
It was correct to not fix this on the branch, because the target fix 
milestone was 3.12, not 3.11.x
You need to log in before you can comment on or make changes to this bug.