util/proto: Convert validation routine to bool

This commit changes the signature of the protocol validation code to
bool and simplifies the validation steps.
pull/5146/head
Jeff Lucovsky 5 years ago committed by Victor Julien
parent 1e8d4af29a
commit dfcc8a88f6

@ -1,4 +1,4 @@
/* Copyright (C) 2007-2010 Open Information Security Foundation /* Copyright (C) 2007-2020 Open Information Security Foundation
* *
* You can copy, redistribute or modify this Program under the terms of * You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free * the GNU General Public License version 2 as published by the Free
@ -93,17 +93,11 @@ void SCProtoNameInit()
* we have corresponding name entry for this number or not. * we have corresponding name entry for this number or not.
* *
* \param proto Protocol number to be validated * \param proto Protocol number to be validated
* \retval ret On success returns TRUE otherwise FALSE * \retval ret On success returns true otherwise false
*/ */
uint8_t SCProtoNameValid(uint16_t proto) bool SCProtoNameValid(uint16_t proto)
{ {
uint8_t ret = FALSE; return (proto <= 255 && known_proto[proto] != NULL);
if (proto <= 255 && known_proto[proto] != NULL) {
ret = TRUE;
}
return ret;
} }
/** /**

@ -1,4 +1,4 @@
/* Copyright (C) 2007-2010 Open Information Security Foundation /* Copyright (C) 2007-2020 Open Information Security Foundation
* *
* You can copy, redistribute or modify this Program under the terms of * You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free * the GNU General Public License version 2 as published by the Free
@ -34,7 +34,7 @@
* in /etc/protocols */ * in /etc/protocols */
extern char *known_proto[256]; extern char *known_proto[256];
uint8_t SCProtoNameValid(uint16_t); bool SCProtoNameValid(uint16_t);
void SCProtoNameInit(void); void SCProtoNameInit(void);
void SCProtoNameDeInit(void); void SCProtoNameDeInit(void);

Loading…
Cancel
Save