Skip to content

Commit 491cc3e

Browse files
authored
Fix building with different options
Fixes #458. Add many build options to the NetBSD target Set any warnings to be errors as NetBSD should build without any warnings. DragonFly as well, but we don't have a target for that.
1 parent 4d583c4 commit 491cc3e

File tree

5 files changed

+51
-19
lines changed

5 files changed

+51
-19
lines changed

.github/workflows/build.yml

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- uses: actions/checkout@v2
2121

2222
- name: Configure
23-
run: ./configure --prefix=/usr
23+
run: ./configure
2424

2525
- name: Build
2626
run: make
@@ -44,9 +44,7 @@ jobs:
4444
git clone --depth=1 "${{ github.server_url }}/${{ github.repository }}" build
4545
cd build
4646
[ "${{ github.event.pull_request.number }}" = "" ] || (echo "fetching PR ${{ github.event.pull_request.number }}"; git fetch origin pull/${{ github.event.pull_request.number }}/head:pr-${{ github.event.pull_request.number }} && git checkout "pr-${{ github.event.pull_request.number }}")
47-
echo "configure"
48-
./configure --prefix=/usr
49-
echo "building"
47+
./configure
5048
make
5149
5250
- name: Tests
@@ -71,9 +69,7 @@ jobs:
7169
git clone --depth=1 "${{ github.server_url }}/${{ github.repository }}" build
7270
cd build
7371
[ "${{ github.event.pull_request.number }}" = "" ] || (echo "fetching PR ${{ github.event.pull_request.number }}"; git fetch origin pull/${{ github.event.pull_request.number }}/head:pr-${{ github.event.pull_request.number }} && git checkout "pr-${{ github.event.pull_request.number }}")
74-
echo "configure"
75-
./configure --prefix=/usr
76-
echo "building"
72+
./configure
7773
make
7874
7975
- name: Tests
@@ -82,6 +78,18 @@ jobs:
8278
make tests
8379
8480
netbsd:
81+
strategy:
82+
matrix:
83+
args:
84+
-
85+
- --disable-ipv4
86+
- --disable-arp
87+
- --disable-ipv4ll
88+
- --disable-ipv6
89+
- --disable-dhcp6
90+
cppflags:
91+
-
92+
- -DSMALL
8593
runs-on: ubuntu-latest
8694
steps:
8795
- name: Bootstrap NetBSD-latest
@@ -94,9 +102,7 @@ jobs:
94102
git clone --depth=1 "${{ github.server_url }}/${{ github.repository }}" build
95103
cd build
96104
[ "${{ github.event.pull_request.number }}" = "" ] || (echo "fetching PR ${{ github.event.pull_request.number }}"; git fetch origin pull/${{ github.event.pull_request.number }}/head:pr-${{ github.event.pull_request.number }} && git checkout "pr-${{ github.event.pull_request.number }}")
97-
echo "configure"
98-
./configure --prefix=/usr
99-
echo "building"
105+
CFLAGS=-Werror CPPFLAGS="${{ matrix.cppflags }}" ./configure ${{ matrix.args }}
100106
make
101107
102108
- name: Tests

src/dhcp.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3068,7 +3068,7 @@ dhcp_handledhcp(struct interface *ifp, struct bootp *bootp, size_t bootp_len,
30683068
struct dhcp_state *state = D_STATE(ifp);
30693069
struct if_options *ifo = ifp->options;
30703070
struct dhcp_lease *lease = &state->lease;
3071-
uint8_t type, tmp;
3071+
uint8_t type;
30723072
struct in_addr addr;
30733073
unsigned int i;
30743074
char *msg;
@@ -3079,6 +3079,9 @@ dhcp_handledhcp(struct interface *ifp, struct bootp *bootp, size_t bootp_len,
30793079
const uint8_t *auth;
30803080
size_t auth_len;
30813081
#endif
3082+
#ifdef IPV4LL
3083+
uint8_t tmp;
3084+
#endif
30823085
#ifdef IN_IFF_DUPLICATED
30833086
struct ipv4_addr *ia;
30843087
#endif

src/if-options.c

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -650,31 +650,37 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
650650
ssize_t s;
651651
struct in_addr addr, addr2;
652652
in_addr_t *naddr;
653-
struct rt *rt;
654653
const struct dhcp_opt *d, *od;
655654
uint8_t *request, *require, *no, *reject;
656655
struct dhcp_opt **dop, *ndop;
657656
size_t *dop_len, dl, odl;
658-
struct vivco *vivco;
659-
const struct vivco *vivco_endp = ifo->vivco + ifo->vivco_len;
660657
struct group *grp;
661658
#ifdef AUTH
662659
struct token *token;
663660
#endif
664661
#ifdef _REENTRANT
665662
struct group grpbuf;
666663
#endif
664+
#ifdef INET
665+
struct rt *rt;
666+
#endif
667667
#ifdef DHCP6
668-
size_t sl;
669668
struct if_ia *ia;
670669
uint8_t iaid[4];
670+
#endif
671+
#if defined(DHCP6) || ((defined(INET) || defined(INET6)) && !defined(SMALL))
672+
size_t sl;
673+
#endif
671674
#ifndef SMALL
672-
struct in6_addr in6addr;
675+
#ifdef DHCP6
673676
struct if_sla *sla, *slap;
677+
#endif
678+
struct vivco *vivco;
679+
const struct vivco *vivco_endp = ifo->vivco + ifo->vivco_len;
680+
struct in6_addr in6addr;
674681
struct vsio **vsiop = NULL, *vsio;
675682
size_t *vsio_lenp = NULL, opt_max, opt_header;
676683
struct vsio_so *vsio_so;
677-
#endif
678684
#endif
679685

680686
dop = NULL;
@@ -1308,6 +1314,7 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
13081314
strncmp(arg, "ms_classless_static_routes=",
13091315
strlen("ms_classless_static_routes=")) == 0)
13101316
{
1317+
#ifdef INET
13111318
struct in_addr addr3;
13121319

13131320
if (p == NULL) {
@@ -1337,7 +1344,12 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
13371344
sa_in_init(&rt->rt_gateway, &addr3);
13381345
if (rt_proto_add_ctx(&ifo->routes, rt, ctx))
13391346
add_environ(&ifo->config, arg, 0);
1347+
#else
1348+
logerrx("no inet support for option: %s", arg);
1349+
return -1;
1350+
#endif
13401351
} else if (strncmp(arg, "routers=", strlen("routers=")) == 0) {
1352+
#ifdef INET
13411353
if (p == NULL) {
13421354
rt_headclear(&ifo->routes, AF_INET);
13431355
add_environ(&ifo->config, arg, 1);
@@ -1353,6 +1365,10 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
13531365
sa_in_init(&rt->rt_gateway, &addr);
13541366
if (rt_proto_add_ctx(&ifo->routes, rt, ctx))
13551367
add_environ(&ifo->config, arg, 0);
1368+
#else
1369+
logerrx("no inet support for option: %s", arg);
1370+
return -1;
1371+
#endif
13561372
} else if (strncmp(arg, "interface_mtu=",
13571373
strlen("interface_mtu=")) == 0 ||
13581374
strncmp(arg, "mtu=", strlen("mtu=")) == 0)
@@ -1366,6 +1382,7 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
13661382
return -1;
13671383
}
13681384
} else if (strncmp(arg, "ip6_address=", strlen("ip6_address=")) == 0) {
1385+
#ifdef INET6
13691386
if (p == NULL) {
13701387
memset(&ifo->req_addr6, 0,
13711388
sizeof(ifo->req_addr6));
@@ -1396,6 +1413,10 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
13961413
sizeof(ifo->req_addr6));
13971414
return -1;
13981415
}
1416+
#else
1417+
logerrx("no inet6 support for option: %s", arg);
1418+
return -1;
1419+
#endif
13991420
} else
14001421
add_environ(&ifo->config, arg, p == NULL ? 1 : 0);
14011422
break;
@@ -2951,11 +2972,11 @@ free_options(struct dhcpcd_ctx *ctx, struct if_options *ifo)
29512972
struct rt *rt;
29522973
#endif
29532974
struct dhcp_opt *opt;
2954-
struct vivco *vo;
29552975
#ifdef AUTH
29562976
struct token *token;
29572977
#endif
29582978
#ifndef SMALL
2979+
struct vivco *vo;
29592980
struct vsio *vsio;
29602981
struct vsio_so *vsio_so;
29612982
#endif

src/ipv6.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ ipv6_deletedaddr(struct ipv6_addr *ia)
626626
#endif
627627

628628
#if !defined(DHCP6) || (!defined(PRIVSEP) && defined(SMALL))
629-
UNUSED(ia)
629+
UNUSED(ia);
630630
#endif
631631
}
632632

src/privsep-inet.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ ps_inet_startcb(struct ps_process *psp)
215215
return ret;
216216
}
217217

218+
#if defined(INET) || defined(DHCP6)
218219
static bool
219220
ps_inet_validudp(struct msghdr *msg, uint16_t sport, uint16_t dport)
220221
{
@@ -233,6 +234,7 @@ ps_inet_validudp(struct msghdr *msg, uint16_t sport, uint16_t dport)
233234
}
234235
return true;
235236
}
237+
#endif
236238

237239
#ifdef INET6
238240
static bool

0 commit comments

Comments
 (0)