Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/mount_qemufwcfg more cleanups, const
details: https://anonhg.NetBSD.org/src/rev/df7722a1559e
branches: trunk
changeset: 357762:df7722a1559e
user: christos <christos%NetBSD.org@localhost>
date: Sun Nov 26 03:51:45 2017 +0000
description:
more cleanups, const
diffstat:
sbin/mount_qemufwcfg/virtdir.c | 26 +++++++++++++-------------
sbin/mount_qemufwcfg/virtdir.h | 10 ++++++----
2 files changed, 19 insertions(+), 17 deletions(-)
diffs (121 lines):
diff -r 545ae69eecf0 -r df7722a1559e sbin/mount_qemufwcfg/virtdir.c
--- a/sbin/mount_qemufwcfg/virtdir.c Sun Nov 26 03:06:24 2017 +0000
+++ b/sbin/mount_qemufwcfg/virtdir.c Sun Nov 26 03:51:45 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: virtdir.c,v 1.2 2017/11/26 03:06:24 christos Exp $ */
+/* $NetBSD: virtdir.c,v 1.3 2017/11/26 03:51:45 christos Exp $ */
/*
* Copyright © 2007 Alistair Crooks. All rights reserved.
@@ -44,8 +44,8 @@
static int
compare(const void *vp1, const void *vp2)
{
- const virt_dirent_t *tp1 = (const virt_dirent_t *) vp1;
- const virt_dirent_t *tp2 = (const virt_dirent_t *) vp2;
+ const virt_dirent_t *tp1 = vp1;
+ const virt_dirent_t *tp2 = vp2;
return strcmp(tp1->name, tp2->name);
}
@@ -60,7 +60,7 @@
(void) strlcpy(name, path, sizeof(name));
for (slash = name + 1 ; (slash = strchr(slash + 1, '/')) != NULL ; ) {
- *slash = 0x0;
+ *slash = '\0';
if ((ep = virtdir_find(tp, name, strlen(name))) == NULL) {
virtdir_add(tp, name, strlen(name), 'd', NULL, 0, 0);
}
@@ -101,7 +101,8 @@
/* initialise the tree */
int
-virtdir_init(virtdir_t *tp, const char *rootdir, struct stat *d, struct stat *f, struct stat *l)
+virtdir_init(virtdir_t *tp, const char *rootdir, const struct stat *d,
+ const struct stat *f, const struct stat *l)
{
tp->dir = *d;
tp->dir.st_mode = S_IFDIR | 0755;
@@ -120,7 +121,8 @@
/* add an entry to the tree */
int
-virtdir_add(virtdir_t *tp, const char *name, size_t size, uint8_t type, const char *tgt, size_t tgtlen, uint16_t select)
+virtdir_add(virtdir_t *tp, const char *name, size_t size, uint8_t type,
+ const char *tgt, size_t tgtlen, uint16_t select)
{
char path[MAXPATHLEN];
size_t pathlen;
@@ -131,13 +133,11 @@
return 0;
}
if (tp->c == tp->size || tp->size == 0) {
- tp->size += 10,
+ tp->size += 10;
tp->v = erealloc(tp->v, tp->size * sizeof(*tp->v));
}
tp->v[tp->c].namelen = pathlen;
- if ((tp->v[tp->c].name = estrndup(path, pathlen)) == NULL) {
- return 0;
- }
+ tp->v[tp->c].name = estrndup(path, pathlen);
tp->v[tp->c].d_name = strrchr(tp->v[tp->c].name, '/') + 1;
tp->v[tp->c].type = type;
tp->v[tp->c].ino = (ino_t) random() & 0xfffff;
@@ -159,7 +159,7 @@
virt_dirent_t e;
char path[MAXPATHLEN];
- (void) memset(&e, 0x0, sizeof(e));
+ (void) memset(&e, 0, sizeof(e));
e.namelen = normalise(name, namelen, path, sizeof(path));
e.name = path;
return bsearch(&e, tp->v, tp->c, sizeof(tp->v[0]), compare);
@@ -167,7 +167,7 @@
/* return the virtual offset in the tree */
off_t
-virtdir_offset(virtdir_t *tp, virt_dirent_t *dp)
+virtdir_offset(const virtdir_t *tp, const virt_dirent_t *dp)
{
return dp - tp->v;
}
@@ -194,7 +194,7 @@
{
char *from;
- for ( ; dirp->i < dirp->tp->c ; dirp->i++) {
+ for ( ; dirp->i < dirp->tp->c; dirp->i++) {
from = (strcmp(dirp->dirname, "/") == 0) ?
&dirp->tp->v[dirp->i].name[1] :
&dirp->tp->v[dirp->i].name[dirp->dirnamelen + 1];
diff -r 545ae69eecf0 -r df7722a1559e sbin/mount_qemufwcfg/virtdir.h
--- a/sbin/mount_qemufwcfg/virtdir.h Sun Nov 26 03:06:24 2017 +0000
+++ b/sbin/mount_qemufwcfg/virtdir.h Sun Nov 26 03:51:45 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: virtdir.h,v 1.2 2017/11/26 03:06:24 christos Exp $ */
+/* $NetBSD: virtdir.h,v 1.3 2017/11/26 03:51:45 christos Exp $ */
/*
* Copyright © 2007 Alistair Crooks. All rights reserved.
@@ -66,14 +66,16 @@
size_t i; /* current offset in dir tree */
} VIRTDIR;
-int virtdir_init(virtdir_t *, const char *, struct stat *, struct stat *, struct stat *);
-int virtdir_add(virtdir_t *, const char *, size_t, uint8_t, const char *, size_t, uint16_t);
+int virtdir_init(virtdir_t *, const char *, const struct stat *,
+ const struct stat *, const struct stat *);
+int virtdir_add(virtdir_t *, const char *, size_t, uint8_t, const char *,
+ size_t, uint16_t);
virt_dirent_t *virtdir_find(virtdir_t *, const char *, size_t);
VIRTDIR *openvirtdir(virtdir_t *, const char *);
virt_dirent_t *readvirtdir(VIRTDIR *);
void closevirtdir(VIRTDIR *);
-off_t virtdir_offset(virtdir_t *, virt_dirent_t *);
+off_t virtdir_offset(const virtdir_t *, const virt_dirent_t *);
#endif
Home |
Main Index |
Thread Index |
Old Index