Bug 207856 - usr/src/sys/geom/vinum/geom_vinum_raid5.c: 2 * bad test ?
Summary: usr/src/sys/geom/vinum/geom_vinum_raid5.c: 2 * bad test ?
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Ed Maste
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-03-09 19:34 UTC by David Binderman
Modified: 2023-03-23 12:54 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Binderman 2016-03-09 19:34:00 UTC
1.

usr/src/sys/geom/vinum/geom_vinum_raid5.c:602]: (style) A pointer can not be negative so it is either pointless or an error to check if it is not.

source code is

    KASSERT(psdno >= 0, ("gv_raid5_offset: psdno < 0"));

but

gv_raid5_offset(struct gv_plex *p, off_t boff, off_t bcount, off_t *real_off,
    off_t *real_len, int *sdno, int *psdno, int growing)

2.

usr/src/sys/geom/vinum/geom_vinum_raid5.c:610]: (style) A pointer can not be negative so it is either pointless or an error to check if it is not.

Source code is

    KASSERT(sdno >= 0, ("gv_raid5_offset: sdno < 0"));

Duplicate.
Comment 1 Ed Maste freebsd_committer freebsd_triage 2022-12-12 17:05:21 UTC
Presumably this was meant to be
KASSERT(*psdno >= 0, ("gv_raid5_offset: psdno < 0"));
Comment 2 Ed Maste freebsd_committer freebsd_triage 2022-12-12 17:07:59 UTC
Actually, these assertions are before *sdno / *psdno are set, so I imagine what was intended was:

KASSERT(psd >= 0, ("gv_raid5_offset: psdno < 0"));

and

KASSERT(sd >= 0, ("gv_raid5_offset: sdno < 0"));
Comment 3 Ed Maste freebsd_committer freebsd_triage 2022-12-12 17:11:46 UTC
https://reviews.freebsd.org/D37677
Comment 4 commit-hook freebsd_committer freebsd_triage 2023-03-21 14:03:42 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=87bb53cb538059a3085db1fa4295dde5fcba55fe

commit 87bb53cb538059a3085db1fa4295dde5fcba55fe
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2022-12-12 17:08:39 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2023-03-21 14:03:12 +0000

    gvinum: correct assertions

    Pointer addresses are always >= 0.  Assert that the value is >= 0
    instead.

    PR:             207855, 207856
    Reviewed by:    imp
    Reported by:    David Binderman
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D37677

 sys/geom/vinum/geom_vinum_plex.c  | 2 +-
 sys/geom/vinum/geom_vinum_raid5.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
Comment 5 commit-hook freebsd_committer freebsd_triage 2023-03-23 12:43:05 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=66f3ac8c661df02cf7d9e187ea20e66e2e71ec82

commit 66f3ac8c661df02cf7d9e187ea20e66e2e71ec82
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2022-12-12 17:08:39 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2023-03-23 12:41:35 +0000

    gvinum: correct assertions

    Pointer addresses are always >= 0.  Assert that the value is >= 0
    instead.

    PR:             207855, 207856
    Reviewed by:    imp
    Reported by:    David Binderman
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D37677

    (cherry picked from commit 87bb53cb538059a3085db1fa4295dde5fcba55fe)

 sys/geom/vinum/geom_vinum_plex.c  | 2 +-
 sys/geom/vinum/geom_vinum_raid5.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
Comment 6 commit-hook freebsd_committer freebsd_triage 2023-03-23 12:51:07 UTC
A commit in branch stable/12 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=12be1c744e002b96c3b84e816e8ec72455f443bf

commit 12be1c744e002b96c3b84e816e8ec72455f443bf
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2022-12-12 17:08:39 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2023-03-23 12:49:43 +0000

    gvinum: correct assertions

    Pointer addresses are always >= 0.  Assert that the value is >= 0
    instead.

    PR:             207855, 207856
    Reviewed by:    imp
    Reported by:    David Binderman
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D37677

    (cherry picked from commit 87bb53cb538059a3085db1fa4295dde5fcba55fe)
    (cherry picked from commit 66f3ac8c661df02cf7d9e187ea20e66e2e71ec82)

 sys/geom/vinum/geom_vinum_plex.c  | 2 +-
 sys/geom/vinum/geom_vinum_raid5.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
Comment 7 Ed Maste freebsd_committer freebsd_triage 2023-03-23 12:54:35 UTC
Now fixed in all supported branches. Thanks for the bug report.