From dfcc8a88f6f8a539b6b1226f58c2f9922fe329a3 Mon Sep 17 00:00:00 2001 From: Jeff Lucovsky Date: Sun, 31 May 2020 08:20:28 -0400 Subject: [PATCH] util/proto: Convert validation routine to bool This commit changes the signature of the protocol validation code to bool and simplifies the validation steps. --- src/util-proto-name.c | 14 ++++---------- src/util-proto-name.h | 4 ++-- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/util-proto-name.c b/src/util-proto-name.c index f9b00f053c..a7954c3020 100644 --- a/src/util-proto-name.c +++ b/src/util-proto-name.c @@ -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 * 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. * * \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; - - if (proto <= 255 && known_proto[proto] != NULL) { - ret = TRUE; - } - - return ret; + return (proto <= 255 && known_proto[proto] != NULL); } /** diff --git a/src/util-proto-name.h b/src/util-proto-name.h index 7cf69df928..3cd4e27f1d 100644 --- a/src/util-proto-name.h +++ b/src/util-proto-name.h @@ -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 * the GNU General Public License version 2 as published by the Free @@ -34,7 +34,7 @@ * in /etc/protocols */ extern char *known_proto[256]; -uint8_t SCProtoNameValid(uint16_t); +bool SCProtoNameValid(uint16_t); void SCProtoNameInit(void); void SCProtoNameDeInit(void); -- 2.47.2