From owner-svn-src-head@freebsd.org Thu Oct 24 22:23:54 2019 Return-Path: Delivered-To: svn-src-head@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 2F01B15BE5A; Thu, 24 Oct 2019 22:23:54 +0000 (UTC) (envelope-from brooks@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) server-signature RSA-PSS (4096 bits) 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 46zhbt08pVz3D7W; Thu, 24 Oct 2019 22:23:54 +0000 (UTC) (envelope-from brooks@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 DCCE41CF83; Thu, 24 Oct 2019 22:23:53 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9OMNrln020093; Thu, 24 Oct 2019 22:23:53 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9OMNrcn020092; Thu, 24 Oct 2019 22:23:53 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <201910242223.x9OMNrcn020092@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Thu, 24 Oct 2019 22:23:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r354054 - head/sys/cam/nvme X-SVN-Group: head X-SVN-Commit-Author: brooks X-SVN-Commit-Paths: head/sys/cam/nvme X-SVN-Commit-Revision: 354054 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 22:23:54 -0000 Author: brooks Date: Thu Oct 24 22:23:53 2019 New Revision: 354054 URL: https://svnweb.freebsd.org/changeset/base/354054 Log: nda(4): Remove unnecessary union and avoid Clang -Wsizeof-array-divwarning Clang trunk recently gained this new warning, and complains about the sizeof(trim->data) / sizeof(struct nvme_dsm_range) expression, since the left hand side's element type (char) does not match the right hand side's type. The byte buffer is unnecessary so we can remove it to clean up the code and fix the warning at the same time. No functional change. Submitted by: James Clarke Reviewed by: imp Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D21912 Modified: head/sys/cam/nvme/nvme_da.c Modified: head/sys/cam/nvme/nvme_da.c ============================================================================== --- head/sys/cam/nvme/nvme_da.c Thu Oct 24 22:07:45 2019 (r354053) +++ head/sys/cam/nvme/nvme_da.c Thu Oct 24 22:23:53 2019 (r354054) @@ -129,12 +129,11 @@ struct nda_softc { }; struct nda_trim_request { - union { - struct nvme_dsm_range dsm; - uint8_t data[NVME_MAX_DSM_TRIM]; - }; + struct nvme_dsm_range dsm[NVME_MAX_DSM_TRIM / sizeof(struct nvme_dsm_range)]; TAILQ_HEAD(, bio) bps; }; +_Static_assert(NVME_MAX_DSM_TRIM % sizeof(struct nvme_dsm_range) == 0, + "NVME_MAX_DSM_TRIM must be an integral number of ranges"); /* Need quirk table */ @@ -957,9 +956,8 @@ ndastart(struct cam_periph *periph, union ccb *start_c } TAILQ_INIT(&trim->bps); bp1 = bp; - ents = sizeof(trim->data) / sizeof(struct nvme_dsm_range); - ents = min(ents, nda_max_trim_entries); - dsm_range = &trim->dsm; + ents = min(nitems(trim->dsm), nda_max_trim_entries); + dsm_range = trim->dsm; dsm_end = dsm_range + ents; do { TAILQ_INSERT_TAIL(&trim->bps, bp1, bio_queue); @@ -977,8 +975,8 @@ ndastart(struct cam_periph *periph, union ccb *start_c /* XXX -- Could limit based on total payload size */ } while (bp1 != NULL); start_ccb->ccb_trim = trim; - nda_nvme_trim(softc, &start_ccb->nvmeio, &trim->dsm, - dsm_range - &trim->dsm); + nda_nvme_trim(softc, &start_ccb->nvmeio, trim->dsm, + dsm_range - trim->dsm); start_ccb->ccb_state = NDA_CCB_TRIM; softc->trim_count++; softc->trim_ranges += ranges;