Date: Tue, 29 Dec 2020 23:06:44 GMT From: Ryan Libby <rlibby@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 0286ee71041c - stable/12 - [libnetmap] Fix 32 bit compilation under gcc-6.4 Message-ID: <202012292306.0BTN6igT093324@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/12 has been updated by rlibby: URL: https://cgit.FreeBSD.org/src/commit/?id=0286ee71041c8b831aeb1abe75b9d4f555c88a97 commit 0286ee71041c8b831aeb1abe75b9d4f555c88a97 Author: Adrian Chadd <adrian@FreeBSD.org> AuthorDate: 2020-11-02 15:01:37 +0000 Commit: Ryan Libby <rlibby@FreeBSD.org> CommitDate: 2020-12-29 23:04:40 +0000 [libnetmap] Fix 32 bit compilation under gcc-6.4 Use uintptr_t to cast a uint64_t to a pointer type. Yeah, it isn't technically correct for platforms with pointers > 64 bits, but it's fine here. This fixes 32 bit compat library builds on amd64 and also mips32 builds. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D26790 (cherry picked from commit 26c29e743bbdbb82762540f72d4bc449bae2e092) --- lib/libnetmap/nmreq.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/libnetmap/nmreq.c b/lib/libnetmap/nmreq.c index 259056de37b4..7f4b2703d22d 100644 --- a/lib/libnetmap/nmreq.c +++ b/lib/libnetmap/nmreq.c @@ -603,10 +603,9 @@ nmreq_options_decode(const char *opt, struct nmreq_opt_parser parsers[], struct nmreq_option * nmreq_find_option(struct nmreq_header *h, uint32_t t) { - struct nmreq_option *o; + struct nmreq_option *o = NULL; - for (o = (struct nmreq_option *)h->nr_options; o != NULL; - o = (struct nmreq_option *)o->nro_next) { + nmreq_foreach_option(h, o) { if (o->nro_reqtype == t) break; } @@ -633,8 +632,14 @@ nmreq_free_options(struct nmreq_header *h) { struct nmreq_option *o, *next; - for (o = (struct nmreq_option *)h->nr_options; o != NULL; o = next) { - next = (struct nmreq_option *)o->nro_next; + /* + * Note: can't use nmreq_foreach_option() here; it frees the + * list as it's walking and nmreq_foreach_option() isn't + * modification-safe. + */ + for (o = (struct nmreq_option *)(uintptr_t)h->nr_options; o != NULL; + o = next) { + next = (struct nmreq_option *)(uintptr_t)o->nro_next; free(o); } }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202012292306.0BTN6igT093324>