#985388 hdbm.c: add a type declaration to empty parentheses; correct type with a cast

Package:
src:nn
Source:
nn
Submitter:
Bjarni Ingi Gislason
Date:
2021-03-17 05:09:03 UTC
Severity:
normal
Tags:
#985388#5
Date:
2021-03-17 05:05:02 UTC
From:
To:
Dear Maintainer,

hdbm.c:

  Add a type declaration to an empty parenthesis in the functions
"hdbmcreate()", "hdbmentry()", and "hdbmwalk()".

  Add a cast in comparisons of "int" versus "unsigned int".

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
---
 hdbm.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/hdbm.c b/hdbm.c
index 6b8cbd2..1b47644 100644
--- a/hdbm.c
+++ b/hdbm.c
@@ -113,7 +113,7 @@ hdbmdef(register HDBMDATUM key)
 }

 HASHTABLE      *
-hdbmcreate(register unsigned size, unsigned (*hashfunc) ())
+hdbmcreate(register unsigned size, unsigned (*hashfunc) (void))
  /* size			a crude guide to size */
 {
     register HASHTABLE *tbl;
@@ -163,7 +163,7 @@ hefree(register HASHENT * hp)
 void
 hdbmdestroy(register HASHTABLE * tbl)
 {
-    register unsigned idx;
+    register unsigned int idx;
     register HASHENT *hp, *next;
     register HASHENT **hepp;
     register int    tblsize;
@@ -172,7 +172,7 @@ hdbmdestroy(register HASHTABLE * tbl)
 	return;
     tblsize = tbl->ht_size;
     hepp = tbl->ht_addr;
-    for (idx = 0; idx < tblsize; idx++) {
+    for (idx = 0; idx < (unsigned int) tblsize; idx++) {
 	for (hp = hepp[idx]; hp != NULL; hp = next) {
 	    next = hp->he_next;
 	    hp->he_next = NULL;
@@ -208,7 +208,7 @@ hdbmfind(register HASHTABLE * tbl, HDBMDATUM key)
     hepp = &tbl->ht_addr[(*tbl->ht_hash) (key) % size];
     for (hp = *hepp; hp != NULL; prevhp = hp, hp = hp->he_next) {
 	hpkeydat = hp->he_key.dat_ptr;
-	if (hp->he_key.dat_len == keylen && hpkeydat[0] == keydat[0] &&
+	if (hp->he_key.dat_len == (unsigned int) keylen && hpkeydat[0] == keydat[0] &&
 	    memcmp(hpkeydat, keydat, keylen) == 0)
 	    break;
     }
@@ -257,7 +257,7 @@ hdbmstore(register HASHTABLE * tbl, HDBMDATUM key, HDBMDATUM data)

 /* return any existing entry for key; otherwise call allocator to make one */
 HDBMDATUM
-hdbmentry(register HASHTABLE * tbl, HDBMDATUM key, HDBMDATUM(*allocator) ())
+hdbmentry(register HASHTABLE * tbl, HDBMDATUM key, HDBMDATUM(*allocator) (HDBMDATUM))
 {
     register HASHENT *hp;
     register HASHENT **nextp;
@@ -325,7 +325,8 @@ hdbmfetch(register HASHTABLE * tbl, HDBMDATUM key)
  * the same time.
  */
 void
-                hdbmwalk(HASHTABLE * tbl, register int (*nodefunc) (), register char *hook)
+hdbmwalk(HASHTABLE * tbl, register int (*nodefunc)
+	(HDBMDATUM, HDBMDATUM, char *), register char *hook)
  /* hook			(void *) really */
 {
     register unsigned idx;
@@ -337,7 +338,7 @@ void
 	return;
     hepp = tbl->ht_addr;
     tblsize = tbl->ht_size;
-    for (idx = 0; idx < tblsize; idx++)
+    for (idx = 0; idx < (unsigned int) tblsize; idx++)
 	for (hp = hepp[idx]; hp != NULL; hp = hp->he_next)
 	    (*nodefunc) (hp->he_key, hp->he_data, hook);
 }