[Spread-cvs] commit: r882 - trunk/libspread-util/src

jschultz at spread.org jschultz at spread.org
Mon Jan 23 07:19:03 EST 2017


Author: jschultz
Date: 2017-01-23 07:19:03 -0500 (Mon, 23 Jan 2017)
New Revision: 882

Modified:
   trunk/libspread-util/src/events.c
Log:
Fixed checks against NUM_PRIORITY and NUM_FDTYPES

Thanks to Daniel Savarese for catching this!



Modified: trunk/libspread-util/src/events.c
===================================================================
--- trunk/libspread-util/src/events.c	2017-01-23 12:02:19 UTC (rev 881)
+++ trunk/libspread-util/src/events.c	2017-01-23 12:19:03 UTC (rev 882)
@@ -587,12 +587,12 @@
 	int	num_fds;
 	int	j;
 
-	if( priority < 0 || priority > NUM_PRIORITY )
+	if( priority < 0 || priority >= NUM_PRIORITY )
 	{
 		Alarmp( SPLOG_PRINT, EVENTS, "E_attach_fd: invalid priority %d for fd %d with fd_type %d\n", priority, fd, fd_type );
 		return( -1 );
 	}
-	if( fd_type < 0 || fd_type > NUM_FDTYPES )
+	if( fd_type < 0 || fd_type >= NUM_FDTYPES )
 	{
 		Alarmp( SPLOG_PRINT, EVENTS, "E_attach_fd: invalid fd_type %d for fd %d with priority %d\n", fd_type, fd, priority );
 		return( -1 );
@@ -649,7 +649,7 @@
 	int	i;
 	int	found;
 
-	if( fd_type < 0 || fd_type > NUM_FDTYPES )
+	if( fd_type < 0 || fd_type >= NUM_FDTYPES )
 	{
 		Alarmp( SPLOG_PRINT, EVENTS, "E_detach_fd: invalid fd_type %d for fd %d\n", fd_type, fd );
 		return( -1 );
@@ -674,7 +674,7 @@
 	int	i;
 	int	found;
 
-	if( fd_type < 0 || fd_type > NUM_FDTYPES )
+	if( fd_type < 0 || fd_type >= NUM_FDTYPES )
 	{
 		Alarmp( SPLOG_PRINT, EVENTS, "E_detach_fd: invalid fd_type %d for fd %d\n", fd_type, fd );
 		return( -1 );
@@ -707,7 +707,7 @@
 	int	i,j;
 	int	found;
 
-	if( fd_type < 0 || fd_type > NUM_FDTYPES )
+	if( fd_type < 0 || fd_type >= NUM_FDTYPES )
 	{
 		Alarmp( SPLOG_PRINT, EVENTS, "E_deactivate_fd: invalid fd_type %d for fd %d\n", fd_type, fd );
 		return( -1 );
@@ -739,7 +739,7 @@
 	int	i,j;
 	int	found;
 
-	if( fd_type < 0 || fd_type > NUM_FDTYPES )
+	if( fd_type < 0 || fd_type >= NUM_FDTYPES )
 	{
 		Alarmp( SPLOG_PRINT, EVENTS, "E_activate_fd: invalid fd_type %d for fd %d\n", fd_type, fd );
 		return( -1 );
@@ -771,7 +771,7 @@
 	int	fd_type;
 	int	i,j;
 
-	if( priority < 0 || priority > NUM_PRIORITY )
+	if( priority < 0 || priority >= NUM_PRIORITY )
 	{
 		Alarmp( SPLOG_PRINT, EVENTS, "E_set_active_threshold: invalid priority %d\n", priority );
 		return( -1 );
@@ -800,7 +800,7 @@
 
 int	E_num_active( int priority )
 {
-	if( priority < 0 || priority > NUM_PRIORITY )
+	if( priority < 0 || priority >= NUM_PRIORITY )
 	{
 		Alarmp( SPLOG_PRINT, EVENTS, "E_num_active: invalid priority %d\n", priority );
 		return( -1 );




More information about the Spread-cvs mailing list