From nobody Thu Feb 9 07:56:52 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PC8Mm4swHz3myBM; Thu, 9 Feb 2023 07:56:52 +0000 (UTC) (envelope-from git@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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PC8Mm3QJKz45HF; Thu, 9 Feb 2023 07:56:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675929412; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=xxfoHLlWIizCa94N74l5AGiIcQ3MF4v2gLDaPoXxje8=; b=yDdaz1MZAUH1m0M8qLP6rbz0dyaV19yPc9x1GllwqVvp9DQcjq1uMYpq5Sh3btUg+GlfwJ PctZTIUBrQ4OaYEK/WbanKziatRzOP1kLi4PbSby1k3+Ja1LwaRNo09kOO3dl7L668r5TV 5fRIXbNGi64Bd97UHPaqQ2iErRcURB3+xnmsAb7S1U+UDJg6BTn9s2VUrNwessRKSqA4R3 js95adrArVcplYuffuZUfNK1EhQabAc8Ur+kcQB0qWv85G2ko04hQfRtPQpoUvLr5KCzzh aNWV9UW/M+PCxmS/L1xHdXLreuk5+l+P02cXcdyU7FRXUv0K9Z796cwhnfE3vQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675929412; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=xxfoHLlWIizCa94N74l5AGiIcQ3MF4v2gLDaPoXxje8=; b=JetOwoGinpTGpihkxTZ9qwJH3lMA99I+XhZeOfgh34QdSvtdELyQnUPBdzwJoaq9OAymiL wZNGvmfLBHJWjC2rKpQvuGXXMVg6vDUcQg8gHOkEm2GSkZ8U6ZeVkAsVJPMPCArXsEos0o sH0falVoF7lYvOADLG+1LTMSr5sImJmNE9h6BjAfpovATOZCX5ZsszVsCmZGXX/mQDdocJ OCKbFAqhGtlEbuYsXMM6F6QQlry5Vk07x+L+1UiEdPv1ovhMYDd/8j8JwIpMQIMadW0qch grXebVlSw6tFT83femk+f4fOjruCI2tuc62TAU52Z5bEJ8xn2lrrU60Il5GNBQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1675929412; a=rsa-sha256; cv=none; b=vCO/DG3fcOoTvlELg+BGGvmHKAAe885ssayp3d4p36S5WcQLGc3SY/6qkLO30G8h+hDUwo gFDhnGd7OkFpaULn6JwGNUxdAm7aBUq7IYCx0PfujjcK6tAv4EXtJEzYFz7vItb498UrIZ SHHrBTfzxp9WbEh6oUWljPn+E5CpHw6nkP4PO0qeSSjhNqHG7+oD7O1lmwklaqfxHMoi/x 3fqnSWYYikRKHwAkJ4roYNt4X+ZJnQW+NbkGF04H9OZCoMTGhgMpuMr+QDEaKa0Vsu5jzp buKInYmTak5XhjxNEdgcmo1D5fwQDLOrYyTi8VbGdcSk13PVxd0MKQZq4wMiwQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4PC8Mm2PV6zV8F; Thu, 9 Feb 2023 07:56:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 3197uqKg093100; Thu, 9 Feb 2023 07:56:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 3197uqKG093099; Thu, 9 Feb 2023 07:56:52 GMT (envelope-from git) Date: Thu, 9 Feb 2023 07:56:52 GMT Message-Id: <202302090756.3197uqKG093099@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dmitry Chagin Subject: git: f4ecf4ab9e02 - stable/13 - linux(4): Microoptimize linux_ipc code to unindent else blocks. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: f4ecf4ab9e0233d1ab55f7fb63b3f7612a650211 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=f4ecf4ab9e0233d1ab55f7fb63b3f7612a650211 commit f4ecf4ab9e0233d1ab55f7fb63b3f7612a650211 Author: Dmitry Chagin AuthorDate: 2023-02-03 16:17:34 +0000 Commit: Dmitry Chagin CommitDate: 2023-02-09 07:55:25 +0000 linux(4): Microoptimize linux_ipc code to unindent else blocks. No functional change. MFC after: 1 week (cherry picked from commit eb08932156dc5801418924cf0bf9f167b15f7bf0) --- sys/compat/linux/linux_ipc.c | 226 ++++++++++++++++++++----------------------- 1 file changed, 103 insertions(+), 123 deletions(-) diff --git a/sys/compat/linux/linux_ipc.c b/sys/compat/linux/linux_ipc.c index 8c40d7505da5..134e353122c1 100644 --- a/sys/compat/linux/linux_ipc.c +++ b/sys/compat/linux/linux_ipc.c @@ -305,22 +305,20 @@ linux_msqid_pullup(l_int ver, struct l_msqid64_ds *linux_msqid64, caddr_t uaddr) if (ver == LINUX_IPC_64 || SV_CURPROC_FLAG(SV_LP64)) return (copyin(uaddr, linux_msqid64, sizeof(*linux_msqid64))); - else { - error = copyin(uaddr, &linux_msqid, sizeof(linux_msqid)); - if (error != 0) - return (error); - bzero(linux_msqid64, sizeof(*linux_msqid64)); + error = copyin(uaddr, &linux_msqid, sizeof(linux_msqid)); + if (error != 0) + return (error); - linux_msqid64->msg_perm.uid = linux_msqid.msg_perm.uid; - linux_msqid64->msg_perm.gid = linux_msqid.msg_perm.gid; - linux_msqid64->msg_perm.mode = linux_msqid.msg_perm.mode; - if (linux_msqid.msg_qbytes == 0) - linux_msqid64->msg_qbytes = linux_msqid.msg_lqbytes; - else - linux_msqid64->msg_qbytes = linux_msqid.msg_qbytes; - return (0); - } + bzero(linux_msqid64, sizeof(*linux_msqid64)); + linux_msqid64->msg_perm.uid = linux_msqid.msg_perm.uid; + linux_msqid64->msg_perm.gid = linux_msqid.msg_perm.gid; + linux_msqid64->msg_perm.mode = linux_msqid.msg_perm.mode; + if (linux_msqid.msg_qbytes == 0) + linux_msqid64->msg_qbytes = linux_msqid.msg_lqbytes; + else + linux_msqid64->msg_qbytes = linux_msqid.msg_qbytes; + return (0); } static int @@ -331,43 +329,40 @@ linux_msqid_pushdown(l_int ver, struct l_msqid64_ds *linux_msqid64, caddr_t uadd if (ver == LINUX_IPC_64 || SV_CURPROC_FLAG(SV_LP64)) return (copyout(linux_msqid64, uaddr, sizeof(*linux_msqid64))); - else { - bzero(&linux_msqid, sizeof(linux_msqid)); - error = linux_ipc64_perm_to_ipc_perm(&linux_msqid64->msg_perm, - &linux_msqid.msg_perm); - if (error != 0) - return (error); + bzero(&linux_msqid, sizeof(linux_msqid)); + error = linux_ipc64_perm_to_ipc_perm(&linux_msqid64->msg_perm, + &linux_msqid.msg_perm); + if (error != 0) + return (error); - linux_msqid.msg_stime = linux_msqid64->msg_stime; - linux_msqid.msg_rtime = linux_msqid64->msg_rtime; - linux_msqid.msg_ctime = linux_msqid64->msg_ctime; - - if (linux_msqid64->msg_cbytes > USHRT_MAX) - linux_msqid.msg_cbytes = USHRT_MAX; - else - linux_msqid.msg_cbytes = linux_msqid64->msg_cbytes; - linux_msqid.msg_lcbytes = linux_msqid64->msg_cbytes; - if (linux_msqid64->msg_qnum > USHRT_MAX) - linux_msqid.msg_qnum = USHRT_MAX; - else - linux_msqid.msg_qnum = linux_msqid64->msg_qnum; - if (linux_msqid64->msg_qbytes > USHRT_MAX) - linux_msqid.msg_qbytes = USHRT_MAX; - else - linux_msqid.msg_qbytes = linux_msqid64->msg_qbytes; - linux_msqid.msg_lqbytes = linux_msqid64->msg_qbytes; - linux_msqid.msg_lspid = linux_msqid64->msg_lspid; - linux_msqid.msg_lrpid = linux_msqid64->msg_lrpid; - - /* Linux does not check overflow */ - if (linux_msqid.msg_stime != linux_msqid64->msg_stime || - linux_msqid.msg_rtime != linux_msqid64->msg_rtime || - linux_msqid.msg_ctime != linux_msqid64->msg_ctime) - return (EOVERFLOW); - - return (copyout(&linux_msqid, uaddr, sizeof(linux_msqid))); - } + linux_msqid.msg_stime = linux_msqid64->msg_stime; + linux_msqid.msg_rtime = linux_msqid64->msg_rtime; + linux_msqid.msg_ctime = linux_msqid64->msg_ctime; + + if (linux_msqid64->msg_cbytes > USHRT_MAX) + linux_msqid.msg_cbytes = USHRT_MAX; + else + linux_msqid.msg_cbytes = linux_msqid64->msg_cbytes; + linux_msqid.msg_lcbytes = linux_msqid64->msg_cbytes; + if (linux_msqid64->msg_qnum > USHRT_MAX) + linux_msqid.msg_qnum = USHRT_MAX; + else + linux_msqid.msg_qnum = linux_msqid64->msg_qnum; + if (linux_msqid64->msg_qbytes > USHRT_MAX) + linux_msqid.msg_qbytes = USHRT_MAX; + else + linux_msqid.msg_qbytes = linux_msqid64->msg_qbytes; + linux_msqid.msg_lqbytes = linux_msqid64->msg_qbytes; + linux_msqid.msg_lspid = linux_msqid64->msg_lspid; + linux_msqid.msg_lrpid = linux_msqid64->msg_lrpid; + + /* Linux does not check overflow */ + if (linux_msqid.msg_stime != linux_msqid64->msg_stime || + linux_msqid.msg_rtime != linux_msqid64->msg_rtime || + linux_msqid.msg_ctime != linux_msqid64->msg_ctime) + return (EOVERFLOW); + return (copyout(&linux_msqid, uaddr, sizeof(linux_msqid))); } static int @@ -378,18 +373,15 @@ linux_semid_pullup(l_int ver, struct l_semid64_ds *linux_semid64, caddr_t uaddr) if (ver == LINUX_IPC_64 || SV_CURPROC_FLAG(SV_LP64)) return (copyin(uaddr, linux_semid64, sizeof(*linux_semid64))); - else { - error = copyin(uaddr, &linux_semid, sizeof(linux_semid)); - if (error != 0) - return (error); - - bzero(linux_semid64, sizeof(*linux_semid64)); + error = copyin(uaddr, &linux_semid, sizeof(linux_semid)); + if (error != 0) + return (error); - linux_semid64->sem_perm.uid = linux_semid.sem_perm.uid; - linux_semid64->sem_perm.gid = linux_semid.sem_perm.gid; - linux_semid64->sem_perm.mode = linux_semid.sem_perm.mode; - return (0); - } + bzero(linux_semid64, sizeof(*linux_semid64)); + linux_semid64->sem_perm.uid = linux_semid.sem_perm.uid; + linux_semid64->sem_perm.gid = linux_semid.sem_perm.gid; + linux_semid64->sem_perm.mode = linux_semid.sem_perm.mode; + return (0); } static int @@ -400,26 +392,23 @@ linux_semid_pushdown(l_int ver, struct l_semid64_ds *linux_semid64, caddr_t uadd if (ver == LINUX_IPC_64 || SV_CURPROC_FLAG(SV_LP64)) return (copyout(linux_semid64, uaddr, sizeof(*linux_semid64))); - else { - bzero(&linux_semid, sizeof(linux_semid)); + bzero(&linux_semid, sizeof(linux_semid)); error = linux_ipc64_perm_to_ipc_perm(&linux_semid64->sem_perm, - &linux_semid.sem_perm); - if (error != 0) - return (error); - - linux_semid.sem_otime = linux_semid64->sem_otime; - linux_semid.sem_ctime = linux_semid64->sem_ctime; - linux_semid.sem_nsems = linux_semid64->sem_nsems; + &linux_semid.sem_perm); + if (error != 0) + return (error); - /* Linux does not check overflow */ - if (linux_semid.sem_otime != linux_semid64->sem_otime || - linux_semid.sem_ctime != linux_semid64->sem_ctime || - linux_semid.sem_nsems != linux_semid64->sem_nsems) - return (EOVERFLOW); + linux_semid.sem_otime = linux_semid64->sem_otime; + linux_semid.sem_ctime = linux_semid64->sem_ctime; + linux_semid.sem_nsems = linux_semid64->sem_nsems; - return (copyout(&linux_semid, uaddr, sizeof(linux_semid))); - } + /* Linux does not check overflow */ + if (linux_semid.sem_otime != linux_semid64->sem_otime || + linux_semid.sem_ctime != linux_semid64->sem_ctime || + linux_semid.sem_nsems != linux_semid64->sem_nsems) + return (EOVERFLOW); + return (copyout(&linux_semid, uaddr, sizeof(linux_semid))); } static int @@ -430,18 +419,16 @@ linux_shmid_pullup(l_int ver, struct l_shmid64_ds *linux_shmid64, caddr_t uaddr) if (ver == LINUX_IPC_64 || SV_CURPROC_FLAG(SV_LP64)) return (copyin(uaddr, linux_shmid64, sizeof(*linux_shmid64))); - else { - error = copyin(uaddr, &linux_shmid, sizeof(linux_shmid)); - if (error != 0) - return (error); - bzero(linux_shmid64, sizeof(*linux_shmid64)); + error = copyin(uaddr, &linux_shmid, sizeof(linux_shmid)); + if (error != 0) + return (error); - linux_shmid64->shm_perm.uid = linux_shmid.shm_perm.uid; - linux_shmid64->shm_perm.gid = linux_shmid.shm_perm.gid; - linux_shmid64->shm_perm.mode = linux_shmid.shm_perm.mode; - return (0); - } + bzero(linux_shmid64, sizeof(*linux_shmid64)); + linux_shmid64->shm_perm.uid = linux_shmid.shm_perm.uid; + linux_shmid64->shm_perm.gid = linux_shmid.shm_perm.gid; + linux_shmid64->shm_perm.mode = linux_shmid.shm_perm.mode; + return (0); } static int @@ -452,34 +439,31 @@ linux_shmid_pushdown(l_int ver, struct l_shmid64_ds *linux_shmid64, caddr_t uadd if (ver == LINUX_IPC_64 || SV_CURPROC_FLAG(SV_LP64)) return (copyout(linux_shmid64, uaddr, sizeof(*linux_shmid64))); - else { - bzero(&linux_shmid, sizeof(linux_shmid)); - error = linux_ipc64_perm_to_ipc_perm(&linux_shmid64->shm_perm, - &linux_shmid.shm_perm); - if (error != 0) - return (error); + bzero(&linux_shmid, sizeof(linux_shmid)); + error = linux_ipc64_perm_to_ipc_perm(&linux_shmid64->shm_perm, + &linux_shmid.shm_perm); + if (error != 0) + return (error); - linux_shmid.shm_segsz = linux_shmid64->shm_segsz; - linux_shmid.shm_atime = linux_shmid64->shm_atime; - linux_shmid.shm_dtime = linux_shmid64->shm_dtime; - linux_shmid.shm_ctime = linux_shmid64->shm_ctime; - linux_shmid.shm_cpid = linux_shmid64->shm_cpid; - linux_shmid.shm_lpid = linux_shmid64->shm_lpid; - linux_shmid.shm_nattch = linux_shmid64->shm_nattch; - - /* Linux does not check overflow */ - if (linux_shmid.shm_segsz != linux_shmid64->shm_segsz || - linux_shmid.shm_atime != linux_shmid64->shm_atime || - linux_shmid.shm_dtime != linux_shmid64->shm_dtime || - linux_shmid.shm_ctime != linux_shmid64->shm_ctime || - linux_shmid.shm_cpid != linux_shmid64->shm_cpid || - linux_shmid.shm_lpid != linux_shmid64->shm_lpid || - linux_shmid.shm_nattch != linux_shmid64->shm_nattch) - return (EOVERFLOW); - - return (copyout(&linux_shmid, uaddr, sizeof(linux_shmid))); - } + linux_shmid.shm_segsz = linux_shmid64->shm_segsz; + linux_shmid.shm_atime = linux_shmid64->shm_atime; + linux_shmid.shm_dtime = linux_shmid64->shm_dtime; + linux_shmid.shm_ctime = linux_shmid64->shm_ctime; + linux_shmid.shm_cpid = linux_shmid64->shm_cpid; + linux_shmid.shm_lpid = linux_shmid64->shm_lpid; + linux_shmid.shm_nattch = linux_shmid64->shm_nattch; + + /* Linux does not check overflow */ + if (linux_shmid.shm_segsz != linux_shmid64->shm_segsz || + linux_shmid.shm_atime != linux_shmid64->shm_atime || + linux_shmid.shm_dtime != linux_shmid64->shm_dtime || + linux_shmid.shm_ctime != linux_shmid64->shm_ctime || + linux_shmid.shm_cpid != linux_shmid64->shm_cpid || + linux_shmid.shm_lpid != linux_shmid64->shm_lpid || + linux_shmid.shm_nattch != linux_shmid64->shm_nattch) + return (EOVERFLOW); + return (copyout(&linux_shmid, uaddr, sizeof(linux_shmid))); } static int @@ -491,18 +475,14 @@ linux_shminfo_pushdown(l_int ver, struct l_shminfo64 *linux_shminfo64, if (ver == LINUX_IPC_64 || SV_CURPROC_FLAG(SV_LP64)) return (copyout(linux_shminfo64, uaddr, sizeof(*linux_shminfo64))); - else { - bzero(&linux_shminfo, sizeof(linux_shminfo)); - linux_shminfo.shmmax = linux_shminfo64->shmmax; - linux_shminfo.shmmin = linux_shminfo64->shmmin; - linux_shminfo.shmmni = linux_shminfo64->shmmni; - linux_shminfo.shmseg = linux_shminfo64->shmseg; - linux_shminfo.shmall = linux_shminfo64->shmall; - - return (copyout(&linux_shminfo, uaddr, - sizeof(linux_shminfo))); - } + bzero(&linux_shminfo, sizeof(linux_shminfo)); + linux_shminfo.shmmax = linux_shminfo64->shmmax; + linux_shminfo.shmmin = linux_shminfo64->shmmin; + linux_shminfo.shmmni = linux_shminfo64->shmmni; + linux_shminfo.shmseg = linux_shminfo64->shmseg; + linux_shminfo.shmall = linux_shminfo64->shmall; + return (copyout(&linux_shminfo, uaddr, sizeof(linux_shminfo))); } #if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32))