Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/librumpuser Fix build where compiler can throw an array-...
details: https://anonhg.NetBSD.org/src/rev/60aa55609781
branches: trunk
changeset: 788692:60aa55609781
user: pooka <pooka%NetBSD.org@localhost>
date: Thu Jul 18 12:28:26 2013 +0000
description:
Fix build where compiler can throw an array-bounds error and
code is built with NDEBUG
or
platform's assert is not __dead
diffstat:
lib/librumpuser/rumpuser_sp.c | 15 ++++++++++++---
1 files changed, 12 insertions(+), 3 deletions(-)
diffs (36 lines):
diff -r b485a0eb3db6 -r 60aa55609781 lib/librumpuser/rumpuser_sp.c
--- a/lib/librumpuser/rumpuser_sp.c Thu Jul 18 12:27:01 2013 +0000
+++ b/lib/librumpuser/rumpuser_sp.c Thu Jul 18 12:28:26 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rumpuser_sp.c,v 1.58 2013/04/30 12:39:20 pooka Exp $ */
+/* $NetBSD: rumpuser_sp.c,v 1.59 2013/07/18 12:28:26 pooka Exp $ */
/*
* Copyright (c) 2010, 2011 Antti Kantee. All Rights Reserved.
@@ -37,7 +37,7 @@
#include "rumpuser_port.h"
#if !defined(lint)
-__RCSID("$NetBSD: rumpuser_sp.c,v 1.58 2013/04/30 12:39:20 pooka Exp $");
+__RCSID("$NetBSD: rumpuser_sp.c,v 1.59 2013/07/18 12:28:26 pooka Exp $");
#endif /* !lint */
#include <sys/types.h>
@@ -648,7 +648,16 @@
break;
}
- assert(i < MAXCLI);
+ /*
+ * Although not finding a slot is impossible (cf. how this routine
+ * is called), the compiler can still think that i == MAXCLI
+ * if this code is either compiled with NDEBUG or the platform
+ * does not use __dead for assert(). Therefore, add an explicit
+ * check to avoid an array-bounds error.
+ */
+ /* assert(i < MAXCLI); */
+ if (i == MAXCLI)
+ abort();
pfdlist[i].fd = newfd;
spclist[i].spc_fd = newfd;
Home |
Main Index |
Thread Index |
Old Index