Skip to content

Commit daa41d4

Browse files
authored
Merge pull request syslog-ng#5029 from HofiOne/fix-gcc-warnings
lib,modules: fix gcc warnings about discarded const qualifiers
2 parents 770c811 + ef5c46b commit daa41d4

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

lib/scanner/csv-scanner/csv-scanner.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ _skip_whitespace(const gchar **src)
163163
static void
164164
_parse_opening_quote_character(CSVScanner *self)
165165
{
166-
gchar *quote = _strchr_optimized_for_single_char_haystack(self->options->quotes_start, *self->src);
166+
const gchar *quote = _strchr_optimized_for_single_char_haystack(self->options->quotes_start, *self->src);
167167

168168
if (quote != NULL)
169169
{

lib/str-utils.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -98,19 +98,19 @@ gchar *normalize_flag(const gchar *buffer);
9898
*
9999
* NOTE: don't use this unless strchr() really shows up in your profile.
100100
*/
101-
static inline char *
101+
static inline const char *
102102
_strchr_optimized_for_single_char_haystack(const char *str, int c)
103103
{
104104
if (str[0] == c)
105-
return (char *) str;
105+
return str;
106106
else if (str[0] == '\0')
107107
return NULL;
108108
if (str[1] == '\0')
109109
{
110110
if (c != '\0')
111111
return NULL;
112112
else
113-
return (char *) &str[1];
113+
return &str[1];
114114
}
115115
return strchr(str + 1, c);
116116
}

lib/tests/test_str-utils.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ ParameterizedTestParameters(str_utils, test_str_utils_find_char)
7878

7979
ParameterizedTest(StrChrTestData *test_data, str_utils, test_str_utils_find_char)
8080
{
81-
char *result = strchr_under_test(test_data->str, test_data->c);
81+
const char *result = strchr_under_test(test_data->str, test_data->c);
8282

8383
cr_assert_not_null(result, "expected a non-NULL return");
8484
cr_assert(result - test_data->str <= strlen(test_data->str),

modules/afsnmp/afsnmpdest.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ snmpdest_dd_set_port(LogDriver *d, gint port)
138138
static gint
139139
snmp_dd_compare_object_ids(gconstpointer a, gconstpointer b)
140140
{
141-
return strcmp((gchar *) a, (gchar *) b);
141+
return strcmp((const gchar *) a, (const gchar *) b);
142142
}
143143

144144
gboolean
@@ -155,7 +155,7 @@ snmpdest_dd_set_snmp_obj(LogDriver *d, GlobalConfig *cfg, const gchar *objectid,
155155
return FALSE;
156156
}
157157

158-
gchar *s_objectid = "objectid";
158+
const gchar *s_objectid = "objectid";
159159

160160
/* check the multiple 'objectid' types - only one type='objectid' is allowed */
161161
if (!strcmp(type, s_objectid) && self->snmp_objs)
@@ -453,7 +453,7 @@ snmpdest_worker_insert(LogThreadedDestDriver *s, LogMessage *msg)
453453
static const gchar *
454454
snmpdest_dd_format_persist_name(const LogPipe *s)
455455
{
456-
SNMPDestDriver *self = (SNMPDestDriver *) s;
456+
const SNMPDestDriver *self = (const SNMPDestDriver *) s;
457457
static gchar persist_name[1024];
458458

459459
g_snprintf(persist_name, sizeof(persist_name), "snmpdest(%s,%u)", self->host, self->port);

0 commit comments

Comments
 (0)