svn commit: r297526 - head/sys/geom/sched

Pedro Giffuni pfg at FreeBSD.org
Sun Apr 3 18:01:27 UTC 2016



On 04/03/16 11:58, Kevin Lo wrote:
> On Sun, Apr 03, 2016 at 04:25:51PM +0000, Pedro F. Giffuni wrote:
>>
>> Author: pfg
>> Date: Sun Apr  3 16:25:51 2016
>> New Revision: 297526
>> URL: https://svnweb.freebsd.org/changeset/base/297526
>>
>> Log:
>>    g_sched_destroy(): prevent return of uninitialized scalar variable.
>>
>>    For the !gsp case there some chance of returning an uninitialized
>>    return value. Prevent that from happening by initializing the
>>    error value.
>
> Hmm, wouldn't it be better to initialize 'error' before use?
>

No. The if case initializes error on line 1278, the only problem
is the else case.

> Index: sys/geom/sched/g_sched.c
> ===================================================================
> --- sys/geom/sched/g_sched.c	(revision 297527)
> +++ sys/geom/sched/g_sched.c	(working copy)
> @@ -1236,7 +1236,7 @@ g_sched_destroy(struct g_geom *gp, boolean_t force
>   	struct g_provider *pp, *oldpp = NULL;
>   	struct g_sched_softc *sc;
>   	struct g_gsched *gsp;
> -	int error;
> +	int error = 0;
>
>   	g_topology_assert();
>   	sc = gp->softc;

Even when this is frequent, it is against style(9).

Pedro.


More information about the svn-src-all mailing list