summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Mierswa2009-08-17 07:27:39 +0200
committerKarel Zak2009-08-17 11:15:59 +0200
commitc0f19ccff73aa0ec5e9f3b61b932ea4a8bf4e6ed (patch)
tree6d4671545542031f67face36783f8ad64b29057c
parentlibblkid: fix cache->probe memory leak (diff)
downloadkernel-qcow2-util-linux-c0f19ccff73aa0ec5e9f3b61b932ea4a8bf4e6ed.tar.gz
kernel-qcow2-util-linux-c0f19ccff73aa0ec5e9f3b61b932ea4a8bf4e6ed.tar.xz
kernel-qcow2-util-linux-c0f19ccff73aa0ec5e9f3b61b932ea4a8bf4e6ed.zip
replace bcopy,bzero,index and rindex
Those 4 functions are marked as LEGACY in POSIX.1-2001 and removed in POSIX.1-2008. Replaced with memmove,memset,strchr and strrchr. Signed-off-by: Daniel Mierswa <impulze@impulze.org>
-rw-r--r--fdisk/cfdisk.c2
-rw-r--r--fdisk/fdiskbsdlabel.c13
-rw-r--r--fdisk/sfdisk.c10
-rw-r--r--login-utils/login.c6
-rw-r--r--login-utils/shutdown.c2
-rw-r--r--login-utils/ttymsg.c2
-rw-r--r--login-utils/vipw.c4
-rw-r--r--login-utils/wall.c2
-rw-r--r--misc-utils/logger.c2
-rw-r--r--misc-utils/whereis.c4
-rw-r--r--mount/mount.c4
-rw-r--r--mount/mount_mntent.c4
-rw-r--r--mount/sundries.c2
-rw-r--r--partx/partx.c2
-rw-r--r--shlibs/blkid/src/config.c4
-rw-r--r--text-utils/colcrt.c4
-rw-r--r--text-utils/display.c2
-rw-r--r--text-utils/parse.c8
-rw-r--r--text-utils/ul.c2
19 files changed, 40 insertions, 39 deletions
diff --git a/fdisk/cfdisk.c b/fdisk/cfdisk.c
index fc0357d2d..1846e11cc 100644
--- a/fdisk/cfdisk.c
+++ b/fdisk/cfdisk.c
@@ -357,7 +357,7 @@ xmalloc (size_t size) {
/* Some libc's have their own basename() */
static char *
my_basename(char *devname) {
- char *s = rindex(devname, '/');
+ char *s = strrchr(devname, '/');
return s ? s+1 : devname;
}
diff --git a/fdisk/fdiskbsdlabel.c b/fdisk/fdiskbsdlabel.c
index 377b64ec4..d5243b9e9 100644
--- a/fdisk/fdiskbsdlabel.c
+++ b/fdisk/fdiskbsdlabel.c
@@ -538,7 +538,7 @@ xbsd_write_bootstrap (void)
/* We need a backup of the disklabel (xbsd_dlabel might have changed). */
d = &disklabelbuffer[BSD_LABELSECTOR * SECTOR_SIZE];
- bcopy (d, &dl, sizeof (struct xbsd_disklabel));
+ memmove (&dl, d, sizeof (struct xbsd_disklabel));
/* The disklabel will be overwritten by 0's from bootxx anyway */
bzero (d, sizeof (struct xbsd_disklabel));
@@ -555,7 +555,7 @@ xbsd_write_bootstrap (void)
exit ( EXIT_FAILURE );
}
- bcopy (&dl, d, sizeof (struct xbsd_disklabel));
+ memmove (d, &dl, sizeof (struct xbsd_disklabel));
#if defined (__powerpc__) || defined (__hppa__)
sector = 0;
@@ -740,8 +740,9 @@ xbsd_readlabel (struct partition *p, struct xbsd_disklabel *d)
if (BSD_BBSIZE != read (fd, disklabelbuffer, BSD_BBSIZE))
fatal (unable_to_read);
- bcopy (&disklabelbuffer[BSD_LABELSECTOR * SECTOR_SIZE + BSD_LABELOFFSET],
- d, sizeof (struct xbsd_disklabel));
+ memmove (d,
+ &disklabelbuffer[BSD_LABELSECTOR * SECTOR_SIZE + BSD_LABELOFFSET],
+ sizeof (struct xbsd_disklabel));
if (d -> d_magic != BSD_DISKMAGIC || d -> d_magic2 != BSD_DISKMAGIC)
return 0;
@@ -776,8 +777,8 @@ xbsd_writelabel (struct partition *p, struct xbsd_disklabel *d)
/* This is necessary if we want to write the bootstrap later,
otherwise we'd write the old disklabel with the bootstrap.
*/
- bcopy (d, &disklabelbuffer[BSD_LABELSECTOR * SECTOR_SIZE + BSD_LABELOFFSET],
- sizeof (struct xbsd_disklabel));
+ memmove (&disklabelbuffer[BSD_LABELSECTOR * SECTOR_SIZE + BSD_LABELOFFSET], d,
+ sizeof (struct xbsd_disklabel));
#if defined (__alpha__) && BSD_LABELSECTOR == 0
alpha_bootblock_checksum (disklabelbuffer);
diff --git a/fdisk/sfdisk.c b/fdisk/sfdisk.c
index da779aa89..8fae5bb54 100644
--- a/fdisk/sfdisk.c
+++ b/fdisk/sfdisk.c
@@ -40,7 +40,7 @@
#include <unistd.h> /* read, write */
#include <fcntl.h> /* O_RDWR */
#include <errno.h> /* ERANGE */
-#include <string.h> /* index() */
+#include <string.h> /* strchr(), strrchr() */
#include <ctype.h>
#include <getopt.h>
#include <sys/ioctl.h>
@@ -1725,12 +1725,12 @@ read_stdin(char **fields, char *line, int fieldssize, int linesize) {
eof = 1;
return RD_EOF;
}
- if (!(lp = index(lp, '\n')))
+ if (!(lp = strchr(lp, '\n')))
fatal(_("long or incomplete input line - quitting\n"));
*lp = 0;
/* remove comments, if any */
- if ((lp = index(line+2, '#')) != 0)
+ if ((lp = strchr(line+2, '#')) != 0)
*lp = 0;
/* recognize a few commands - to be expanded */
@@ -1740,7 +1740,7 @@ read_stdin(char **fields, char *line, int fieldssize, int linesize) {
}
/* dump style? - then bad input is fatal */
- if ((ip = index(line+2, ':')) != 0) {
+ if ((ip = strchr(line+2, ':')) != 0) {
struct dumpfld *d;
nxtfld:
@@ -2503,7 +2503,7 @@ main(int argc, char **argv) {
if (argc < 1)
fatal(_("no command?\n"));
- if ((progn = rindex(argv[0], '/')) == NULL)
+ if ((progn = strrchr(argv[0], '/')) == NULL)
progn = argv[0];
else
progn++;
diff --git a/login-utils/login.c b/login-utils/login.c
index 7328edeb9..486b30bf0 100644
--- a/login-utils/login.c
+++ b/login-utils/login.c
@@ -418,7 +418,7 @@ main(int argc, char **argv)
*/
gethostname(tbuf, sizeof(tbuf));
xstrncpy(thishost, tbuf, sizeof(thishost));
- domain = index(tbuf, '.');
+ domain = strchr(tbuf, '.');
username = tty_name = hostname = NULL;
fflag = hflag = pflag = 0;
@@ -437,7 +437,7 @@ main(int argc, char **argv)
exit(1);
}
hflag = 1;
- if (domain && (p = index(optarg, '.')) &&
+ if (domain && (p = strchr(optarg, '.')) &&
strcasecmp(p, domain) == 0)
*p = 0;
@@ -1251,7 +1251,7 @@ Michael Riepe <michael@stud.uni-hannover.de>
childArgv[childArgc++] = buff;
} else {
tbuf[0] = '-';
- xstrncpy(tbuf + 1, ((p = rindex(pwd->pw_shell, '/')) ?
+ xstrncpy(tbuf + 1, ((p = strrchr(pwd->pw_shell, '/')) ?
p + 1 : pwd->pw_shell),
sizeof(tbuf)-1);
diff --git a/login-utils/shutdown.c b/login-utils/shutdown.c
index f798e5812..58600b9d8 100644
--- a/login-utils/shutdown.c
+++ b/login-utils/shutdown.c
@@ -281,7 +281,7 @@ main(int argc, char *argv[])
if (fgets (line, sizeof(line), fp) != NULL &&
strncasecmp (line, "HALT_ACTION", 11) == 0 &&
iswhitespace(line[11])) {
- p = index(line, '\n');
+ p = strchr(line, '\n');
if (p)
*p = 0; /* strip final '\n' */
p = line+11;
diff --git a/login-utils/ttymsg.c b/login-utils/ttymsg.c
index 24b74bcbc..92282c127 100644
--- a/login-utils/ttymsg.c
+++ b/login-utils/ttymsg.c
@@ -111,7 +111,7 @@ ttymsg(struct iovec *iov, int iovcnt, char *line, int tmout) {
if (wret >= 0) {
left -= wret;
if (iov != localiov) {
- bcopy(iov, localiov,
+ memmove(localiov, iov,
iovcnt * sizeof(struct iovec));
iov = localiov;
}
diff --git a/login-utils/vipw.c b/login-utils/vipw.c
index 5f4472111..b3972f3b3 100644
--- a/login-utils/vipw.c
+++ b/login-utils/vipw.c
@@ -311,8 +311,8 @@ int main(int argc, char *argv[]) {
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- bzero(tmp_file, FILENAMELEN);
- progname = (rindex(argv[0], '/')) ? rindex(argv[0], '/') + 1 : argv[0];
+ memset(tmp_file, '\0', FILENAMELEN);
+ progname = (strrchr(argv[0], '/')) ? strrchr(argv[0], '/') + 1 : argv[0];
if (!strcmp(progname, "vigr")) {
program = VIGR;
xstrncpy(orig_file, GROUP_FILE, sizeof(orig_file));
diff --git a/login-utils/wall.c b/login-utils/wall.c
index 42856ae38..7b5f6718f 100644
--- a/login-utils/wall.c
+++ b/login-utils/wall.c
@@ -95,7 +95,7 @@ main(int argc, char **argv) {
textdomain(PACKAGE);
progname = argv[0];
- p = rindex(progname, '/');
+ p = strrchr(progname, '/');
if (p)
progname = p+1;
diff --git a/misc-utils/logger.c b/misc-utils/logger.c
index 72a8f85e8..95050a1b3 100644
--- a/misc-utils/logger.c
+++ b/misc-utils/logger.c
@@ -196,7 +196,7 @@ main(int argc, char **argv) {
} else {
if (p != buf)
*p++ = ' ';
- bcopy(*argv++, p, len);
+ memmove(p, *argv++, len);
*(p += len) = '\0';
}
}
diff --git a/misc-utils/whereis.c b/misc-utils/whereis.c
index 71ee6835c..931ff77b5 100644
--- a/misc-utils/whereis.c
+++ b/misc-utils/whereis.c
@@ -325,14 +325,14 @@ findin(char *dir, char *cp) {
char dirbuf[1024];
struct stat statbuf;
- dd = index(dir, '*');
+ dd = strchr(dir, '*');
if (!dd)
goto noglob;
l = strlen(dir);
if (l < sizeof(dirbuf)) { /* refuse excessively long names */
strcpy (dirbuf, dir);
- d = index(dirbuf, '*');
+ d = strchr(dirbuf, '*');
*d = 0;
dirp = opendir(dirbuf);
if (dirp == NULL)
diff --git a/mount/mount.c b/mount/mount.c
index ef478c793..e8cb54992 100644
--- a/mount/mount.c
+++ b/mount/mount.c
@@ -911,11 +911,11 @@ guess_fstype_and_mount(const char *spec, const char *node, const char **types,
/* Accept a comma-separated list of types, and try them one by one */
/* A list like "nonfs,.." indicates types not to use */
- if (*types && strncmp(*types, "no", 2) && index(*types,',')) {
+ if (*types && strncmp(*types, "no", 2) && strchr(*types,',')) {
char *t = strdup(*types);
char *p;
- while((p = index(t,',')) != NULL) {
+ while((p = strchr(t,',')) != NULL) {
*p = 0;
args.type = *types = t;
if (do_mount (&args, special, status) == 0)
diff --git a/mount/mount_mntent.c b/mount/mount_mntent.c
index e6e64bbc8..f2623fd57 100644
--- a/mount/mount_mntent.c
+++ b/mount/mount_mntent.c
@@ -157,7 +157,7 @@ my_getmntent (mntFILE *mfp) {
return NULL;
mfp->mntent_lineno++;
- s = index (buf, '\n');
+ s = strchr (buf, '\n');
if (s == NULL) {
/* Missing final newline? Otherwise extremely */
/* long line - assume file was corrupted */
@@ -165,7 +165,7 @@ my_getmntent (mntFILE *mfp) {
fprintf(stderr, _("[mntent]: warning: no final "
"newline at the end of %s\n"),
mfp->mntent_file);
- s = index (buf, 0);
+ s = strchr (buf, 0);
} else {
mfp->mntent_errs = 1;
goto err;
diff --git a/mount/sundries.c b/mount/sundries.c
index 3980f81ad..658eec52e 100644
--- a/mount/sundries.c
+++ b/mount/sundries.c
@@ -157,7 +157,7 @@ matching_type (const char *type, const char *types) {
if (strncmp(p, type, len) == 0 &&
(p[len] == 0 || p[len] == ','))
return !no;
- p = index(p,',');
+ p = strchr(p,',');
if (!p)
break;
p++;
diff --git a/partx/partx.c b/partx/partx.c
index 86507422a..25485fff2 100644
--- a/partx/partx.c
+++ b/partx/partx.c
@@ -131,7 +131,7 @@ main(int argc, char **argv){
case 'n':
p = optarg;
lower = atoi(p);
- p = index(p, '-');
+ p = strchr(p, '-');
if (p)
upper = atoi(p+1);
else
diff --git a/shlibs/blkid/src/config.c b/shlibs/blkid/src/config.c
index 9091736be..fcc7b6f12 100644
--- a/shlibs/blkid/src/config.c
+++ b/shlibs/blkid/src/config.c
@@ -68,12 +68,12 @@ static int parse_next(FILE *fd, struct blkid_config *conf)
do {
if (fgets (buf, sizeof(buf), fd) == NULL)
return feof(fd) ? 0 : -1;
- s = index (buf, '\n');
+ s = strchr (buf, '\n');
if (!s) {
/* Missing final newline? Otherwise extremely */
/* long line - assume file was corrupted */
if (feof(fd))
- s = index (buf, '\0');
+ s = strchr (buf, '\0');
else {
DBG(DEBUG_CONFIG, fprintf(stderr,
"libblkid: config file: missing newline at line '%s'.\n",
diff --git a/text-utils/colcrt.c b/text-utils/colcrt.c
index 891fd86db..6f796656d 100644
--- a/text-utils/colcrt.c
+++ b/text-utils/colcrt.c
@@ -252,8 +252,8 @@ void pflush(int ol)
}
putwchar('\n');
}
- bcopy(page[ol], page, (267 - ol) * 132 * sizeof(wchar_t));
- bzero(page[267- ol], ol * 132 * sizeof(wchar_t));
+ memmove(page, page[ol], (267 - ol) * 132 * sizeof(wchar_t));
+ memset(page[267- ol], '\0', ol * 132 * sizeof(wchar_t));
outline -= ol;
outcol = 0;
first = 1;
diff --git a/text-utils/display.c b/text-utils/display.c
index 3d4bdcd98..91857c2fa 100644
--- a/text-utils/display.c
+++ b/text-utils/display.c
@@ -163,7 +163,7 @@ static void bpad(PR *pr)
pr->cchar[0] = 's';
pr->cchar[1] = 0;
for (p1 = pr->fmt; *p1 != '%'; ++p1);
- for (p2 = ++p1; *p1 && index(spec, *p1); ++p1);
+ for (p2 = ++p1; *p1 && strchr(spec, *p1); ++p1);
while ((*p2++ = *p1++) != 0) ;
}
diff --git a/text-utils/parse.c b/text-utils/parse.c
index d7a302082..8164c601c 100644
--- a/text-utils/parse.c
+++ b/text-utils/parse.c
@@ -64,7 +64,7 @@ void addfile(char *name)
exit(1);
}
while (fgets(buf, sizeof(buf), fp)) {
- if ((p = index(buf, '\n')) == NULL) {
+ if ((p = strchr(buf, '\n')) == NULL) {
(void)fprintf(stderr, _("hexdump: line too long.\n"));
while ((ch = getchar()) != '\n' && ch != EOF);
continue;
@@ -171,7 +171,7 @@ int size(FS *fs)
* skip any special chars -- save precision in
* case it's a %s format.
*/
- while (index(spec + 1, *++fmt));
+ while (strchr(spec + 1, *++fmt));
if (*fmt == '.' && isdigit((unsigned char)*++fmt)) {
prec = atoi(fmt);
while (isdigit((unsigned char)*++fmt));
@@ -244,10 +244,10 @@ void rewrite(FS *fs)
if (fu->bcnt) {
sokay = USEBCNT;
/* skip to conversion character */
- for (++p1; index(spec, *p1); ++p1);
+ for (++p1; strchr(spec, *p1); ++p1);
} else {
/* skip any special chars, field width */
- while (index(spec + 1, *++p1));
+ while (strchr(spec + 1, *++p1));
if (*p1 == '.' &&
isdigit((unsigned char)*++p1)) {
sokay = USEPREC;
diff --git a/text-utils/ul.c b/text-utils/ul.c
index 76c0a9703..a1491b846 100644
--- a/text-utils/ul.c
+++ b/text-utils/ul.c
@@ -42,7 +42,7 @@
#include <stdio.h>
#include <unistd.h> /* for getopt(), isatty() */
-#include <string.h> /* for bzero(), strcpy() */
+#include <string.h> /* for memset(), strcpy() */
#include <term.h> /* for setupterm() */
#include <stdlib.h> /* for getenv() */
#include <limits.h> /* for INT_MAX */