From 0001b92828417ab48ee4f16f3a76199eff1421a3 Mon Sep 17 00:00:00 2001 From: christos Date: Sun, 28 Dec 2008 01:23:46 +0000 Subject: [PATCH] rename nv_int -> nv_num and make it long long, so that dev_t will fit when we change it. --- usr.bin/config/defs.h | 12 ++++----- usr.bin/config/files.c | 14 +++++----- usr.bin/config/gram.y | 4 +-- usr.bin/config/lint.c | 4 +-- usr.bin/config/main.c | 4 +-- usr.bin/config/mkheaders.c | 12 ++++----- usr.bin/config/mkioconf.c | 6 ++--- usr.bin/config/mkswap.c | 10 +++---- usr.bin/config/sem.c | 53 ++++++++++++++++++++------------------ usr.bin/config/util.c | 6 ++--- 10 files changed, 64 insertions(+), 61 deletions(-) diff --git a/usr.bin/config/defs.h b/usr.bin/config/defs.h index c7d8a35a1cd0..09abe066b1be 100644 --- a/usr.bin/config/defs.h +++ b/usr.bin/config/defs.h @@ -1,4 +1,4 @@ -/* $NetBSD: defs.h,v 1.25 2008/12/21 11:39:56 martin Exp $ */ +/* $NetBSD: defs.h,v 1.26 2008/12/28 01:23:46 christos Exp $ */ /* * Copyright (c) 1992, 1993 @@ -110,7 +110,7 @@ struct nvlist { const char *nv_name; const char *nv_str; void *nv_ptr; - int nv_int; + long long nv_num; int nv_ifunit; /* XXX XXX XXX */ int nv_flags; #define NV_DEPENDED 1 @@ -200,7 +200,7 @@ struct devbase { TAILQ_ENTRY(devbase) d_next; int d_isdef; /* set once properly defined */ int d_ispseudo; /* is a pseudo-device */ - int d_major; /* used for "root on sd0", e.g. */ + dev_t d_major; /* used for "root on sd0", e.g. */ struct nvlist *d_attrs; /* attributes, if any */ int d_umax; /* highest unit number + 1 */ struct devi *d_ihead; /* first instance, if any */ @@ -287,12 +287,12 @@ struct filetype * depending on whether it has names on which to *be* optional. The * options field (fi_optx) is actually an expression tree, with nodes * for OR, AND, and NOT, as well as atoms (words) representing some - * particular option. The node type is stored in the nv_int field. + * particular option. The node type is stored in the nv_num field. * Subexpressions appear in the `next' field; for the binary operators * AND and OR, the left subexpression is first stored in the nv_ptr field. * * For any file marked as needs-count or needs-flag, fixfiles() will - * build fi_optf, a `flat list' of the options with nv_int fields that + * build fi_optf, a `flat list' of the options with nv_num fields that * contain counts or `need' flags; this is used in mkheaders(). */ struct files { @@ -551,7 +551,7 @@ void cfgxerror(const char *, int, const char *, ...) /* delayed errs */ __attribute__((__format__(__printf__, 3, 4))); __dead void panic(const char *, ...) __attribute__((__format__(__printf__, 1, 2))); -struct nvlist *newnv(const char *, const char *, void *, int, struct nvlist *); +struct nvlist *newnv(const char *, const char *, void *, long long, struct nvlist *); void nvfree(struct nvlist *); void nvfreel(struct nvlist *); struct nvlist *nvcat(struct nvlist *, struct nvlist *); diff --git a/usr.bin/config/files.c b/usr.bin/config/files.c index c3209d263957..2cf9e3c8c236 100644 --- a/usr.bin/config/files.c +++ b/usr.bin/config/files.c @@ -1,4 +1,4 @@ -/* $NetBSD: files.c,v 1.7 2007/11/30 23:19:18 dsl Exp $ */ +/* $NetBSD: files.c,v 1.8 2008/12/28 01:23:46 christos Exp $ */ /* * Copyright (c) 1992, 1993 @@ -501,7 +501,7 @@ expr_eval(struct nvlist *expr, int (*fn)(const char *, void *), void *context) { int lhs, rhs; - switch (expr->nv_int) { + switch (expr->nv_num) { case FX_ATOM: return ((*fn)(expr->nv_name, context)); @@ -519,7 +519,7 @@ expr_eval(struct nvlist *expr, int (*fn)(const char *, void *), void *context) rhs = expr_eval(expr->nv_next, fn, context); return (lhs | rhs); } - panic("expr_eval %d", expr->nv_int); + panic("expr_eval %lld", expr->nv_num); /* NOTREACHED */ return (0); } @@ -534,7 +534,7 @@ expr_free(struct nvlist *expr) /* This loop traverses down the RHS of each subexpression. */ for (; expr != NULL; expr = rhs) { - switch (expr->nv_int) { + switch (expr->nv_num) { /* Atoms and !-exprs have no left hand side. */ case FX_ATOM: @@ -548,7 +548,7 @@ expr_free(struct nvlist *expr) break; default: - panic("expr_free %d", expr->nv_int); + panic("expr_free %lld", expr->nv_num); } rhs = expr->nv_next; nvfree(expr); @@ -574,7 +574,7 @@ static void pr0(struct nvlist *e) { - switch (e->nv_int) { + switch (e->nv_num) { case FX_ATOM: printf(" %s", e->nv_name); return; @@ -588,7 +588,7 @@ pr0(struct nvlist *e) printf(" (|"); break; default: - printf(" (?%d?", e->nv_int); + printf(" (?%lld?", e->nv_num); break; } if (e->nv_ptr) diff --git a/usr.bin/config/gram.y b/usr.bin/config/gram.y index 7bead94e652e..010579abbed4 100644 --- a/usr.bin/config/gram.y +++ b/usr.bin/config/gram.y @@ -1,5 +1,5 @@ %{ -/* $NetBSD: gram.y,v 1.17 2008/06/10 18:11:31 drochner Exp $ */ +/* $NetBSD: gram.y,v 1.18 2008/12/28 01:23:46 christos Exp $ */ /* * Copyright (c) 1992, 1993 @@ -725,7 +725,7 @@ mk_nsis(const char *name, int count, struct nvlist *adefs, int opt) *p = new_s("0"); snprintf(buf, sizeof(buf), "%s%c%d", name, ARRCHR, i); (*p)->nv_name = i == 0 ? name : intern(buf); - (*p)->nv_int = i > 0 || opt; + (*p)->nv_num = i > 0 || opt; p = &(*p)->nv_next; } *p = 0; diff --git a/usr.bin/config/lint.c b/usr.bin/config/lint.c index 0cabf7bbc35e..e616b22c0da5 100644 --- a/usr.bin/config/lint.c +++ b/usr.bin/config/lint.c @@ -1,4 +1,4 @@ -/* $NetBSD: lint.c,v 1.6 2008/04/29 06:53:03 martin Exp $ */ +/* $NetBSD: lint.c,v 1.7 2008/12/28 01:23:46 christos Exp $ */ /* * Copyright (c) 2007 The NetBSD Foundation. @@ -130,7 +130,7 @@ do_emit_instances(struct devbase *d, struct attr *at) printf("%s0\tat\t%s?", d->d_name, at->a_name); for (nv = at->a_locs; nv != NULL; nv = nv->nv_next) { - if (nv->nv_int == 0) + if (nv->nv_num == 0) printf(" %s %c", nv->nv_name, nv->nv_str ? '?' : '0'); } diff --git a/usr.bin/config/main.c b/usr.bin/config/main.c index 9ef0c184f5db..b38723d35deb 100644 --- a/usr.bin/config/main.c +++ b/usr.bin/config/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.32 2008/10/20 11:02:18 ad Exp $ */ +/* $NetBSD: main.c,v 1.33 2008/12/28 01:23:46 christos Exp $ */ /* * Copyright (c) 1992, 1993 @@ -1086,7 +1086,7 @@ cfcrosscheck(struct config *cf, const char *what, struct nvlist *nv) if (has_attr(dev->d_attrs, s_ifnet)) devunit = nv->nv_ifunit; /* XXX XXX XXX */ else - devunit = minor((uint32_t)nv->nv_int) / maxpartitions; + devunit = (int)(minor(nv->nv_num) / maxpartitions); if (devbase_has_instances(dev, devunit)) continue; if (devbase_has_instances(dev, STAR) && diff --git a/usr.bin/config/mkheaders.c b/usr.bin/config/mkheaders.c index a0aa5e9baed7..2e48c68fc6c3 100644 --- a/usr.bin/config/mkheaders.c +++ b/usr.bin/config/mkheaders.c @@ -1,4 +1,4 @@ -/* $NetBSD: mkheaders.c,v 1.13 2007/11/09 05:21:30 cube Exp $ */ +/* $NetBSD: mkheaders.c,v 1.14 2008/12/28 01:23:46 christos Exp $ */ /* * Copyright (c) 1992, 1993 @@ -102,7 +102,7 @@ mkheaders(void) } static void -fprint_global(FILE *fp, const char *name, unsigned int value) +fprint_global(FILE *fp, const char *name, long long value) { /* * We have to doubt the founding fathers here. @@ -116,12 +116,12 @@ fprint_global(FILE *fp, const char *name, unsigned int value) fprintf(fp, "#ifdef _LOCORE\n" " .ifndef _KERNEL_OPT_%s\n" " .global _KERNEL_OPT_%s\n" - " .equiv _KERNEL_OPT_%s,0x%x\n" + " .equiv _KERNEL_OPT_%s,0x%llx\n" " .endif\n" "#else\n" "__asm(\" .ifndef _KERNEL_OPT_%s\\n" " .global _KERNEL_OPT_%s\\n" - " .equiv _KERNEL_OPT_%s,0x%x\\n" + " .equiv _KERNEL_OPT_%s,0x%llx\\n" " .endif\");\n" "#endif\n", name, name, name, value, @@ -151,8 +151,8 @@ fprintcnt(FILE *fp, struct nvlist *nv) { const char *name = cntname(nv->nv_name); - fprintf(fp, "#define\t%s\t%d\n", name, nv->nv_int); - fprint_global(fp, name, nv->nv_int); + fprintf(fp, "#define\t%s\t%lld\n", name, nv->nv_num); + fprint_global(fp, name, nv->nv_num); } static int diff --git a/usr.bin/config/mkioconf.c b/usr.bin/config/mkioconf.c index 1132a7b55e3a..95787d4801d6 100644 --- a/usr.bin/config/mkioconf.c +++ b/usr.bin/config/mkioconf.c @@ -1,4 +1,4 @@ -/* $NetBSD: mkioconf.c,v 1.10 2007/12/12 00:03:33 lukem Exp $ */ +/* $NetBSD: mkioconf.c,v 1.11 2008/12/28 01:23:46 christos Exp $ */ /* * Copyright (c) 1992, 1993 @@ -489,8 +489,8 @@ emitname2blk(FILE *fp) if (dev->d_major == NODEV) continue; - fprintf(fp, "\t{ \"%s\", %d },\n", - dev->d_name, dev->d_major); + fprintf(fp, "\t{ \"%s\", %lld },\n", + dev->d_name, (long long)dev->d_major); } fprintf(fp, "\t{ NULL, 0 }\n};\n"); } diff --git a/usr.bin/config/mkswap.c b/usr.bin/config/mkswap.c index b546808d5b6e..fe7153ab9f26 100644 --- a/usr.bin/config/mkswap.c +++ b/usr.bin/config/mkswap.c @@ -1,4 +1,4 @@ -/* $NetBSD: mkswap.c,v 1.5 2008/12/19 17:11:57 pgoyette Exp $ */ +/* $NetBSD: mkswap.c,v 1.6 2008/12/28 01:23:46 christos Exp $ */ /* * Copyright (c) 1992, 1993 @@ -79,8 +79,8 @@ mkdevstr(dev_t d) if (d == NODEV) (void)snprintf(buf, sizeof(buf), "NODEV"); else - (void)snprintf(buf, sizeof(buf), "makedev(%d, %d)", - major(d), minor(d)); + (void)snprintf(buf, sizeof(buf), "makedev(%" PRIi64 ", %" + PRIi64 ")", (int64_t)major(d), (int64_t)minor(d)); return buf; } @@ -114,7 +114,7 @@ mkoneswap(struct config *cf) cf->cf_root->nv_str); fprintf(fp, "const char *rootspec = %s;\n", specinfo); fprintf(fp, "dev_t\trootdev = %s;\t/* %s */\n\n", - mkdevstr(nv->nv_int), + mkdevstr(nv->nv_num), nv->nv_str == s_qmark ? "wildcarded" : nv->nv_str); /* @@ -127,7 +127,7 @@ mkoneswap(struct config *cf) snprintf(specinfo, sizeof(specinfo), "\"%s\"", cf->cf_dump->nv_str); fprintf(fp, "const char *dumpspec = %s;\n", specinfo); fprintf(fp, "dev_t\tdumpdev = %s;\t/* %s */\n\n", - nv ? mkdevstr(nv->nv_int) : "NODEV", + nv ? mkdevstr(nv->nv_num) : "NODEV", nv ? nv->nv_str : "unspecified"); /* diff --git a/usr.bin/config/sem.c b/usr.bin/config/sem.c index 0d096fe10731..21cbccdd7c6c 100644 --- a/usr.bin/config/sem.c +++ b/usr.bin/config/sem.c @@ -1,4 +1,4 @@ -/* $NetBSD: sem.c,v 1.30 2008/07/07 16:10:27 cube Exp $ */ +/* $NetBSD: sem.c,v 1.31 2008/12/28 01:23:46 christos Exp $ */ /* * Copyright (c) 1992, 1993 @@ -83,9 +83,9 @@ static char *extend(char *, const char *); static int split(const char *, size_t, char *, size_t, int *); static void selectbase(struct devbase *, struct deva *); static const char **fixloc(const char *, struct attr *, struct nvlist *); -static const char *makedevstr(int, int); +static const char *makedevstr(dev_t, dev_t); static const char *major2name(int); -static int dev2major(struct devbase *); +static dev_t dev2major(struct devbase *); extern const char *yyfile; extern int vflag; @@ -635,8 +635,8 @@ setmajor(struct devbase *d, int n) { if (d != &errdev && d->d_major != NODEV) - cfgerror("device `%s' is already major %d", - d->d_name, d->d_major); + cfgerror("device `%s' is already major %lld", + d->d_name, (long long)d->d_major); else d->d_major = n; } @@ -661,7 +661,7 @@ major2name(int maj) return (NULL); } -int +dev_t dev2major(struct devbase *dev) { struct devm *dm; @@ -680,17 +680,19 @@ dev2major(struct devbase *dev) * Make a string description of the device at maj/min. */ static const char * -makedevstr(int maj, int min) +makedevstr(dev_t maj, dev_t min) { const char *devicename; char buf[32]; devicename = major2name(maj); if (devicename == NULL) - (void)snprintf(buf, sizeof(buf), "<%d/%d>", maj, min); + (void)snprintf(buf, sizeof(buf), "<%lld/%lld>", + (long long)maj, (long long)min); else - (void)snprintf(buf, sizeof(buf), "%s%d%c", devicename, - min / maxpartitions, (min % maxpartitions) + 'a'); + (void)snprintf(buf, sizeof(buf), "%s%lld%c", devicename, + (long long)min / maxpartitions, + (char)(min % maxpartitions) + 'a'); return (intern(buf)); } @@ -707,7 +709,8 @@ resolve(struct nvlist **nvp, const char *name, const char *what, struct nvlist *nv; struct devbase *dev; const char *cp; - int maj, min, i, l; + dev_t maj, min; + int i, l; int unit; char buf[NAMESIZE]; @@ -719,9 +722,9 @@ resolve(struct nvlist **nvp, const char *name, const char *what, * Apply default. Easiest to do this by number. * Make sure to retain NODEVness, if this is dflt's disposition. */ - if (dflt->nv_int != NODEV) { - maj = major(dflt->nv_int); - min = ((minor(dflt->nv_int) / maxpartitions) * + if (dflt->nv_num != NODEV) { + maj = major(dflt->nv_num); + min = ((minor(dflt->nv_num) / maxpartitions) * maxpartitions) + part; d = makedev(maj, min); cp = makedevstr(maj, min); @@ -729,13 +732,13 @@ resolve(struct nvlist **nvp, const char *name, const char *what, cp = NULL; *nvp = nv = newnv(NULL, cp, NULL, d, NULL); } - if (nv->nv_int != NODEV) { + if (nv->nv_num != NODEV) { /* * By the numbers. Find the appropriate major number * to make a name. */ - maj = major(nv->nv_int); - min = minor(nv->nv_int); + maj = major(nv->nv_num); + min = minor(nv->nv_num); nv->nv_str = makedevstr(maj, min); return (0); } @@ -774,7 +777,7 @@ resolve(struct nvlist **nvp, const char *name, const char *what, * don't bother making a device number. */ if (has_attr(dev->d_attrs, s_ifnet)) { - nv->nv_int = NODEV; + nv->nv_num = NODEV; nv->nv_ifunit = unit; /* XXX XXX XXX */ } else { maj = dev2major(dev); @@ -783,7 +786,7 @@ resolve(struct nvlist **nvp, const char *name, const char *what, name, what, nv->nv_str); return (1); } - nv->nv_int = makedev(maj, unit * maxpartitions + part); + nv->nv_num = makedev(maj, unit * maxpartitions + part); } nv->nv_name = dev->d_name; @@ -1744,18 +1747,18 @@ fixloc(const char *name, struct attr *attr, struct nvlist *got) else lp = emalloc((attr->a_loclen + 1) * sizeof(const char *)); for (n = got; n != NULL; n = n->nv_next) - n->nv_int = -1; + n->nv_num = -1; nmissing = 0; mp = missing; /* yes, this is O(mn), but m and n should be small */ for (ord = 0, m = attr->a_locs; m != NULL; m = m->nv_next, ord++) { for (n = got; n != NULL; n = n->nv_next) { if (n->nv_name == m->nv_name) { - n->nv_int = ord; + n->nv_num = ord; break; } } - if (n == NULL && m->nv_int == 0) { + if (n == NULL && m->nv_num == 0) { nmissing++; mp = extend(mp, m->nv_name); } @@ -1769,10 +1772,10 @@ fixloc(const char *name, struct attr *attr, struct nvlist *got) nnodefault = 0; ndp = nodefault; for (n = got; n != NULL; n = n->nv_next) { - if (n->nv_int >= 0) { + if (n->nv_num >= 0) { if (n->nv_str != NULL) - lp[n->nv_int] = n->nv_str; - else if (lp[n->nv_int] == NULL) { + lp[n->nv_num] = n->nv_str; + else if (lp[n->nv_num] == NULL) { nnodefault++; ndp = extend(ndp, n->nv_name); } diff --git a/usr.bin/config/util.c b/usr.bin/config/util.c index b065fcc4701a..7ba97b81af2f 100644 --- a/usr.bin/config/util.c +++ b/usr.bin/config/util.c @@ -1,4 +1,4 @@ -/* $NetBSD: util.c,v 1.7 2007/12/12 00:03:34 lukem Exp $ */ +/* $NetBSD: util.c,v 1.8 2008/12/28 01:23:46 christos Exp $ */ /* * Copyright (c) 1992, 1993 @@ -136,7 +136,7 @@ sourcepath(const char *file) } struct nvlist * -newnv(const char *name, const char *str, void *ptr, int i, struct nvlist *next) +newnv(const char *name, const char *str, void *ptr, long long i, struct nvlist *next) { struct nvlist *nv; @@ -145,7 +145,7 @@ newnv(const char *name, const char *str, void *ptr, int i, struct nvlist *next) nv->nv_name = name; nv->nv_str = str; nv->nv_ptr = ptr; - nv->nv_int = i; + nv->nv_num = i; return nv; }