diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2017-11-10 11:08:35 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2017-11-10 11:08:35 +0200 |
commit | 2f1214a79a6befb629466c3e81a993123733a2fe (patch) | |
tree | acf5e1cc9289cf4b655aa873d0b01642090b1391 | |
parent | 3457c19206858d3e8155dcfc776df8818d05824b (diff) | |
download | smap-2f1214a79a6befb629466c3e81a993123733a2fe.tar.gz smap-2f1214a79a6befb629466c3e81a993123733a2fe.tar.bz2 |
Placate cc warnings
-rw-r--r-- | lib/parseopt.c | 5 | ||||
-rw-r--r-- | lib/sockmapstr.c | 2 | ||||
-rw-r--r-- | lib/stream.c | 4 | ||||
-rw-r--r-- | modules/ldap/ldap.c | 23 | ||||
-rw-r--r-- | src/smapc.c | 2 | ||||
-rw-r--r-- | src/userprivs.c | 2 |
6 files changed, 15 insertions, 23 deletions
diff --git a/lib/parseopt.c b/lib/parseopt.c index cc0c9a6..cf5319d 100644 --- a/lib/parseopt.c +++ b/lib/parseopt.c | |||
@@ -1,34 +1,35 @@ | |||
1 | /* This file is part of Smap. | 1 | /* This file is part of Smap. |
2 | Copyright (C) 2008, 2010, 2014 Sergey Poznyakoff | 2 | Copyright (C) 2008, 2010, 2014, 2017 Sergey Poznyakoff |
3 | 3 | ||
4 | Smap is free software; you can redistribute it and/or modify | 4 | Smap is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by | 5 | it under the terms of the GNU General Public License as published by |
6 | the Free Software Foundation; either version 3, or (at your option) | 6 | the Free Software Foundation; either version 3, or (at your option) |
7 | any later version. | 7 | any later version. |
8 | 8 | ||
9 | Smap is distributed in the hope that it will be useful, | 9 | Smap is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | GNU General Public License for more details. | 12 | GNU General Public License for more details. |
13 | 13 | ||
14 | You should have received a copy of the GNU General Public License | 14 | You should have received a copy of the GNU General Public License |
15 | along with Smap. If not, see <http://www.gnu.org/licenses/>. */ | 15 | along with Smap. If not, see <http://www.gnu.org/licenses/>. */ |
16 | 16 | ||
17 | #ifdef HAVE_CONFIG_H | 17 | #ifdef HAVE_CONFIG_H |
18 | # include <config.h> | 18 | # include <config.h> |
19 | #endif | 19 | #endif |
20 | #include <smap/parseopt.h> | 20 | #include <smap/parseopt.h> |
21 | #include <smap/diag.h> | 21 | #include <smap/diag.h> |
22 | #include <string.h> | 22 | #include <string.h> |
23 | #include <ctype.h> | ||
23 | 24 | ||
24 | static struct smap_option const * | 25 | static struct smap_option const * |
25 | find_opt(struct smap_option const *opt, const char *str, const char **value, | 26 | find_opt(struct smap_option const *opt, const char *str, const char **value, |
26 | int flags) | 27 | int flags) |
27 | { | 28 | { |
28 | size_t len = strlen(str); | 29 | size_t len = strlen(str); |
29 | int isbool; | 30 | int isbool; |
30 | int delim = flags & SMAP_DELIM_MASK; | 31 | int delim = flags & SMAP_DELIM_MASK; |
31 | 32 | ||
32 | if (len > 2 && (flags & SMAP_IGNORECASE | 33 | if (len > 2 && (flags & SMAP_IGNORECASE |
33 | ? strncasecmp | 34 | ? strncasecmp |
34 | : strncmp)(str, "no", 2) == 0) { | 35 | : strncmp)(str, "no", 2) == 0) { |
@@ -166,26 +167,24 @@ smap_parseline(struct smap_option const *opt, const char *line, int flags, | |||
166 | } | 167 | } |
167 | 168 | ||
168 | if (p->func && p->func(p, value, errmsg)) | 169 | if (p->func && p->func(p, value, errmsg)) |
169 | rc = SMAP_PARSE_INVAL; | 170 | rc = SMAP_PARSE_INVAL; |
170 | return rc; | 171 | return rc; |
171 | } | 172 | } |
172 | 173 | ||
173 | int | 174 | int |
174 | smap_parseopt(struct smap_option const *opt, int argc, char **argv, int flags, | 175 | smap_parseopt(struct smap_option const *opt, int argc, char **argv, int flags, |
175 | int *pindex) | 176 | int *pindex) |
176 | { | 177 | { |
177 | int i; | 178 | int i; |
178 | long n; | ||
179 | char *s; | ||
180 | int rc = 0; | 179 | int rc = 0; |
181 | const char *modname = argv[0]; | 180 | const char *modname = argv[0]; |
182 | 181 | ||
183 | for (i = (flags & SMAP_PARSEOPT_PARSE_ARGV0) ? 0 : 1; | 182 | for (i = (flags & SMAP_PARSEOPT_PARSE_ARGV0) ? 0 : 1; |
184 | i < argc; i++) { | 183 | i < argc; i++) { |
185 | char *errmsg; | 184 | char *errmsg; |
186 | int res; | 185 | int res; |
187 | 186 | ||
188 | res = smap_parseline(opt, argv[i], SMAP_DELIM_EQ, &errmsg); | 187 | res = smap_parseline(opt, argv[i], SMAP_DELIM_EQ, &errmsg); |
189 | 188 | ||
190 | if (res == SMAP_PARSE_SUCCESS) | 189 | if (res == SMAP_PARSE_SUCCESS) |
191 | continue; | 190 | continue; |
diff --git a/lib/sockmapstr.c b/lib/sockmapstr.c index 1c0d749..7e188f2 100644 --- a/lib/sockmapstr.c +++ b/lib/sockmapstr.c | |||
@@ -218,25 +218,25 @@ read_payload_length(struct sockmap_input_stream *sp) | |||
218 | char *p; | 218 | char *p; |
219 | 219 | ||
220 | n = recv(sp->fd, sp->nbuf + len, SIZE_T_STRLEN_BOUND - len, 0); | 220 | n = recv(sp->fd, sp->nbuf + len, SIZE_T_STRLEN_BOUND - len, 0); |
221 | if (n < 0) { | 221 | if (n < 0) { |
222 | smap_debug(sp->debug_idx, 1, | 222 | smap_debug(sp->debug_idx, 1, |
223 | ("error reading from fd #%d: %s", sp->fd, | 223 | ("error reading from fd #%d: %s", sp->fd, |
224 | strerror(errno))); | 224 | strerror(errno))); |
225 | return errno; | 225 | return errno; |
226 | } | 226 | } |
227 | if (n == 0) | 227 | if (n == 0) |
228 | return EOF; | 228 | return EOF; |
229 | len += n; | 229 | len += n; |
230 | if (p = memchr(sp->nbuf, ':', len)) { | 230 | if ((p = memchr(sp->nbuf, ':', len))) { |
231 | sp->cp = p - sp->nbuf; | 231 | sp->cp = p - sp->nbuf; |
232 | sp->nbuf[len] = 0; | 232 | sp->nbuf[len] = 0; |
233 | sp->nlen = len; | 233 | sp->nlen = len; |
234 | return 0; | 234 | return 0; |
235 | } | 235 | } |
236 | } | 236 | } |
237 | sp->nbuf[len] = 0; | 237 | sp->nbuf[len] = 0; |
238 | sp->nlen = len; | 238 | sp->nlen = len; |
239 | if (smap_debug_np(sp->debug_idx, 1)) | 239 | if (smap_debug_np(sp->debug_idx, 1)) |
240 | report_invalid_prefix(sp, "prefix too long"); | 240 | report_invalid_prefix(sp, "prefix too long"); |
241 | return EPROTO; | 241 | return EPROTO; |
242 | } | 242 | } |
diff --git a/lib/stream.c b/lib/stream.c index d039c08..c217ca6 100644 --- a/lib/stream.c +++ b/lib/stream.c | |||
@@ -216,30 +216,30 @@ _stream_flush_buffer(struct _smap_stream *stream, int all) | |||
216 | end = memchr(stream->cur, '\n', stream->level)) { | 216 | end = memchr(stream->cur, '\n', stream->level)) { |
217 | size_t size = end - stream->cur + 1; | 217 | size_t size = end - stream->cur + 1; |
218 | rc = smap_stream_write_unbuffered(stream, | 218 | rc = smap_stream_write_unbuffered(stream, |
219 | stream->cur, | 219 | stream->cur, |
220 | size, 1, | 220 | size, 1, |
221 | NULL); | 221 | NULL); |
222 | if (rc) | 222 | if (rc) |
223 | return rc; | 223 | return rc; |
224 | _stream_advance_buffer(stream, size); | 224 | _stream_advance_buffer(stream, size); |
225 | } | 225 | } |
226 | if (stream->level) { | 226 | if (stream->level) { |
227 | if (all) { | 227 | if (all) { |
228 | if (rc = _force_flush_buffer(stream)) | 228 | if ((rc = _force_flush_buffer(stream))) |
229 | return rc; | 229 | return rc; |
230 | } else if (BUFFER_FULL_P(stream)) { | 230 | } else if (BUFFER_FULL_P(stream)) { |
231 | if (stream->flags & SMAP_STREAM_EXPBUF) | 231 | if (stream->flags & SMAP_STREAM_EXPBUF) |
232 | return _stream_realloc_buffer(stream, 0); | 232 | return _stream_realloc_buffer(stream, 0); |
233 | if (rc = _force_flush_buffer(stream)) | 233 | if ((rc = _force_flush_buffer(stream))) |
234 | return rc; | 234 | return rc; |
235 | } | 235 | } |
236 | } | 236 | } |
237 | } | 237 | } |
238 | } else if (all) | 238 | } else if (all) |
239 | _stream_advance_buffer(stream, stream->level); | 239 | _stream_advance_buffer(stream, stream->level); |
240 | 240 | ||
241 | if (stream->level) { | 241 | if (stream->level) { |
242 | if (stream->cur > stream->buffer) | 242 | if (stream->cur > stream->buffer) |
243 | memmove(stream->buffer, stream->cur, stream->level); | 243 | memmove(stream->buffer, stream->cur, stream->level); |
244 | } else { | 244 | } else { |
245 | stream->flags &= ~_SMAP_STR_DIRTY; | 245 | stream->flags &= ~_SMAP_STR_DIRTY; |
diff --git a/modules/ldap/ldap.c b/modules/ldap/ldap.c index d686f6b..b34c560 100644 --- a/modules/ldap/ldap.c +++ b/modules/ldap/ldap.c | |||
@@ -99,25 +99,25 @@ argz_copy(char ***dst, char **a) | |||
99 | { | 99 | { |
100 | int i, n; | 100 | int i, n; |
101 | char **b; | 101 | char **b; |
102 | 102 | ||
103 | if (!a) { | 103 | if (!a) { |
104 | *dst = NULL; | 104 | *dst = NULL; |
105 | return 0; | 105 | return 0; |
106 | } | 106 | } |
107 | 107 | ||
108 | for (n = 0; a[n]; n++) | 108 | for (n = 0; a[n]; n++) |
109 | ; | 109 | ; |
110 | 110 | ||
111 | b = calloc(i + 1, sizeof(b[0])); | 111 | b = calloc(n + 1, sizeof(b[0])); |
112 | if (!b) | 112 | if (!b) |
113 | return -1; | 113 | return -1; |
114 | for (i = 0; i < n; i++) { | 114 | for (i = 0; i < n; i++) { |
115 | b[i] = strdup(a[i]); | 115 | b[i] = strdup(a[i]); |
116 | if (!b[i]) | 116 | if (!b[i]) |
117 | return -1; | 117 | return -1; |
118 | } | 118 | } |
119 | b[i] = NULL; | 119 | b[i] = NULL; |
120 | return 0; | 120 | return 0; |
121 | } | 121 | } |
122 | 122 | ||
123 | static void | 123 | static void |
@@ -191,25 +191,25 @@ parse_ldap_conf(const char *name, struct smap_option const *opt) | |||
191 | char buf[1024]; | 191 | char buf[1024]; |
192 | unsigned line; | 192 | unsigned line; |
193 | char *p; |