Remove unnecessary free argument casts.

Don't abuse arcname's constness.
This commit is contained in:
Brian Somers 2007-05-25 17:53:38 +00:00
parent dbda4d7734
commit 367787a3c6
4 changed files with 29 additions and 32 deletions

View File

@ -1109,8 +1109,8 @@ get_phys(void)
int
ar_next(void)
{
static char *arcbuf;
char buf[PAXPATHLEN+2];
static int freeit = 0;
sigset_t o_mask;
/*
@ -1228,17 +1228,14 @@ ar_next(void)
* try to open new archive
*/
if (ar_open(buf) >= 0) {
if (freeit) {
free((char *)(uintptr_t)arcname);
freeit = 0;
}
if ((arcname = strdup(buf)) == NULL) {
free(arcbuf);
if ((arcbuf = strdup(buf)) == NULL) {
done = 1;
lstrval = -1;
paxwarn(0, "Cannot save archive name.");
return(-1);
}
freeit = 1;
arcname = arcbuf;
break;
}
tty_prnt("Cannot open %s, try again\n", buf);

View File

@ -140,7 +140,7 @@ rep_add(char *str)
regerror(res, &(rep->rcmp), rebuf, sizeof(rebuf));
paxwarn(1, "%s while compiling regular expression %s", rebuf, str);
# endif
free((char *)rep);
free(rep);
return(-1);
}
@ -152,11 +152,11 @@ rep_add(char *str)
*pt1++ = *str;
if ((pt2 = strchr(pt1, *str)) == NULL) {
# ifdef NET2_REGEX
free((char *)rep->rcmp);
free(rep->rcmp);
# else
regfree(&(rep->rcmp));
regfree(&rep->rcmp);
# endif
free((char *)rep);
free(rep);
paxwarn(1, "Invalid replacement string %s", str);
return(-1);
}
@ -181,11 +181,11 @@ rep_add(char *str)
break;
default:
# ifdef NET2_REGEX
free((char *)rep->rcmp);
free(rep->rcmp);
# else
regfree(&(rep->rcmp));
regfree(&rep->rcmp);
# endif
free((char *)rep);
free(rep);
*pt1 = *str;
paxwarn(1, "Invalid replacement string option %s", str);
return(-1);
@ -401,7 +401,7 @@ pat_sel(ARCHD *arcn)
return(-1);
}
*ppt = pt->fow;
free((char *)pt);
free(pt);
arcn->pat = NULL;
return(0);
}

View File

@ -412,7 +412,7 @@ trng_add(char *str)
*/
if (str_sec(str, &(pt->low_time)) < 0) {
paxwarn(1, "Illegal lower time range %s", str);
free((char *)pt);
free(pt);
goto out;
}
pt->flgs |= HASLOW;
@ -424,7 +424,7 @@ trng_add(char *str)
*/
if (str_sec(up_pt, &(pt->high_time)) < 0) {
paxwarn(1, "Illegal upper time range %s", up_pt);
free((char *)pt);
free(pt);
goto out;
}
pt->flgs |= HASHIGH;
@ -436,7 +436,7 @@ trng_add(char *str)
if (pt->low_time > pt->high_time) {
paxwarn(1, "Upper %s and lower %s time overlap",
up_pt, str);
free((char *)pt);
free(pt);
return(-1);
}
}

View File

@ -178,8 +178,8 @@ chk_lnk(ARCHD *arcn)
*/
if (--pt->nlink <= 1) {
*ppt = pt->fow;
free((char *)pt->name);
free((char *)pt);
free(pt->name);
free(pt);
}
return(1);
}
@ -198,7 +198,7 @@ chk_lnk(ARCHD *arcn)
ltab[indx] = pt;
return(0);
}
free((char *)pt);
free(pt);
}
paxwarn(1, "Hard link table out of memory");
@ -254,8 +254,8 @@ purg_lnk(ARCHD *arcn)
* remove and free it
*/
*ppt = pt->fow;
free((char *)pt->name);
free((char *)pt);
free(pt->name);
free(pt);
}
/*
@ -288,8 +288,8 @@ lnk_end(void)
while (pt != NULL) {
ppt = pt;
pt = ppt->fow;
free((char *)ppt->name);
free((char *)ppt);
free(ppt->name);
free(ppt);
}
}
return;
@ -460,7 +460,7 @@ chk_ftime(ARCHD *arcn)
paxwarn(1, "File time table ran out of memory");
if (pt != NULL)
free((char *)pt);
free(pt);
return(-1);
}
@ -538,7 +538,7 @@ add_name(char *oname, int onamelen, char *nname)
if (strcmp(nname, pt->nname) == 0)
return(0);
free((char *)pt->nname);
free(pt->nname);
if ((pt->nname = strdup(nname)) == NULL) {
paxwarn(1, "Cannot update rename table");
return(-1);
@ -557,9 +557,9 @@ add_name(char *oname, int onamelen, char *nname)
ntab[indx] = pt;
return(0);
}
free((char *)pt->oname);
free(pt->oname);
}
free((char *)pt);
free(pt);
}
paxwarn(1, "Interactive rename table out of memory");
return(-1);
@ -994,7 +994,7 @@ add_atdir(char *fname, dev_t dev, ino_t ino, time_t mtime, time_t atime)
atab[indx] = pt;
return;
}
free((char *)pt);
free(pt);
}
paxwarn(1, "Directory access time reset table ran out of memory");
@ -1051,8 +1051,8 @@ get_atdir(dev_t dev, ino_t ino, time_t *mtime, time_t *atime)
*ppt = pt->fow;
*mtime = pt->mtime;
*atime = pt->atime;
free((char *)pt->name);
free((char *)pt);
free(pt->name);
free(pt);
return(0);
}