Update array of software RAID names in ata_raid.c.

Change a boundary check to ensure that we won't accidentally read and use
uninitialized memory if ATA_RAID_TYPE_MAX is updated without updating the
array.
Update comment near ATA_RAID_TYPE_MAX to note that the array in ata_raid.c
should be updated if a new ATA_RAID_TYPE_* is added.
This commit is contained in:
briggs 2005-07-18 15:21:48 +00:00
parent 839d8caeb0
commit 2622309630
2 changed files with 8 additions and 4 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ata_raid.c,v 1.13 2005/06/20 02:11:57 briggs Exp $ */
/* $NetBSD: ata_raid.c,v 1.14 2005/07/18 15:21:48 briggs Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
@ -40,7 +40,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ata_raid.c,v 1.13 2005/06/20 02:11:57 briggs Exp $");
__KERNEL_RCSID(0, "$NetBSD: ata_raid.c,v 1.14 2005/07/18 15:21:48 briggs Exp $");
#include <sys/param.h>
#include <sys/buf.h>
@ -115,9 +115,10 @@ ata_raid_type_name(u_int type)
{
static const char *ata_raid_type_names[] = {
"Promise",
"Adaptec",
};
if (type <= ATA_RAID_TYPE_MAX)
if (type < sizeof(ata_raid_type_names) / sizeof(ata_raid_type_names[0]))
return (ata_raid_type_names[type]);
return (NULL);

View File

@ -1,4 +1,4 @@
/* $NetBSD: ata_raidvar.h,v 1.2 2005/06/20 02:11:57 briggs Exp $ */
/* $NetBSD: ata_raidvar.h,v 1.3 2005/07/18 15:21:48 briggs Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
@ -44,6 +44,9 @@
* Types of RAID configurations we support. Do not change the order
* of this list, as it will change the order in which the arrays are
* sorted.
*
* If this list is updated, ensure the array in
* ata_raid.c:ata_raid_type_name() is also updated.
*/
#define ATA_RAID_TYPE_PROMISE 0
#define ATA_RAID_TYPE_ADAPTEC 1