NetBSD Problem Report #29433

From www@netbsd.org  Fri Feb 18 00:30:56 2005
Return-Path: <www@netbsd.org>
Received: by narn.netbsd.org (Postfix, from userid 31301)
	id 651BF63B844; Fri, 18 Feb 2005 00:30:56 +0000 (UTC)
Message-Id: <20050218003056.651BF63B844@narn.netbsd.org>
Date: Fri, 18 Feb 2005 00:30:56 +0000 (UTC)
From: okumoto@soe.ucsd.ed
Reply-To: okumoto@soe.ucsd.ed
To: gnats-bugs@netbsd.org
Subject: Remove cast of emallloc()
X-Send-Pr-Version: www-1.0

>Number:         29433
>Category:       bin
>Synopsis:       Remove cast of emallloc()
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Feb 18 00:31:00 +0000 2005
>Closed-Date:    Sat Sep 23 22:41:41 +0000 2006
>Last-Modified:  Sat Sep 23 22:41:41 +0000 2006
>Originator:     Max Okumoto
>Release:        None
>Organization:
>Environment:
>Description:
Style pages says not to cast functions that return 'void *'
>How-To-Repeat:

>Fix:
Apply patch that will follow.

>Release-Note:

>Audit-Trail:
From: Max Okumoto <okumoto@ucsd.edu>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: bin/29433
Date: Thu, 17 Feb 2005 16:49:54 -0800

 This is a multi-part message in MIME format.
 --------------010003060805080508030105
 Content-Type: text/plain; charset=ISO-8859-1; format=flowed
 Content-Transfer-Encoding: 7bit

 Update to PR with patch

 --------------010003060805080508030105
 Content-Type: text/plain;
  name="p3"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="p3"

 diff nbsd-src fbsd-src
 diff -ru  nbsd-src/make.orig/arch.c nbsd-src/make/arch.c
 --- nbsd-src/make.orig/arch.c	Thu Feb 17 13:22:06 2005
 +++ nbsd-src/make/arch.c	Thu Feb 17 13:43:28 2005
 @@ -684,7 +684,7 @@
  #endif

  	    he = Hash_CreateEntry(&ar->members, memName, (Boolean *)NULL);
 -	    Hash_SetValue (he, (ClientData)emalloc (sizeof (struct ar_hdr)));
 +	    Hash_SetValue (he, emalloc (sizeof (struct ar_hdr)));
  	    memcpy ((Address)Hash_GetValue (he), (Address)&arh,
  		sizeof (struct ar_hdr));
  	}
 diff -ru  nbsd-src/make.orig/bit.h nbsd-src/make/bit.h
 --- nbsd-src/make.orig/bit.h	Thu Feb 17 13:22:06 2005
 +++ nbsd-src/make/bit.h	Thu Feb 17 13:43:35 2005
 @@ -93,7 +93,7 @@
  	(Bit_NumInts(numBits) * sizeof(int))

  #define Bit_Alloc(numBits, bitArrayPtr)  	\
 -        bitArrayPtr = (int *) emalloc((unsigned)Bit_NumBytes(numBits)); \
 +        bitArrayPtr = emalloc((unsigned)Bit_NumBytes(numBits)); \
          Bit_Zero((numBits), (bitArrayPtr))

  #define Bit_Free(bitArrayPtr)	\
 diff -ru  nbsd-src/make.orig/hash.c nbsd-src/make/hash.c
 --- nbsd-src/make.orig/hash.c	Thu Feb 17 13:22:05 2005
 +++ nbsd-src/make/hash.c	Thu Feb 17 13:41:59 2005
 @@ -144,7 +144,7 @@
  	t->numEntries = 0;
  	t->size = i;
  	t->mask = i - 1;
 -	t->bucketPtr = hp = (struct Hash_Entry **)emalloc(sizeof(*hp) * i);
 +	t->bucketPtr = hp = emalloc(sizeof(*hp) * i);
  	while (--i >= 0)
  		*hp++ = NULL;
  }
 @@ -444,7 +444,7 @@
  	i <<= 1;
  	t->size = i;
  	t->mask = mask = i - 1;
 -	t->bucketPtr = hp = (struct Hash_Entry **) emalloc(sizeof(*hp) * i);
 +	t->bucketPtr = hp = emalloc(sizeof(*hp) * i);
  	while (--i >= 0)
  		*hp++ = NULL;
  	for (hp = oldhp, i = oldsize; --i >= 0;) {

 --------------010003060805080508030105--

From: Max Okumoto <okumoto@ucsd.edu>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: bin/29433
Date: Thu, 17 Feb 2005 16:52:28 -0800

 This is a multi-part message in MIME format.
 --------------060805020904090109080403
 Content-Type: text/plain; charset=ISO-8859-1; format=flowed
 Content-Transfer-Encoding: 7bit

 Update to pr with patch

 --------------060805020904090109080403
 Content-Type: text/plain;
  name="p4"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="p4"

 diff -ru  nbsd-src/make.orig/arch.c nbsd-src/make/arch.c
 --- nbsd-src/make.orig/arch.c	Thu Feb 17 13:46:15 2005
 +++ nbsd-src/make/arch.c	Thu Feb 17 13:47:45 2005
 @@ -615,8 +615,8 @@
      Hash_InitTable(&ar->members, -1);
      memName[AR_MAX_NAME_LEN] = '\0';

 -    while (fread ((char *)&arh, sizeof (struct ar_hdr), 1, arch) == 1) {
 -	if (strncmp ( arh.ar_fmag, ARFMAG, sizeof (arh.ar_fmag)) != 0) {
 +    while (fread ((char *)&arh, sizeof(struct ar_hdr), 1, arch) == 1) {
 +	if (strncmp ( arh.ar_fmag, ARFMAG, sizeof(arh.ar_fmag)) != 0) {
  	    /*
  	     * The header is bogus, so the archive is bad
  	     * and there's no way we can recover...
 @@ -684,9 +684,9 @@
  #endif

  	    he = Hash_CreateEntry(&ar->members, memName, (Boolean *)NULL);
 -	    Hash_SetValue (he, emalloc (sizeof (struct ar_hdr)));
 +	    Hash_SetValue (he, emalloc (sizeof(struct ar_hdr)));
  	    memcpy ((Address)Hash_GetValue (he), (Address)&arh,
 -		sizeof (struct ar_hdr));
 +		sizeof(struct ar_hdr));
  	}
  	fseek (arch, (size + 1) & ~1, SEEK_CUR);
      }
 @@ -878,12 +878,12 @@
  	member = cp + 1;
      }
      len = tlen = strlen (member);
 -    if (len > sizeof (arhPtr->ar_name)) {
 -	tlen = sizeof (arhPtr->ar_name);
 +    if (len > sizeof(arhPtr->ar_name)) {
 +	tlen = sizeof(arhPtr->ar_name);
      }

 -    while (fread ((char *)arhPtr, sizeof (struct ar_hdr), 1, arch) == 1) {
 -	if (strncmp(arhPtr->ar_fmag, ARFMAG, sizeof (arhPtr->ar_fmag) ) != 0) {
 +    while (fread ((char *)arhPtr, sizeof(struct ar_hdr), 1, arch) == 1) {
 +	if (strncmp(arhPtr->ar_fmag, ARFMAG, sizeof(arhPtr->ar_fmag) ) != 0) {
  	     /*
  	      * The header is bogus, so the archive is bad
  	      * and there's no way we can recover...
 @@ -1003,7 +1003,7 @@
      snprintf(arh.ar_date, sizeof(arh.ar_date), "%-12ld", (long) now);

      if (arch != (FILE *) NULL) {
 -	(void)fwrite ((char *)&arh, sizeof (struct ar_hdr), 1, arch);
 +	(void)fwrite ((char *)&arh, sizeof(struct ar_hdr), 1, arch);
  	fclose (arch);
      }
  }
 @@ -1042,7 +1042,7 @@
      snprintf(arh.ar_date, sizeof(arh.ar_date), "%-12ld", (long) now);

      if (arch != (FILE *) NULL) {
 -	(void)fwrite ((char *)&arh, sizeof (struct ar_hdr), 1, arch);
 +	(void)fwrite ((char *)&arh, sizeof(struct ar_hdr), 1, arch);
  	fclose (arch);

  	times.actime = times.modtime = now;
 diff -ru  nbsd-src/make.orig/hash.h nbsd-src/make/hash.h
 --- nbsd-src/make.orig/hash.h	Thu Feb 17 13:46:12 2005
 +++ nbsd-src/make/hash.h	Thu Feb 17 13:47:51 2005
 @@ -134,7 +134,7 @@
   * Hash_Size(n) returns the number of words in an object of n bytes
   */

 -#define	Hash_Size(n)	(((n) + sizeof (int) - 1) / sizeof (int))
 +#define	Hash_Size(n)	(((n) + sizeof(int) - 1) / sizeof(int))

  void Hash_InitTable(Hash_Table *, int);
  void Hash_DeleteTable(Hash_Table *);
 diff -ru  nbsd-src/make.orig/parse.c nbsd-src/make/parse.c
 --- nbsd-src/make.orig/parse.c	Thu Feb 17 13:46:13 2005
 +++ nbsd-src/make/parse.c	Thu Feb 17 13:49:37 2005
 @@ -1992,7 +1992,7 @@
       */
      oldFile = emalloc(sizeof(IFile));

 -    memcpy(oldFile, &curFile, sizeof (IFile));
 +    memcpy(oldFile, &curFile, sizeof(IFile));

      (void) Lst_AtFront(includes, (ClientData)oldFile);

 @@ -2075,7 +2075,7 @@
  	(void) fprintf(stderr, "%s\n---- at line %d\n", str, lineno);

      oldFile = emalloc(sizeof(IFile));
 -    memcpy(oldFile, &curFile, sizeof (IFile));
 +    memcpy(oldFile, &curFile, sizeof(IFile));

      (void) Lst_AtFront(includes, (ClientData)oldFile);

 @@ -2217,7 +2217,7 @@
  	 * a very nice stack to track how we got here...
  	 */
  	oldFile = emalloc(sizeof(IFile));
 -	memcpy(oldFile, &curFile, sizeof (IFile));
 +	memcpy(oldFile, &curFile, sizeof(IFile));

  	(void) Lst_AtFront(includes, (ClientData)oldFile);

 @@ -2283,7 +2283,7 @@
  	free((Address) curFile.P);
      }

 -    memcpy(&curFile, ifile, sizeof (IFile));
 +    memcpy(&curFile, ifile, sizeof(IFile));

      free ((Address)ifile);

 diff -ru  nbsd-src/make.orig/targ.c nbsd-src/make/targ.c
 --- nbsd-src/make.orig/targ.c	Thu Feb 17 13:46:13 2005
 +++ nbsd-src/make/targ.c	Thu Feb 17 13:49:45 2005
 @@ -546,7 +546,7 @@
      static char	  	buf[128];

      parts = localtime(&tm);
 -    (void)strftime(buf, sizeof buf, "%k:%M:%S %b %d, %Y", parts);
 +    (void)strftime(buf, sizeof(buf), "%k:%M:%S %b %d, %Y", parts);
      return(buf);
  }

 --------------060805020904090109080403--

State-Changed-From-To: open->closed
State-Changed-By: elad@netbsd.org
State-Changed-When: Sat, 23 Sep 2006 22:41:41 +0000
State-Changed-Why:
this is a style issue...


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.