mirror of
git://git.sv.gnu.org/coreutils.git
synced 2026-07-26 18:48:55 +02:00
Remove anachronistic casts of xmalloc, xrealloc, and xcalloc return values.
This commit is contained in:
+1
-1
@@ -227,7 +227,7 @@ canonicalize_file_name (const char *name)
|
||||
new_size += end - start + 1;
|
||||
else
|
||||
new_size += PATH_MAX;
|
||||
rpath = (char *) xrealloc (rpath, new_size);
|
||||
rpath = xrealloc (rpath, new_size);
|
||||
rpath_limit = rpath + new_size;
|
||||
|
||||
dest = rpath + dest_offset;
|
||||
|
||||
+3
-4
@@ -104,10 +104,10 @@ struct exclude
|
||||
struct exclude *
|
||||
new_exclude (void)
|
||||
{
|
||||
struct exclude *ex = (struct exclude *) xmalloc (sizeof *ex);
|
||||
struct exclude *ex = xmalloc (sizeof *ex);
|
||||
ex->exclude_count = 0;
|
||||
ex->exclude_alloc = (1 << 6); /* This must be a power of 2. */
|
||||
ex->exclude = (struct patopts *) xmalloc (ex->exclude_alloc
|
||||
ex->exclude = xmalloc (ex->exclude_alloc
|
||||
* sizeof ex->exclude[0]);
|
||||
return ex;
|
||||
}
|
||||
@@ -206,8 +206,7 @@ add_exclude (struct exclude *ex, char const *pattern, int options)
|
||||
if (! (0 < s && s <= SIZE_MAX / sizeof ex->exclude[0]))
|
||||
xalloc_die ();
|
||||
ex->exclude_alloc = s;
|
||||
ex->exclude = (struct patopts *) xrealloc (ex->exclude,
|
||||
s * sizeof ex->exclude[0]);
|
||||
ex->exclude = xrealloc (ex->exclude, s * sizeof ex->exclude[0]);
|
||||
}
|
||||
|
||||
patopts = &ex->exclude[ex->exclude_count++];
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/* provide consistent interface to getgroups for systems that don't allow N==0
|
||||
Copyright (C) 1996, 1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 1996, 1999, 2003 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -43,7 +43,7 @@ getgroups (size_t n, GETGROUPS_T *group)
|
||||
gbuf = NULL;
|
||||
while (1)
|
||||
{
|
||||
gbuf = (GETGROUPS_T *) xrealloc (gbuf, n * sizeof (GETGROUPS_T));
|
||||
gbuf = xrealloc (gbuf, n * sizeof (GETGROUPS_T));
|
||||
n_groups = getgroups (n, gbuf);
|
||||
if (n_groups < n)
|
||||
break;
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/* getusershell.c -- Return names of valid user shells.
|
||||
Copyright (C) 1991, 1997, 2000, 2001 Free Software Foundation, Inc.
|
||||
Copyright (C) 1991, 1997, 2000, 2001, 2003 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -153,7 +153,7 @@ readname (name, size, stream)
|
||||
if (*name == NULL)
|
||||
{
|
||||
*size = 10;
|
||||
*name = (char *) xmalloc (*size);
|
||||
*name = xmalloc (*size);
|
||||
}
|
||||
|
||||
/* Skip blank space. */
|
||||
@@ -166,7 +166,7 @@ readname (name, size, stream)
|
||||
while (name_index >= *size)
|
||||
{
|
||||
*size *= 2;
|
||||
*name = (char *) xrealloc (*name, *size);
|
||||
*name = xrealloc (*name, *size);
|
||||
}
|
||||
c = getc (stream);
|
||||
}
|
||||
|
||||
+3
-4
@@ -1,5 +1,5 @@
|
||||
/* group-member.c -- determine whether group id is in calling user's group list
|
||||
Copyright (C) 1994, 1997, 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 1994, 1997, 1998, 2003 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -67,8 +67,7 @@ get_group_info (void)
|
||||
while (n_groups == n_group_slots)
|
||||
{
|
||||
n_group_slots += 64;
|
||||
group = (GETGROUPS_T *) xrealloc (group,
|
||||
n_group_slots * sizeof (GETGROUPS_T));
|
||||
group = xrealloc (group, n_group_slots * sizeof (GETGROUPS_T));
|
||||
n_groups = getgroups (n_group_slots, group);
|
||||
}
|
||||
|
||||
@@ -79,7 +78,7 @@ get_group_info (void)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gi = (struct group_info *) xmalloc (sizeof (*gi));
|
||||
gi = xmalloc (sizeof (*gi));
|
||||
gi->n_groups = n_groups;
|
||||
gi->group = group;
|
||||
|
||||
|
||||
+4
-4
@@ -77,7 +77,7 @@ getuser (uid_t uid)
|
||||
return tail->name;
|
||||
|
||||
pwent = getpwuid (uid);
|
||||
tail = (struct userid *) xmalloc (sizeof (struct userid));
|
||||
tail = xmalloc (sizeof (struct userid));
|
||||
tail->id.u = uid;
|
||||
tail->name = pwent ? xstrdup (pwent->pw_name) : NULL;
|
||||
|
||||
@@ -119,7 +119,7 @@ getuidbyname (const char *user)
|
||||
}
|
||||
#endif
|
||||
|
||||
tail = (struct userid *) xmalloc (sizeof (struct userid));
|
||||
tail = xmalloc (sizeof (struct userid));
|
||||
tail->name = xstrdup (user);
|
||||
|
||||
/* Add to the head of the list, so most recently used is first. */
|
||||
@@ -153,7 +153,7 @@ getgroup (gid_t gid)
|
||||
return tail->name;
|
||||
|
||||
grent = getgrgid (gid);
|
||||
tail = (struct userid *) xmalloc (sizeof (struct userid));
|
||||
tail = xmalloc (sizeof (struct userid));
|
||||
tail->id.g = gid;
|
||||
tail->name = grent ? xstrdup (grent->gr_name) : NULL;
|
||||
|
||||
@@ -195,7 +195,7 @@ getgidbyname (const char *group)
|
||||
}
|
||||
#endif
|
||||
|
||||
tail = (struct userid *) xmalloc (sizeof (struct userid));
|
||||
tail = xmalloc (sizeof (struct userid));
|
||||
tail->name = xstrdup (group);
|
||||
|
||||
/* Add to the head of the list, so most recently used is first. */
|
||||
|
||||
+20
-20
@@ -322,21 +322,21 @@ read_filesystem_list (int need_fs_type)
|
||||
remove. Specifically, automount create normal NFS mounts.
|
||||
*/
|
||||
|
||||
if(listmntent(&mntlist, KMTAB, NULL, NULL) < 0)
|
||||
if (listmntent (&mntlist, KMTAB, NULL, NULL) < 0)
|
||||
return NULL;
|
||||
for (p = mntlist; p; p = p->next) {
|
||||
mnt = p->ment;
|
||||
me = (struct mount_entry*) xmalloc(sizeof (struct mount_entry));
|
||||
me->me_devname = xstrdup(mnt->mnt_fsname);
|
||||
me->me_mountdir = xstrdup(mnt->mnt_dir);
|
||||
me->me_type = xstrdup(mnt->mnt_type);
|
||||
me = xmalloc (sizeof (struct mount_entry));
|
||||
me->me_devname = xstrdup (mnt->mnt_fsname);
|
||||
me->me_mountdir = xstrdup (mnt->mnt_dir);
|
||||
me->me_type = xstrdup (mnt->mnt_type);
|
||||
me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
|
||||
me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
|
||||
me->me_dev = -1;
|
||||
*mtail = me;
|
||||
mtail = &me->me_next;
|
||||
}
|
||||
freemntlist(mntlist);
|
||||
freemntlist (mntlist);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -353,7 +353,7 @@ read_filesystem_list (int need_fs_type)
|
||||
|
||||
while ((mnt = getmntent (fp)))
|
||||
{
|
||||
me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
|
||||
me = xmalloc (sizeof (struct mount_entry));
|
||||
me->me_devname = xstrdup (mnt->mnt_fsname);
|
||||
me->me_mountdir = xstrdup (mnt->mnt_dir);
|
||||
me->me_type = xstrdup (mnt->mnt_type);
|
||||
@@ -392,7 +392,7 @@ read_filesystem_list (int need_fs_type)
|
||||
{
|
||||
char *fs_type = fsp_to_string (fsp);
|
||||
|
||||
me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
|
||||
me = xmalloc (sizeof (struct mount_entry));
|
||||
me->me_devname = xstrdup (fsp->f_mntfromname);
|
||||
me->me_mountdir = xstrdup (fsp->f_mntonname);
|
||||
me->me_type = fs_type;
|
||||
@@ -417,7 +417,7 @@ read_filesystem_list (int need_fs_type)
|
||||
0 < (val = getmnt (&offset, &fsd, sizeof (fsd), NOSTAT_MANY,
|
||||
(char *) 0)))
|
||||
{
|
||||
me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
|
||||
me = xmalloc (sizeof (struct mount_entry));
|
||||
me->me_devname = xstrdup (fsd.fd_req.devname);
|
||||
me->me_mountdir = xstrdup (fsd.fd_req.path);
|
||||
me->me_type = gt_names[fsd.fd_req.fstype];
|
||||
@@ -489,7 +489,7 @@ read_filesystem_list (int need_fs_type)
|
||||
{
|
||||
struct rootdir_entry *re;
|
||||
|
||||
re = (struct rootdir_entry *) xmalloc (sizeof (struct rootdir_entry));
|
||||
re = xmalloc (sizeof (struct rootdir_entry));
|
||||
re->name = name;
|
||||
re->dev = statbuf.st_dev;
|
||||
re->ino = statbuf.st_ino;
|
||||
@@ -515,7 +515,7 @@ read_filesystem_list (int need_fs_type)
|
||||
if (re->dev == fi.dev && re->ino == fi.root)
|
||||
break;
|
||||
|
||||
me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
|
||||
me = xmalloc (sizeof (struct mount_entry));
|
||||
me->me_devname = xstrdup (fi.device_name[0] != '\0' ? fi.device_name : fi.fsh_name);
|
||||
me->me_mountdir = xstrdup (re != NULL ? re->name : fi.fsh_name);
|
||||
me->me_type = xstrdup (fi.fsh_name);
|
||||
@@ -549,7 +549,7 @@ read_filesystem_list (int need_fs_type)
|
||||
return (NULL);
|
||||
|
||||
bufsize = (1 + numsys) * sizeof (struct statfs);
|
||||
stats = (struct statfs *)xmalloc (bufsize);
|
||||
stats = xmalloc (bufsize);
|
||||
numsys = getfsstat (stats, bufsize, MNT_WAIT);
|
||||
|
||||
if (numsys < 0)
|
||||
@@ -560,7 +560,7 @@ read_filesystem_list (int need_fs_type)
|
||||
|
||||
for (counter = 0; counter < numsys; counter++)
|
||||
{
|
||||
me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
|
||||
me = xmalloc (sizeof (struct mount_entry));
|
||||
me->me_devname = xstrdup (stats[counter].f_mntfromname);
|
||||
me->me_mountdir = xstrdup (stats[counter].f_mntonname);
|
||||
me->me_type = xstrdup (FS_TYPE (stats[counter]));
|
||||
@@ -589,7 +589,7 @@ read_filesystem_list (int need_fs_type)
|
||||
|
||||
while (fread (&mnt, sizeof mnt, 1, fp) > 0)
|
||||
{
|
||||
me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
|
||||
me = xmalloc (sizeof (struct mount_entry));
|
||||
# ifdef GETFSTYP /* SVR3. */
|
||||
me->me_devname = xstrdup (mnt.mt_dev);
|
||||
# else
|
||||
@@ -634,12 +634,12 @@ read_filesystem_list (int need_fs_type)
|
||||
|
||||
#ifdef MOUNTED_GETMNTTBL /* DolphinOS goes it's own way */
|
||||
{
|
||||
struct mntent **mnttbl=getmnttbl(),**ent;
|
||||
struct mntent **mnttbl = getmnttbl (), **ent;
|
||||
for (ent=mnttbl;*ent;ent++)
|
||||
{
|
||||
me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
|
||||
me = xmalloc (sizeof (struct mount_entry));
|
||||
me->me_devname = xstrdup ( (*ent)->mt_resource);
|
||||
me->me_mountdir = xstrdup( (*ent)->mt_directory);
|
||||
me->me_mountdir = xstrdup ( (*ent)->mt_directory);
|
||||
me->me_type = xstrdup ((*ent)->mt_fstype);
|
||||
me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
|
||||
me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
|
||||
@@ -649,7 +649,7 @@ read_filesystem_list (int need_fs_type)
|
||||
*mtail = me;
|
||||
mtail = &me->me_next;
|
||||
}
|
||||
endmnttbl();
|
||||
endmnttbl ();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -698,7 +698,7 @@ read_filesystem_list (int need_fs_type)
|
||||
{
|
||||
while ((ret = getmntent (fp, &mnt)) == 0)
|
||||
{
|
||||
me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
|
||||
me = xmalloc (sizeof (struct mount_entry));
|
||||
me->me_devname = xstrdup (mnt.mnt_special);
|
||||
me->me_mountdir = xstrdup (mnt.mnt_mountp);
|
||||
me->me_type = xstrdup (mnt.mnt_fstype);
|
||||
@@ -755,7 +755,7 @@ read_filesystem_list (int need_fs_type)
|
||||
char *options, *ignore;
|
||||
|
||||
vmp = (struct vmount *) thisent;
|
||||
me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
|
||||
me = xmalloc (sizeof (struct mount_entry));
|
||||
if (vmp->vmt_flags & MNT_REMOTE)
|
||||
{
|
||||
char *host, *path;
|
||||
|
||||
+6
-6
@@ -62,7 +62,7 @@ init_tokenbuffer (tokenbuffer)
|
||||
token_buffer *tokenbuffer;
|
||||
{
|
||||
tokenbuffer->size = INITIAL_TOKEN_LENGTH;
|
||||
tokenbuffer->buffer = ((char *) xmalloc (INITIAL_TOKEN_LENGTH));
|
||||
tokenbuffer->buffer = (xmalloc (INITIAL_TOKEN_LENGTH));
|
||||
}
|
||||
|
||||
/* Read a token from `stream' into `tokenbuffer'.
|
||||
@@ -184,8 +184,8 @@ readtokens (FILE *stream,
|
||||
else
|
||||
projected_n_tokens = 64;
|
||||
sz = projected_n_tokens;
|
||||
tokens = (char **) xmalloc (sz * sizeof (char *));
|
||||
lengths = (long *) xmalloc (sz * sizeof (long));
|
||||
tokens = xmalloc (sz * sizeof (char *));
|
||||
lengths = xmalloc (sz * sizeof (long));
|
||||
|
||||
init_tokenbuffer (token);
|
||||
for (;;)
|
||||
@@ -195,8 +195,8 @@ readtokens (FILE *stream,
|
||||
if (n_tokens >= sz)
|
||||
{
|
||||
sz *= 2;
|
||||
tokens = (char **) xrealloc (tokens, sz * sizeof (char *));
|
||||
lengths = (long *) xrealloc (lengths, sz * sizeof (long));
|
||||
tokens = xrealloc (tokens, sz * sizeof (char *));
|
||||
lengths = xrealloc (lengths, sz * sizeof (long));
|
||||
}
|
||||
|
||||
if (token_length < 0)
|
||||
@@ -206,7 +206,7 @@ readtokens (FILE *stream,
|
||||
lengths[n_tokens] = -1;
|
||||
break;
|
||||
}
|
||||
tmp = (char *) xmalloc ((token_length + 1) * sizeof (char));
|
||||
tmp = xmalloc ((token_length + 1) * sizeof (char));
|
||||
lengths[n_tokens] = token_length;
|
||||
tokens[n_tokens] = strncpy (tmp, token->buffer,
|
||||
(unsigned) (token_length + 1));
|
||||
|
||||
Reference in New Issue
Block a user