From patchwork Wed Nov 13 16:29:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hal Rosenstock X-Patchwork-Id: 3178781 X-Patchwork-Delegate: hal@mellanox.com Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BCB2E9F43F for ; Wed, 13 Nov 2013 16:30:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 22C142076E for ; Wed, 13 Nov 2013 16:30:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 76A0620774 for ; Wed, 13 Nov 2013 16:30:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757569Ab3KMQaA (ORCPT ); Wed, 13 Nov 2013 11:30:00 -0500 Received: from mail-bk0-f53.google.com ([209.85.214.53]:49611 "EHLO mail-bk0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757536Ab3KMQ3y (ORCPT ); Wed, 13 Nov 2013 11:29:54 -0500 Received: by mail-bk0-f53.google.com with SMTP id na10so473782bkb.12 for ; Wed, 13 Nov 2013 08:29:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:content-type:content-transfer-encoding; bh=G0Tf+dbDRY46WcqmfBPpvAOHRh4kJztlUWERJDC/hUw=; b=fTiDlkYY7w6DQvypOwT1v8jTPsnh/WMbiQE4cVDJi3KB6fHqAI9pvbCCOE5wxSlJXD kYPdfAoccwmUqU7IMhSxZYiFwhABVxcWpwbAUPyRo3D6alNpVxLOXewoFZBJnBhb/z9L AzngpHseUEG34Q6W+SloiB7n9DAnVUAxcSSfADCfgqNrL46M41TjOX8d8b94Bkv/cz3f M+AiXPd2NhkKNvqrycS5VWipd7gEOLxwO7A1cNWv8/JrmI6yxsPZJtMU28fGJDj3btFn Kr4qmTNYyiz7iDq4trHIKBiKWbyLLRKGA+y8jPVvzRkrd7Hs3WvFZtGevNMrPV7r/SZ6 TWUQ== X-Gm-Message-State: ALoCoQnFupxl6dFPPtDyG3A8iiBy1VqCQ1u1KNGP74P5sL1ePtHScEGUQ77YGgK77nX/ldldOcm4 X-Received: by 10.205.86.6 with SMTP id aq6mr17847bkc.71.1384360192731; Wed, 13 Nov 2013 08:29:52 -0800 (PST) Received: from [192.168.1.102] (c-98-229-118-119.hsd1.ma.comcast.net. [98.229.118.119]) by mx.google.com with ESMTPSA id pn6sm23915628bkb.14.2013.11.13.08.29.51 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 13 Nov 2013 08:29:52 -0800 (PST) Message-ID: <5283A8FF.6010001@dev.mellanox.co.il> Date: Wed, 13 Nov 2013 11:29:51 -0500 From: Hal Rosenstock User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:9.0) Gecko/20111222 Thunderbird/9.0.1 MIME-Version: 1.0 To: "linux-rdma (linux-rdma@vger.kernel.org)" CC: Vladimir Koushnir Subject: [PATCH opensm 1/2] Redundant remove() function call during db file generation Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Vladimir Koushnir Signed-off-by: Vladimir Koushnir --- opensm/osm_db_files.c | 17 +++++------------ 1 files changed, 5 insertions(+), 12 deletions(-) diff --git a/opensm/osm_db_files.c b/opensm/osm_db_files.c index 75b58cd..348385f 100644 --- a/opensm/osm_db_files.c +++ b/opensm/osm_db_files.c @@ -45,6 +45,7 @@ #include #include +#include #include #include #include @@ -480,8 +481,8 @@ int osm_db_store(IN osm_db_domain_t * p_domain) p_file = fopen(p_tmp_file_name, "w"); if (!p_file) { OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 6107: " - "Failed to open the db file:%s for writing\n", - p_domain_imp->file_name); + "Failed to open the db file:%s for writing: err:%s\n", + p_domain_imp->file_name, strerror(errno)); status = 1; goto Exit; } @@ -489,19 +490,11 @@ int osm_db_store(IN osm_db_domain_t * p_domain) st_foreach(p_domain_imp->p_hash, dump_tbl_entry, (st_data_t) p_file); fclose(p_file); - /* move the domain file */ - status = remove(p_domain_imp->file_name); - if (status) { - OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 6109: " - "Failed to remove file:%s (err:%u)\n", - p_domain_imp->file_name, status); - } - status = rename(p_tmp_file_name, p_domain_imp->file_name); if (status) { OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 6108: " - "Failed to rename the db file to:%s (err:%u)\n", - p_domain_imp->file_name, status); + "Failed to rename the db file to:%s (err:%s)\n", + p_domain_imp->file_name, strerror(errno)); } Exit: cl_spinlock_release(&p_domain_imp->lock);