From nobody Fri Feb 3 16:17:51 2023 X-Original-To: dev-commits-src-main@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 4P7gmc1sM2z3kTj0; Fri, 3 Feb 2023 16:17: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 4P7gmc12hbz3pVF; Fri, 3 Feb 2023 16:17:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675441072; 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=dh9bAQU+WD/A0jNAHvknYFt/NOjsmgunTkEBtDZnYts=; b=lq7L9dHP4IwUX1B9RT9F8xoesMdokjHQgolYgPQJSbbRl8KIYPlLK7SEJlwrLy+fDF4nsT YZ4XJRDOYHXcAeF913dqSc6wd7HR2a3aJqBj3AzqBeWzIBhfJEUAk5r5I0t0KHGk3+14Fd ZMtnRwzbbo76/LKDfzGeXRCmUFJwlpOpY+70Cf1K3zyUth5EcPZSMeQQNpxLGHOM5EzYi5 pUFmD+6S+8vBUwCuqlK/CipVHRZkg7vkPPlnEE2eMHlVAYoaJMlmZhTOXi53GQtlIMhBu5 Q/25mXvQA2P95lp/K6r61JcSNnkxh1ekJZv5zUKnxDfHPMZey7dwROlhxlQQPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675441072; 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=dh9bAQU+WD/A0jNAHvknYFt/NOjsmgunTkEBtDZnYts=; b=rI+rcLt1jVVZzdXpKuRFG/MzufYrtc/Bls5N4PESEPrrPxH4vhpJ7/oMF7W9Gzn9mqj627 TTWPMT5I/IV1bpa8V6T1ifYpFIgIU46xHr6B5vR1OpTh1GlVIZXHpWDtyy5hTrWJAEx4x4 jgYSBhF7drsVqZHO7N6CssWNcStG+DvTH0tlTA5y2oRGSeYnpvSDunkLgydYoP7/xD0JdL 0+2cc4/raHT4yLNw098Z465qnsUCdpnnOxeEJjbCufudD1uW8sn7ftIjGxUrP4mKVcw7+o lE/NsPRbyHwa5UUuU+O9Og+ZcsogRwJlI1CaRAIk0wb8uqJ5lKfxAoH6FgV6hw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1675441072; a=rsa-sha256; cv=none; b=GS2J8febrMxZeM6Cgtfn2+HWjvCI683EBgX4iw0LQR5w7M/nKcx2fsh5VVYTSlxgkpM875 yjWJ1RBHPBCg38Wf9uIVxDWcfdMsvsdMLl8Cu+Mbu7txUfx1VLaTASoiTJQT7KRFrn56ro UIz14VCN+9GVoEX1rggaUbP51wXNphnPtZob0xBLUMuOkuV/XdmlSAmNeawRD2uDQjLowx C/Rqeslr90gA+nvTAeb6fMGW1HjunMVP6t1xiH8Ib6nLISVZsNQ60in0jkw/srHr/MjSRE DHyxKSzEJr2FyGrUaHZN3TJR4ue6wjORxzCIcVHFNMFmthdosnwQJI8lLxrFmQ== 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 4P7gmb74WFzgv6; Fri, 3 Feb 2023 16:17:51 +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 313GHp3v057542; Fri, 3 Feb 2023 16:17:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 313GHpa1057541; Fri, 3 Feb 2023 16:17:51 GMT (envelope-from git) Date: Fri, 3 Feb 2023 16:17:51 GMT Message-Id: <202302031617.313GHpa1057541@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: eb08932156dc - main - linux(4): Microoptimize linux_ipc code to unindent else blocks. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: eb08932156dc5801418924cf0bf9f167b15f7bf0 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=eb08932156dc5801418924cf0bf9f167b15f7bf0 commit eb08932156dc5801418924cf0bf9f167b15f7bf0 Author: Dmitry Chagin AuthorDate: 2023-02-03 16:17:34 +0000 Commit: Dmitry Chagin CommitDate: 2023-02-03 16:17:34 +0000 linux(4): Microoptimize linux_ipc code to unindent else blocks. No functional change. MFC after: 1 week --- 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))