diff --git a/sys/geom/geom.h b/sys/geom/geom.h index ec668a26a452..028e57d8bbb3 100644 --- a/sys/geom/geom.h +++ b/sys/geom/geom.h @@ -75,7 +75,7 @@ typedef void g_orphan_t (struct g_consumer *); typedef void g_start_t (struct bio *); typedef void g_spoiled_t (struct g_consumer *); -typedef void g_dumpconf_t (struct sbuf *, char *indent, struct g_geom *, +typedef void g_dumpconf_t (struct sbuf *, const char *indent, struct g_geom *, struct g_consumer *, struct g_provider *); /* @@ -86,7 +86,7 @@ typedef void g_dumpconf_t (struct sbuf *, char *indent, struct g_geom *, * taste and config_geom functions. */ struct g_class { - char *name; + const char *name; g_taste_t *taste; g_config_t *config; /* @@ -167,7 +167,7 @@ struct g_provider { int error; struct g_event *event; TAILQ_ENTRY(g_provider) orphan; - int index; + u_int index; off_t mediasize; u_int sectorsize; }; @@ -197,7 +197,7 @@ int g_dev_print(void); /* geom_dump.c */ void g_hexdump(void *ptr, int length); -void g_trace(int level, char *, ...); +void g_trace(int level, const char *, ...); # define G_T_TOPOLOGY 1 # define G_T_BIO 2 # define G_T_ACCESS 4 @@ -222,13 +222,13 @@ void g_detach(struct g_consumer *cp); void g_error_provider(struct g_provider *pp, int error); int g_getattr__(const char *attr, struct g_consumer *cp, void *var, int len); #define g_getattr(a, c, v) g_getattr__((a), (c), (v), sizeof *(v)) -int g_handleattr(struct bio *bp, char *attribute, void *val, int len); -int g_handleattr_int(struct bio *bp, char *attribute, int val); -int g_handleattr_off_t(struct bio *bp, char *attribute, off_t val); -struct g_geom * g_insert_geom(char *class, struct g_consumer *cp); +int g_handleattr(struct bio *bp, const char *attribute, void *val, int len); +int g_handleattr_int(struct bio *bp, const char *attribute, int val); +int g_handleattr_off_t(struct bio *bp, const char *attribute, off_t val); +struct g_geom * g_insert_geom(const char *class, struct g_consumer *cp); struct g_consumer * g_new_consumer(struct g_geom *gp); -struct g_geom * g_new_geomf(struct g_class *mp, char *fmt, ...); -struct g_provider * g_new_providerf(struct g_geom *gp, char *fmt, ...); +struct g_geom * g_new_geomf(struct g_class *mp, const char *fmt, ...); +struct g_provider * g_new_providerf(struct g_geom *gp, const char *fmt, ...); void g_sanity(void *ptr); void g_spoil(struct g_provider *pp, struct g_consumer *cp); int g_std_access(struct g_provider *pp, int dr, int dw, int de); diff --git a/sys/geom/geom_aes.c b/sys/geom/geom_aes.c index fae7f3485464..72f0d3dcc56f 100644 --- a/sys/geom/geom_aes.c +++ b/sys/geom/geom_aes.c @@ -70,9 +70,9 @@ #define MASTER_KEY_LENGTH (1024/8) -static u_char *aes_magic = "<>"; -static u_char *aes_magic_random = "<>"; -static u_char *aes_magic_test = "<>"; +static const u_char *aes_magic = "<>"; +static const u_char *aes_magic_random = "<>"; +static const u_char *aes_magic_test = "<>"; struct g_aes_softc { diff --git a/sys/geom/geom_bsd.c b/sys/geom/geom_bsd.c index a711bbc79ea1..7d51896958a3 100644 --- a/sys/geom/geom_bsd.c +++ b/sys/geom/geom_bsd.c @@ -316,7 +316,7 @@ g_bsd_modify(struct g_geom *gp, struct disklabel *dl) struct partition *ppp; struct g_slicer *gsp; struct g_consumer *cp; - u_int secsize; + u_int secsize, u; off_t mediasize; /* Basic check that this is indeed a disklabel. */ @@ -385,13 +385,13 @@ g_bsd_modify(struct g_geom *gp, struct disklabel *dl) } /* Look good, go for it... */ - for (i = 0; i < gsp->nslice; i++) { - ppp = &dl->d_partitions[i]; - g_slice_config(gp, i, G_SLICE_CONFIG_SET, + for (u = 0; u < gsp->nslice; u++) { + ppp = &dl->d_partitions[u]; + g_slice_config(gp, u, G_SLICE_CONFIG_SET, (off_t)ppp->p_offset * dl->d_secsize, (off_t)ppp->p_size * dl->d_secsize, dl->d_secsize, - "%s%c", gp->name, 'a' + i); + "%s%c", gp->name, 'a' + u); } return (0); } @@ -566,7 +566,7 @@ g_bsd_hotwrite(void *arg) gsp = gp->softc; ms = gsp->softc; gsl = &gsp->slices[bp->bio_to->index]; - p = bp->bio_data + ms->labeloffset + p = (u_char*)bp->bio_data + ms->labeloffset - (bp->bio_offset + gsl->offset); g_bsd_ledec_disklabel(p, &fake.ondisk); @@ -675,7 +675,7 @@ g_bsd_start(struct bio *bp) * consumer and provider. We let g_slice_dumpconf() do most of the work. */ static void -g_bsd_dumpconf(struct sbuf *sb, char *indent, struct g_geom *gp, struct g_consumer *cp, struct g_provider *pp) +g_bsd_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp, struct g_consumer *cp, struct g_provider *pp) { struct g_bsd_softc *ms; struct g_slicer *gsp; diff --git a/sys/geom/geom_disk.c b/sys/geom/geom_disk.c index 0379fabd73e5..ddfb19385880 100644 --- a/sys/geom/geom_disk.c +++ b/sys/geom/geom_disk.c @@ -203,7 +203,7 @@ g_disk_start(struct bio *bp) } static void -g_disk_dumpconf(struct sbuf *sb, char *indent, struct g_geom *gp, struct g_consumer *cp, struct g_provider *pp) +g_disk_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp, struct g_consumer *cp, struct g_provider *pp) { struct disk *dp; diff --git a/sys/geom/geom_dump.c b/sys/geom/geom_dump.c index 95a9ffd9d239..f65803cc9b39 100644 --- a/sys/geom/geom_dump.c +++ b/sys/geom/geom_dump.c @@ -273,7 +273,7 @@ g_confxml(void *p) } void -g_trace(int level, char *fmt, ...) +g_trace(int level, const char *fmt, ...) { va_list ap; diff --git a/sys/geom/geom_mbr.c b/sys/geom/geom_mbr.c index 30e7f54ad192..f18d0d848a2c 100644 --- a/sys/geom/geom_mbr.c +++ b/sys/geom/geom_mbr.c @@ -103,25 +103,25 @@ g_mbr_start(struct bio *bp) struct g_geom *gp; struct g_mbr_softc *mp; struct g_slicer *gsp; - int index; + int idx; pp = bp->bio_to; - index = pp->index; + idx = pp->index; gp = pp->geom; gsp = gp->softc; mp = gsp->softc; if (bp->bio_cmd == BIO_GETATTR) { - if (g_handleattr_int(bp, "MBR::type", mp->type[index])) + if (g_handleattr_int(bp, "MBR::type", mp->type[idx])) return (1); if (g_handleattr_off_t(bp, "MBR::offset", - gsp->slices[index].offset)) + gsp->slices[idx].offset)) return (1); } return (0); } static void -g_mbr_dumpconf(struct sbuf *sb, char *indent, struct g_geom *gp, struct g_consumer *cp __unused, struct g_provider *pp) +g_mbr_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp, struct g_consumer *cp __unused, struct g_provider *pp) { struct g_mbr_softc *mp; struct g_slicer *gsp; @@ -289,22 +289,22 @@ g_mbrext_start(struct bio *bp) struct g_geom *gp; struct g_mbrext_softc *mp; struct g_slicer *gsp; - int index; + int idx; pp = bp->bio_to; - index = pp->index; + idx = pp->index; gp = pp->geom; gsp = gp->softc; mp = gsp->softc; if (bp->bio_cmd == BIO_GETATTR) { - if (g_handleattr_int(bp, "MBR::type", mp->type[index])) + if (g_handleattr_int(bp, "MBR::type", mp->type[idx])) return (1); } return (0); } static void -g_mbrext_dumpconf(struct sbuf *sb, char *indent, struct g_geom *gp, struct g_consumer *cp __unused, struct g_provider *pp) +g_mbrext_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp, struct g_consumer *cp __unused, struct g_provider *pp) { struct g_mbrext_softc *mp; struct g_slicer *gsp; diff --git a/sys/geom/geom_pc98.c b/sys/geom/geom_pc98.c index ebb2ecff5128..8b3873f354e7 100644 --- a/sys/geom/geom_pc98.c +++ b/sys/geom/geom_pc98.c @@ -57,7 +57,7 @@ static void g_dec_dos_partition(u_char *ptr, struct dos_partition *d) { - int i; + u_int u; d->dp_mid = ptr[0]; d->dp_sid = ptr[1]; @@ -72,8 +72,8 @@ g_dec_dos_partition(u_char *ptr, struct dos_partition *d) d->dp_esect = ptr[12]; d->dp_ehd = ptr[13]; d->dp_ecyl = g_dec_le2(ptr + 14); - for (i = 0; i < sizeof(d->dp_name); i++) - d->dp_name[i] = ptr[16 + i]; + for (u = 0; u < sizeof(d->dp_name); u++) + d->dp_name[u] = ptr[16 + u]; } struct g_pc98_softc { @@ -88,25 +88,25 @@ g_pc98_start(struct bio *bp) struct g_geom *gp; struct g_pc98_softc *mp; struct g_slicer *gsp; - int index; + int idx; pp = bp->bio_to; - index = pp->index; + idx = pp->index; gp = pp->geom; gsp = gp->softc; mp = gsp->softc; if (bp->bio_cmd == BIO_GETATTR) { - if (g_handleattr_int(bp, "PC98::type", mp->type[index])) + if (g_handleattr_int(bp, "PC98::type", mp->type[idx])) return (1); if (g_handleattr_off_t(bp, "PC98::offset", - gsp->slices[index].offset)) + gsp->slices[idx].offset)) return (1); } return (0); } static void -g_pc98_dumpconf(struct sbuf *sb, char *indent, struct g_geom *gp, +g_pc98_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp, struct g_consumer *cp __unused, struct g_provider *pp) { struct g_pc98_softc *mp; diff --git a/sys/geom/geom_slice.c b/sys/geom/geom_slice.c index 82df9fb99e78..cbe3749524e2 100644 --- a/sys/geom/geom_slice.c +++ b/sys/geom/geom_slice.c @@ -82,7 +82,8 @@ g_slice_init(unsigned nslice, unsigned scsize) static int g_slice_access(struct g_provider *pp, int dr, int dw, int de) { - int error, i; + int error; + u_int u; struct g_geom *gp; struct g_consumer *cp; struct g_provider *pp2; @@ -94,11 +95,11 @@ g_slice_access(struct g_provider *pp, int dr, int dw, int de) KASSERT (cp != NULL, ("g_slice_access but no consumer")); gsp = gp->softc; gsl = &gsp->slices[pp->index]; - for (i = 0; i < gsp->nslice; i++) { - gsl2 = &gsp->slices[i]; + for (u = 0; u < gsp->nslice; u++) { + gsl2 = &gsp->slices[u]; if (gsl2->length == 0) continue; - if (i == pp->index) + if (u == pp->index) continue; if (gsl->offset + gsl->length <= gsl2->offset) continue; @@ -129,7 +130,7 @@ g_slice_finish_hot(struct bio *bp) struct g_consumer *cp; struct g_slicer *gsp; struct g_slice *gsl; - int index; + int idx; KASSERT(bp->bio_to != NULL, ("NULL bio_to in g_slice_finish_hot(%p)", bp)); KASSERT(bp->bio_from != NULL, ("NULL bio_from in g_slice_finish_hot(%p)", bp)); @@ -137,8 +138,8 @@ g_slice_finish_hot(struct bio *bp) gsp = gp->softc; cp = LIST_FIRST(&gp->consumer); KASSERT(cp != NULL, ("NULL consumer in g_slice_finish_hot(%p)", bp)); - index = bp->bio_to->index; - gsl = &gsp->slices[index]; + idx = bp->bio_to->index; + gsl = &gsp->slices[idx]; bp2 = g_clone_bio(bp); if (bp2 == NULL) { @@ -162,7 +163,7 @@ g_slice_start(struct bio *bp) struct g_consumer *cp; struct g_slicer *gsp; struct g_slice *gsl, *gmp; - int index, error; + int idx, error; u_int m_index; off_t t; @@ -170,8 +171,8 @@ g_slice_start(struct bio *bp) gp = pp->geom; gsp = gp->softc; cp = LIST_FIRST(&gp->consumer); - index = pp->index; - gsl = &gsp->slices[index]; + idx = pp->index; + gsl = &gsp->slices[idx]; switch(bp->bio_cmd) { case BIO_READ: case BIO_WRITE: @@ -233,9 +234,9 @@ g_slice_start(struct bio *bp) struct g_kerneldump *gkd; gkd = (struct g_kerneldump *)bp->bio_data; - gkd->offset += gsp->slices[index].offset; - if (gkd->length > gsp->slices[index].length) - gkd->length = gsp->slices[index].length; + gkd->offset += gsp->slices[idx].offset; + if (gkd->length > gsp->slices[idx].length) + gkd->length = gsp->slices[idx].length; /* now, pass it on downwards... */ } #endif @@ -254,7 +255,7 @@ g_slice_start(struct bio *bp) } void -g_slice_dumpconf(struct sbuf *sb, char *indent, struct g_geom *gp, struct g_consumer *cp, struct g_provider *pp) +g_slice_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp, struct g_consumer *cp, struct g_provider *pp) { struct g_slicer *gsp; @@ -283,7 +284,7 @@ g_slice_dumpconf(struct sbuf *sb, char *indent, struct g_geom *gp, struct g_cons } int -g_slice_config(struct g_geom *gp, u_int index, int how, off_t offset, off_t length, u_int sectorsize, char *fmt, ...) +g_slice_config(struct g_geom *gp, u_int idx, int how, off_t offset, off_t length, u_int sectorsize, const char *fmt, ...) { struct g_provider *pp; struct g_slicer *gsp; @@ -293,13 +294,13 @@ g_slice_config(struct g_geom *gp, u_int index, int how, off_t offset, off_t leng int error, acc; g_trace(G_T_TOPOLOGY, "g_slice_config(%s, %d, %d)", - gp->name, index, how); + gp->name, idx, how); g_topology_assert(); gsp = gp->softc; error = 0; - if (index >= gsp->nslice) + if (idx >= gsp->nslice) return(EINVAL); - gsl = &gsp->slices[index]; + gsl = &gsp->slices[idx]; pp = gsl->provider; if (pp != NULL) acc = pp->acr + pp->acw + pp->ace; @@ -344,7 +345,7 @@ g_slice_config(struct g_geom *gp, u_int index, int how, off_t offset, off_t leng printf("GEOM: Configure %s, start %jd length %jd end %jd\n", pp->name, (intmax_t)offset, (intmax_t)length, (intmax_t)(offset + length - 1)); - pp->index = index; + pp->index = idx; pp->mediasize = gsl->length; pp->sectorsize = gsl->sectorsize; gsl->provider = pp; @@ -355,7 +356,7 @@ g_slice_config(struct g_geom *gp, u_int index, int how, off_t offset, off_t leng } int -g_slice_conf_hot(struct g_geom *gp, u_int index, off_t offset, off_t length) +g_slice_conf_hot(struct g_geom *gp, u_int idx, off_t offset, off_t length) { struct g_slicer *gsp; struct g_slice *gsl, *gsl2; @@ -364,27 +365,27 @@ g_slice_conf_hot(struct g_geom *gp, u_int index, off_t offset, off_t length) g_topology_assert(); gsp = gp->softc; gsl = gsp->hot; - if(index >= gsp->nhot) { - gsl2 = g_malloc((index + 1) * sizeof *gsl2, M_WAITOK | M_ZERO); + if(idx >= gsp->nhot) { + gsl2 = g_malloc((idx + 1) * sizeof *gsl2, M_WAITOK | M_ZERO); if (gsp->hot != NULL) bcopy(gsp->hot, gsl2, gsp->nhot * sizeof *gsl2); gsp->hot = gsl2; if (gsp->hot != NULL) g_free(gsl); gsl = gsl2; - gsp->nhot = index + 1; + gsp->nhot = idx + 1; } if (bootverbose) printf("GEOM: Add %s hot[%d] start %jd length %jd end %jd\n", - gp->name, index, (intmax_t)offset, (intmax_t)length, + gp->name, idx, (intmax_t)offset, (intmax_t)length, (intmax_t)(offset + length - 1)); - gsl[index].offset = offset; - gsl[index].length = length; + gsl[idx].offset = offset; + gsl[idx].length = length; return (0); } struct g_provider * -g_slice_addslice(struct g_geom *gp, int index, off_t offset, off_t length, u_int sectorsize, char *fmt, ...) +g_slice_addslice(struct g_geom *gp, int idx, off_t offset, off_t length, u_int sectorsize, const char *fmt, ...) { struct g_provider *pp; struct g_slicer *gsp; @@ -400,13 +401,13 @@ g_slice_addslice(struct g_geom *gp, int index, off_t offset, off_t length, u_int sbuf_finish(sb); pp = g_new_providerf(gp, sbuf_data(sb)); - pp->index = index; - gsp->slices[index].length = length; - gsp->slices[index].offset = offset; - gsp->slices[index].provider = pp; - gsp->slices[index].sectorsize = sectorsize; - pp->mediasize = gsp->slices[index].length; - pp->sectorsize = gsp->slices[index].sectorsize; + pp->index = idx; + gsp->slices[idx].length = length; + gsp->slices[idx].offset = offset; + gsp->slices[idx].provider = pp; + gsp->slices[idx].sectorsize = sectorsize; + pp->mediasize = gsp->slices[idx].length; + pp->sectorsize = gsp->slices[idx].sectorsize; sbuf_delete(sb); if (bootverbose) printf("GEOM: Add %s, start %jd length %jd end %jd\n", diff --git a/sys/geom/geom_slice.h b/sys/geom/geom_slice.h index bea6aac8b8bf..6ca64a96b6f7 100644 --- a/sys/geom/geom_slice.h +++ b/sys/geom/geom_slice.h @@ -60,14 +60,14 @@ struct g_slicer { }; g_dumpconf_t g_slice_dumpconf; -struct g_provider * g_slice_addslice(struct g_geom *gp, int index, off_t offset, off_t length, u_int sectorsize, char *fmt, ...); -int g_slice_config(struct g_geom *gp, u_int index, int how, off_t offset, off_t length, u_int sectorsize, char *fmt, ...); +struct g_provider * g_slice_addslice(struct g_geom *gp, int idx, off_t offset, off_t length, u_int sectorsize, const char *fmt, ...); +int g_slice_config(struct g_geom *gp, u_int idx, int how, off_t offset, off_t length, u_int sectorsize, const char *fmt, ...); #define G_SLICE_CONFIG_CHECK 0 #define G_SLICE_CONFIG_SET 1 #define G_SLICE_CONFIG_FORCE 2 struct g_geom * g_slice_new(struct g_class *mp, u_int slices, struct g_provider *pp, struct g_consumer **cpp, void *extrap, int extra, g_slice_start_t *start); -int g_slice_conf_hot(struct g_geom *gp, u_int index, off_t offset, off_t length); +int g_slice_conf_hot(struct g_geom *gp, u_int idx, off_t offset, off_t length); void g_slice_finish_hot(struct bio *bp); #endif /* _GEOM_GEOM_SLICE_H_ */ diff --git a/sys/geom/geom_subr.c b/sys/geom/geom_subr.c index 96f3b61e4610..7fc15a1ab07e 100644 --- a/sys/geom/geom_subr.c +++ b/sys/geom/geom_subr.c @@ -88,7 +88,7 @@ g_add_class(struct g_class *mp) } struct g_geom * -g_new_geomf(struct g_class *mp, char *fmt, ...) +g_new_geomf(struct g_class *mp, const char *fmt, ...) { struct g_geom *gp; va_list ap; @@ -167,7 +167,7 @@ g_destroy_consumer(struct g_consumer *cp) } struct g_provider * -g_new_providerf(struct g_geom *gp, char *fmt, ...) +g_new_providerf(struct g_geom *gp, const char *fmt, ...) { struct g_provider *pp; struct sbuf *sb; @@ -451,14 +451,14 @@ g_access_rel(struct g_consumer *cp, int dcr, int dcw, int dce) } int -g_handleattr_int(struct bio *bp, char *attribute, int val) +g_handleattr_int(struct bio *bp, const char *attribute, int val) { return (g_handleattr(bp, attribute, &val, sizeof val)); } int -g_handleattr_off_t(struct bio *bp, char *attribute, off_t val) +g_handleattr_off_t(struct bio *bp, const char *attribute, off_t val) { return (g_handleattr(bp, attribute, &val, sizeof val)); @@ -466,7 +466,7 @@ g_handleattr_off_t(struct bio *bp, char *attribute, off_t val) int -g_handleattr(struct bio *bp, char *attribute, void *val, int len) +g_handleattr(struct bio *bp, const char *attribute, void *val, int len) { int error; @@ -563,7 +563,7 @@ g_spoil(struct g_provider *pp, struct g_consumer *cp) } static struct g_class * -g_class_by_name(char *name) +g_class_by_name(const char *name) { struct g_class *mp; @@ -576,7 +576,7 @@ g_class_by_name(char *name) } struct g_geom * -g_insert_geom(char *class, struct g_consumer *cp) +g_insert_geom(const char *class, struct g_consumer *cp) { struct g_class *mp; struct g_geom *gp; diff --git a/sys/geom/geom_sunlabel.c b/sys/geom/geom_sunlabel.c index 715b4232b860..576a35b0f6d5 100644 --- a/sys/geom/geom_sunlabel.c +++ b/sys/geom/geom_sunlabel.c @@ -78,7 +78,7 @@ g_sunlabel_start(struct bio *bp) } static void -g_sunlabel_dumpconf(struct sbuf *sb, char *indent, struct g_geom *gp, struct g_consumer *cp __unused, struct g_provider *pp) +g_sunlabel_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp, struct g_consumer *cp __unused, struct g_provider *pp) { struct g_slicer *gsp; struct g_sunlabel_softc *ms;