diff options
author | Fabrice Fontaine <fontaine.fabrice@gmail.com> | 2022-01-02 22:01:31 +0100 |
---|---|---|
committer | Simon Kelley <simon@thekelleys.org.uk> | 2022-01-03 15:13:53 +0000 |
commit | b2690415bfa1bc105e61b75f642fb5c1aaf0fae8 (patch) | |
tree | e8ab8e4016c54c8256a576887d808767943eeba8 | |
parent | 011f8cf1d011ade2f9e7231fca3cabfb1e8eaf06 (diff) | |
download | dnsmasq-b2690415bfa1bc105e61b75f642fb5c1aaf0fae8.tar.gz |
src/option.c: fix build with gcc 4.8
Thanks for applying and fixing my patch. Here is another one on src/pattern.c
Best Regards,
Fabrice
Le dim. 2 janv. 2022 à 00:36, Simon Kelley <simon@thekelleys.org.uk> a écrit :
>
>
>
> Thanks,
>
>
> patch applied. Followed by a small fix, and then a larger fix when I was
> forced to look at the code in question ;)
>
>
>
> Cheers,
>
> Simon.
>
> On 31/12/2021 16:29, Fabrice Fontaine wrote:
> > Fix the following build failure with gcc 4.8 raised since version 2.86:
> >
> > option.c: In function 'one_opt':
> > option.c:2445:11: error: 'for' loop initial declarations are only allowed in C99 mode
> > for (char *p = arg; *p; p++) {
> > ^
> > option.c:2445:11: note: use option -std=c99 or -std=gnu99 to compile your code
> > option.c:2453:11: error: 'for' loop initial declarations are only allowed in C99 mode
> > for (u8 i = 0; i < sizeof(daemon->umbrella_device); i++, arg+=2) {
> > ^
> >
> > Fixes:
> > - http://autobuild.buildroot.org/results/39b34a4e69fc10f4bd9d4ddb0ed8c0aae5741c84
> >
> > Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
> > ---
> > src/option.c | 6 ++++--
> > 1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/src/option.c b/src/option.c
> > index ff54def..c57f6d8 100644
> > --- a/src/option.c
> > +++ b/src/option.c
> > @@ -2525,7 +2525,8 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
> > arg += 9;
> > if (strlen(arg) != 16)
> > ret_err(gen_err);
> > - for (char *p = arg; *p; p++) {
> > + char *p;
> > + for (*p = arg; *p; p++) {
> > if (!isxdigit((int)*p))
> > ret_err(gen_err);
> > }
> > @@ -2533,7 +2534,8 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
> >
> > u8 *u = daemon->umbrella_device;
> > char word[3];
> > - for (u8 i = 0; i < sizeof(daemon->umbrella_device); i++, arg+=2) {
> > + u8 i;
> > + for (i = 0; i < sizeof(daemon->umbrella_device); i++, arg+=2) {
> > memcpy(word, &(arg[0]), 2);
> > *u++ = strtoul(word, NULL, 16);
> > }
> >
>
From 0c89dd2fa0fe50b00bca638dbbacfbd361526e0a Mon Sep 17 00:00:00 2001
From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Date: Sun, 2 Jan 2022 21:57:52 +0100
Subject: [PATCH] src/pattern.c: fix build with gcc 4.8
Fix the following build failure:
pattern.c: In function 'is_valid_dns_name':
pattern.c:134:3: error: 'for' loop initial declarations are only allowed in C99 mode
for (const char *c = value;; c++)
^
pattern.c:134:3: note: use option -std=c99 or -std=gnu99 to compile your code
pattern.c: In function 'is_valid_dns_name_pattern':
pattern.c:249:3: error: 'for' loop initial declarations are only allowed in C99 mode
for (const char *c = value;; c++)
^
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
-rw-r--r-- | src/pattern.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/pattern.c b/src/pattern.c index 03e23b9..928d259 100644 --- a/src/pattern.c +++ b/src/pattern.c @@ -129,9 +129,9 @@ int is_valid_dns_name(const char *value) size_t num_bytes = 0; size_t num_labels = 0; - const char *label = NULL; + const char *c, *label = NULL; int is_label_numeric = 1; - for (const char *c = value;; c++) + for (c = value;; c++) { if (*c && *c != '-' && *c != '.' && @@ -242,11 +242,11 @@ int is_valid_dns_name_pattern(const char *value) size_t num_bytes = 0; size_t num_labels = 0; - const char *label = NULL; + const char *c, *label = NULL; int is_label_numeric = 1; size_t num_wildcards = 0; int previous_label_has_wildcard = 1; - for (const char *c = value;; c++) + for (c = value;; c++) { if (*c && *c != '*' && /* Wildcard. */ |