Fix the possibility of off-by-one on the grammer. Reported by coypu.

Currently it never happens because type is (minor number % 7) and
the arraycount of fd_types[] is 8.  I.e., it is a dead code...
However, when the capacity of the FDTYPE() changes or the arraycount
of fd_types[] changes, this correction will be effective.
This commit is contained in:
isaki 2017-01-12 14:24:53 +00:00
parent ca57f21848
commit e9bbb736c5

View File

@ -1,4 +1,4 @@
/* $NetBSD: fd.c,v 1.118 2015/07/11 10:32:46 kamil Exp $ */
/* $NetBSD: fd.c,v 1.119 2017/01/12 14:24:53 isaki Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -64,7 +64,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.118 2015/07/11 10:32:46 kamil Exp $");
__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.119 2017/01/12 14:24:53 isaki Exp $");
#include "opt_ddb.h"
#include "opt_m68k_arch.h"
@ -672,7 +672,7 @@ fd_dev_to_type(struct fd_softc *fd, dev_t dev)
{
size_t type = FDTYPE(dev);
if (type > __arraycount(fd_types))
if (type >= __arraycount(fd_types))
return NULL;
return &fd_types[type];
}