• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

OISF / suricata / 23374838686

21 Mar 2026 07:29AM UTC coverage: 59.341% (-20.0%) from 79.315%
23374838686

Pull #15075

github

web-flow
Merge 90b4e834f into 6587e363a
Pull Request #15075: Stack 8001 v16.4

38 of 70 new or added lines in 10 files covered. (54.29%)

34165 existing lines in 563 files now uncovered.

119621 of 201584 relevant lines covered (59.34%)

650666.92 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

73.08
/src/util-enum.c
1
/* Copyright (C) 2007-2010 Open Information Security Foundation
2
 *
3
 * You can copy, redistribute or modify this Program under the terms of
4
 * the GNU General Public License version 2 as published by the Free
5
 * Software Foundation.
6
 *
7
 * This program is distributed in the hope that it will be useful,
8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 * GNU General Public License for more details.
11
 *
12
 * You should have received a copy of the GNU General Public License
13
 * version 2 along with this program; if not, write to the Free Software
14
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15
 * 02110-1301, USA.
16
 */
17

18
/**
19
 * \file
20
 *
21
 * \author Anoop Saldanha <anoopsaldanha@gmail.com>
22
 */
23

24
#include "suricata-common.h"
25

26
#include "util-enum.h"
27
#include "util-debug.h"
28

29
/**
30
 * \brief Maps a string name to an enum value from the supplied table.  Please
31
 *        specify the last element of any map table with a {NULL, -1}.  If
32
 *        missing, you will be welcomed with a segfault :)
33
 *
34
 * \param enum_name Character string that has to be mapped to an enum value
35
 *                  from the table
36
 * \param table     Enum-Char table, from which the mapping is retrieved
37
 *
38
 * \retval result The enum_value for the enum_name string or -1 on failure
39
 */
40
int SCMapEnumNameToValue(const char *enum_name, SCEnumCharMap *table)
41
{
46,955✔
42
    int result = -1;
46,955✔
43

44
    if (enum_name == NULL || table == NULL) {
46,955✔
45
        SCLogDebug("Invalid argument(s) passed into SCMapEnumNameToValue");
×
46
        return -1;
×
47
    }
×
48

49
    for (; table->enum_name != NULL; table++) {
664,666✔
50
        if (strcasecmp(table->enum_name, enum_name) == 0) {
660,256✔
51
            result = table->enum_value;
42,545✔
52
            break;
42,545✔
53
        }
42,545✔
54
    }
660,256✔
55

56
    return result;
46,955✔
57
}
46,955✔
58

59
/**
60
 * \brief Maps an enum value to a string name, from the supplied table
61
 *
62
 * \param enum_value Enum_value that has to be mapped to a string_value
63
 *                   from the table
64
 * \param table      Enum-Char table, from which the mapping is retrieved
65
 *
66
 * \retval result The enum_name for the enum_value supplied or NULL on failure
67
 */
68
const char * SCMapEnumValueToName(int enum_value, SCEnumCharMap *table)
69
{
10,695,823✔
70
    if (table == NULL) {
10,695,823✔
71
        SCLogDebug("Invalid argument(s) passed into SCMapEnumValueToName");
×
72
        return NULL;
×
73
    }
×
74

75
    for (; table->enum_name != NULL; table++) {
34,369,292✔
76
        if (table->enum_value == enum_value) {
34,369,292✔
77
            return table->enum_name;
10,695,823✔
78
        }
10,695,823✔
79
    }
34,369,292✔
80

UNCOV
81
    SCLogDebug("A enum by the value %d doesn't exist in this table", enum_value);
×
82

83
    return NULL;
84
}
10,695,823✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc