]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
util/proto: Convert validation routine to bool 5146/head
authorJeff Lucovsky <jeff@lucovsky.org>
Sun, 31 May 2020 12:20:28 +0000 (08:20 -0400)
committerVictor Julien <victor@inliniac.net>
Wed, 8 Jul 2020 10:26:22 +0000 (12:26 +0200)
This commit changes the signature of the protocol validation code to
bool and simplifies the validation steps.

src/util-proto-name.c
src/util-proto-name.h

index f9b00f053c1038668514394ac994ef1f0c6845f8..a7954c3020ecf00cc0c2c2b3e3cabf4e3ad9309e 100644 (file)
@@ -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);
 }
 
 /**
index 7cf69df928f0893ed7b8025d5a30d2936681e785..3cd4e27f1d4b8909fdef046eee06827247acbee5 100644 (file)
@@ -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);