From b99bce73e2029b200fd178abab11737d6f2c6aed Mon Sep 17 00:00:00 2001 From: "Pedro F. Giffuni" Date: Wed, 27 Apr 2016 15:10:40 +0000 Subject: [PATCH] geom: unsign some types to match their definitions and avoid overflows. In struct:gctl_req, nargs is unsigned. In mirror: g_mirror_syncreqs is unsigned. In raid: in struct:g_raid_volume, v_disks_count is unsigned. In virstor: in struct:g_virstor_softc, n_components is unsigned. MFC after: 2 weeks --- sys/geom/geom_ctl.c | 10 +++++----- sys/geom/mirror/g_mirror.c | 2 +- sys/geom/raid/md_promise.c | 2 +- sys/geom/raid/md_sii.c | 2 +- sys/geom/virstor/g_virstor.c | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/sys/geom/geom_ctl.c b/sys/geom/geom_ctl.c index a5fa3d75126..71a8c2605e9 100644 --- a/sys/geom/geom_ctl.c +++ b/sys/geom/geom_ctl.c @@ -135,7 +135,7 @@ gctl_copyin(struct gctl_req *req) { struct gctl_req_arg *ap; char *p; - int i; + u_int i; ap = geom_alloc_copyin(req, req->arg, req->narg * sizeof(*ap)); if (ap == NULL) { @@ -212,7 +212,7 @@ gctl_copyout(struct gctl_req *req) static void gctl_free(struct gctl_req *req) { - int i; + u_int i; sbuf_delete(req->serror); if (req->arg == NULL) @@ -270,7 +270,7 @@ int gctl_set_param(struct gctl_req *req, const char *param, void const *ptr, int len) { - int i; + u_int i; struct gctl_req_arg *ap; for (i = 0; i < req->narg; i++) { @@ -311,7 +311,7 @@ gctl_set_param_err(struct gctl_req *req, const char *param, void const *ptr, void * gctl_get_param(struct gctl_req *req, const char *param, int *len) { - int i; + u_int i; void *p; struct gctl_req_arg *ap; @@ -332,7 +332,7 @@ gctl_get_param(struct gctl_req *req, const char *param, int *len) char const * gctl_get_asciiparam(struct gctl_req *req, const char *param) { - int i; + u_int i; char const *p; struct gctl_req_arg *ap; diff --git a/sys/geom/mirror/g_mirror.c b/sys/geom/mirror/g_mirror.c index 59da9802726..5ef4d5c3d63 100644 --- a/sys/geom/mirror/g_mirror.c +++ b/sys/geom/mirror/g_mirror.c @@ -1160,7 +1160,7 @@ g_mirror_sync_collision(struct g_mirror_softc *sc, struct bio *bp) struct g_mirror_disk *disk; struct bio *sbp; off_t rstart, rend, sstart, send; - int i; + u_int i; if (sc->sc_sync.ds_ndisks == 0) return (0); diff --git a/sys/geom/raid/md_promise.c b/sys/geom/raid/md_promise.c index 42ae947ca08..1cf334f240f 100644 --- a/sys/geom/raid/md_promise.c +++ b/sys/geom/raid/md_promise.c @@ -893,7 +893,7 @@ g_raid_md_promise_start(struct g_raid_volume *vol) struct g_raid_md_promise_perdisk *pd; struct g_raid_md_promise_pervolume *pv; struct promise_raid_conf *meta; - int i; + u_int i; sc = vol->v_softc; md = sc->sc_md; diff --git a/sys/geom/raid/md_sii.c b/sys/geom/raid/md_sii.c index 34cdd8d3ee7..f97366041ef 100644 --- a/sys/geom/raid/md_sii.c +++ b/sys/geom/raid/md_sii.c @@ -1482,7 +1482,7 @@ g_raid_md_write_sii(struct g_raid_md_object *md, struct g_raid_volume *tvol, struct g_raid_md_sii_object *mdi; struct g_raid_md_sii_perdisk *pd; struct sii_raid_conf *meta; - int i; + u_int i; sc = md->mdo_softc; mdi = (struct g_raid_md_sii_object *)md; diff --git a/sys/geom/virstor/g_virstor.c b/sys/geom/virstor/g_virstor.c index a1774a9c498..7393c10c984 100644 --- a/sys/geom/virstor/g_virstor.c +++ b/sys/geom/virstor/g_virstor.c @@ -471,7 +471,7 @@ static void update_metadata(struct g_virstor_softc *sc) { struct g_virstor_metadata md; - int n; + u_int n; if (virstor_valid_components(sc) != sc->n_components) return; /* Incomplete device */ @@ -928,7 +928,7 @@ virstor_geom_destroy(struct g_virstor_softc *sc, boolean_t force, { struct g_provider *pp; struct g_geom *gp; - int n; + u_int n; g_topology_assert(); -- 2.45.2