Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp340044rwi; Wed, 12 Oct 2022 21:36:46 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7SqT5dR9xkmx1Dn7sjTM7JmU2SB0iaB6IAhXNm9ccCT6ISK4FoHLU75NqrmP0U9424F+kf X-Received: by 2002:a05:6402:2803:b0:45c:91f9:8296 with SMTP id h3-20020a056402280300b0045c91f98296mr8612227ede.1.1665635806195; Wed, 12 Oct 2022 21:36:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665635806; cv=none; d=google.com; s=arc-20160816; b=jPVfL2LPA1HAIGjfZD1ef3LtjDUmBAhPFS7UQ2SpCwxcDG8P/m7a2PThXb0Mxmki8R wbxal+N1Vv/QN6lC8x0SljcbBe16GOtdh91MVfUYobX8h4Q1q3nzaapIJWCFgSAj6LIp SLiWckH0dqHETA0DVzXr24mIgkbsjqpdMEInAIP78CQfVAEEuiLFhQXtJZ67/TLHrIsY 2gUpdW0i4246P+jAmUx4zY7otI6oOqlrRtvyCY0c0G3RLPrJi4Ss1z8aCAAmiqko0mbJ Z0pVZ1o+gZo6aXVsuOf8cUiAodSP+URAvUg0G45xB9ODk2YnQtVM813Pjx1vJ1Dp4sci qxhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=/O1n3rBWMHcjPyQp3FqpD97INhqQR2lEH3yP8Yxg8Fo=; b=e1jh5iFPKKZOyNnNbGKLS65cTzdNuXsMBiE+dF9ERINoFNoqmO0NL/wnnRdtoArlIW rs7SpeOcmaJg2ex3LjfDJVwFT4AJmTG6JFwWqgm87HNjI3dg2lKT0rsuJmXgKkKK4BCI fBfsVmfiNMnZ0BAVSnjT5P5lSx5U4AEpDDRe4X1gWgm4sKQJ6nMY2s+/AowdBhkVmX46 tfawWbzoVODxTf6KdY7x/87cK25ZO7hrDcjSV0DsqWMyx9ceA15fOFYc/UNkiLWyuozB wQDUwG/zMNn6nOKgSMRedwN7Mk9kMU5mFOBfBLc1n4ZYf7fliTVrA9MSgzD/u1Ug0vOL XCCw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a19-20020aa7d753000000b0045c234508e2si7716428eds.627.2022.10.12.21.36.19; Wed, 12 Oct 2022 21:36:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229529AbiJMEGJ (ORCPT + 99 others); Thu, 13 Oct 2022 00:06:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229502AbiJMEGF (ORCPT ); Thu, 13 Oct 2022 00:06:05 -0400 Received: from mail.nfschina.com (mail.nfschina.com [124.16.136.209]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9A9FD100BCC for ; Wed, 12 Oct 2022 21:06:02 -0700 (PDT) Received: from localhost (unknown [127.0.0.1]) by mail.nfschina.com (Postfix) with ESMTP id F2E5C1E80D99; Thu, 13 Oct 2022 12:06:04 +0800 (CST) X-Virus-Scanned: amavisd-new at test.com Received: from mail.nfschina.com ([127.0.0.1]) by localhost (mail.nfschina.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id AfHexhvLqMdh; Thu, 13 Oct 2022 12:06:02 +0800 (CST) Received: from localhost.localdomain (unknown [219.141.250.2]) (Authenticated sender: zeming@nfschina.com) by mail.nfschina.com (Postfix) with ESMTPA id 0E21A1E80D90; Thu, 13 Oct 2022 12:06:02 +0800 (CST) From: Li zeming To: hubcap@omnibond.com, martin@omnibond.com Cc: devel@lists.orangefs.org, linux-kernel@vger.kernel.org, Li zeming Subject: [PATCH] orangefs: inode: Optimized variable usage in orangefs_* correlation functions Date: Thu, 13 Oct 2022 12:05:51 +0800 Message-Id: <20221013040551.277251-1-zeming@nfschina.com> X-Mailer: git-send-email 2.18.2 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org These functions are optimized as follows. 1. Remove some variables to initialize the assignment, they are assigned first. 2. Removes the cast part of a variable assignment of type void*. 3. The orangefs_inode variable is directly assigned at the definition. Signed-off-by: Li zeming --- fs/orangefs/inode.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/fs/orangefs/inode.c b/fs/orangefs/inode.c index 7a8c0c6e698d..ea557b3b989e 100644 --- a/fs/orangefs/inode.c +++ b/fs/orangefs/inode.c @@ -719,7 +719,7 @@ static int orangefs_setattr_size(struct inode *inode, struct iattr *iattr) struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode); struct orangefs_kernel_op_s *new_op; loff_t orig_size; - int ret = -EINVAL; + int ret; gossip_debug(GOSSIP_INODE_DEBUG, "%s: %pU: Handle is %pU | fs_id %d | size is %llu\n", @@ -1021,7 +1021,7 @@ static inline ino_t orangefs_handle_hash(struct orangefs_object_kref *ref) */ static int orangefs_set_inode(struct inode *inode, void *data) { - struct orangefs_object_kref *ref = (struct orangefs_object_kref *) data; + struct orangefs_object_kref *ref = data; ORANGEFS_I(inode)->refn.fs_id = ref->fs_id; ORANGEFS_I(inode)->refn.khandle = ref->khandle; ORANGEFS_I(inode)->attr_valid = 0; @@ -1036,10 +1036,9 @@ static int orangefs_set_inode(struct inode *inode, void *data) */ static int orangefs_test_inode(struct inode *inode, void *data) { - struct orangefs_object_kref *ref = (struct orangefs_object_kref *) data; - struct orangefs_inode_s *orangefs_inode = NULL; + struct orangefs_object_kref *ref = data; + struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode); - orangefs_inode = ORANGEFS_I(inode); /* test handles and fs_ids... */ return (!ORANGEFS_khandle_cmp(&(orangefs_inode->refn.khandle), &(ref->khandle)) && @@ -1056,7 +1055,7 @@ static int orangefs_test_inode(struct inode *inode, void *data) struct inode *orangefs_iget(struct super_block *sb, struct orangefs_object_kref *ref) { - struct inode *inode = NULL; + struct inode *inode; unsigned long hash; int error; -- 2.18.2