From owner-svn-src-all@freebsd.org Mon Nov 2 15:01:38 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 20276453CFB; Mon, 2 Nov 2020 15:01:38 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CPx2T5wJVz4dLD; Mon, 2 Nov 2020 15:01:37 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id AE6BFB2A9; Mon, 2 Nov 2020 15:01:37 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0A2F1b07059569; Mon, 2 Nov 2020 15:01:37 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0A2F1bvQ059568; Mon, 2 Nov 2020 15:01:37 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <202011021501.0A2F1bvQ059568@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd Date: Mon, 2 Nov 2020 15:01:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367273 - head/lib/libnetmap X-SVN-Group: head X-SVN-Commit-Author: adrian X-SVN-Commit-Paths: head/lib/libnetmap X-SVN-Commit-Revision: 367273 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Nov 2020 15:01:38 -0000 Author: adrian Date: Mon Nov 2 15:01:37 2020 New Revision: 367273 URL: https://svnweb.freebsd.org/changeset/base/367273 Log: [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 Modified: head/lib/libnetmap/nmreq.c Modified: head/lib/libnetmap/nmreq.c ============================================================================== --- head/lib/libnetmap/nmreq.c Mon Nov 2 14:30:55 2020 (r367272) +++ head/lib/libnetmap/nmreq.c Mon Nov 2 15:01:37 2020 (r367273) @@ -603,10 +603,9 @@ nmreq_options_decode(const char *opt, struct nmreq_opt 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); } }