From patchwork Wed Jan 2 12:36:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honggang LI X-Patchwork-Id: 10746307 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4431317D2 for ; Wed, 2 Jan 2019 12:37:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3409228800 for ; Wed, 2 Jan 2019 12:37:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2851028806; Wed, 2 Jan 2019 12:37:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C931828800 for ; Wed, 2 Jan 2019 12:37:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729448AbfABMho (ORCPT ); Wed, 2 Jan 2019 07:37:44 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45508 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726670AbfABMho (ORCPT ); Wed, 2 Jan 2019 07:37:44 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F019A637FC; Wed, 2 Jan 2019 12:37:43 +0000 (UTC) Received: from localhost (ovpn-12-39.pek2.redhat.com [10.72.12.39]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 99BA7105B1E5; Wed, 2 Jan 2019 12:37:38 +0000 (UTC) From: Honggang Li To: hal@dev.mellanox.co.il Cc: linux-rdma@vger.kernel.org, Honggang Li Subject: [ibsim patch 01/23] move sim_cmd_file into ibsim/sim_cmd.c Date: Wed, 2 Jan 2019 20:36:05 +0800 Message-Id: <20190102123627.18629-1-honli@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 02 Jan 2019 12:37:44 +0000 (UTC) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The 'sim_cmd_file' function only called by 'do_cmd' function in the sim_cmd.c file. Signed-off-by: Honggang Li --- ibsim/ibsim.c | 38 -------------------------------------- ibsim/sim_cmd.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/ibsim/ibsim.c b/ibsim/ibsim.c index debf591fea92..40e605c75429 100644 --- a/ibsim/ibsim.c +++ b/ibsim/ibsim.c @@ -517,44 +517,6 @@ static int sim_read_pkt(int fd, int client) return -1; // never reached } -int sim_cmd_file(FILE * f, char *s) -{ - char line[4096]; - FILE *cmd_file; - char *p; - - s++; - while (isspace(*s)) - s++; - - if (!s || !*s) { - fprintf(f, "do_cmd_from_file: no file name - skip\n"); - return -1; - } - - p = s + strlen(s) - 1; - while (isspace(*p)) { - *p = '\0'; - p--; - } - - cmd_file = fopen(s, "r"); - if (!cmd_file) { - fprintf(f, "do_cmd_from_file: cannot open file \'%s\': %s\n", - s, strerror(errno)); - return -1; - } - - while (fgets(line, sizeof(line) - 1, cmd_file) != NULL) { - if((p = strchr(line, '\n')) != NULL) - *p = '\0'; - do_cmd(line, f); - } - - fclose(cmd_file); - return 0; -} - static int sim_init_net(char *netconf, FILE * out) { DEBUG("reading %s", netconf); diff --git a/ibsim/sim_cmd.c b/ibsim/sim_cmd.c index 4b8fb62e0906..4345731e5081 100644 --- a/ibsim/sim_cmd.c +++ b/ibsim/sim_cmd.c @@ -1143,6 +1143,44 @@ format_error: return -1; } +int sim_cmd_file(FILE * f, char *s) +{ + char line[4096]; + FILE *cmd_file; + char *p; + + s++; + while (isspace(*s)) + s++; + + if (!s || !*s) { + fprintf(f, "do_cmd_from_file: no file name - skip\n"); + return -1; + } + + p = s + strlen(s) - 1; + while (isspace(*p)) { + *p = '\0'; + p--; + } + + cmd_file = fopen(s, "r"); + if (!cmd_file) { + fprintf(f, "do_cmd_from_file: cannot open file \'%s\': %s\n", + s, strerror(errno)); + return -1; + } + + while (fgets(line, sizeof(line) - 1, cmd_file) != NULL) { + if((p = strchr(line, '\n')) != NULL) + *p = '\0'; + do_cmd(line, f); + } + + fclose(cmd_file); + return 0; +} + int netstarted; int do_cmd(char *buf, FILE *f)