From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9188BA0C46; Mon, 19 Jul 2021 09:00:25 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7B0534068B; Mon, 19 Jul 2021 09:00:25 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 4E3324067A for ; Mon, 19 Jul 2021 09:00:23 +0200 (CEST) Received: from dggeme765-chm.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4GSsz01NJvzYdBv; Mon, 19 Jul 2021 14:54:36 +0800 (CST) Received: from [10.69.27.114] (10.69.27.114) by dggeme765-chm.china.huawei.com (10.3.19.111) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Mon, 19 Jul 2021 15:00:20 +0800 To: Stephen Hemminger , "Min Hu (Connor)" References: <1619355742-15429-1-git-send-email-humin29@huawei.com> <20210717105333.58d98920@hermes.local> CC: , , From: Chengchang Tang Message-ID: Date: Mon, 19 Jul 2021 15:00:20 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: <20210717105333.58d98920@hermes.local> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.69.27.114] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggeme765-chm.china.huawei.com (10.3.19.111) X-CFilter-Loop: Reflected Subject: Re: [dpdk-dev] [PATCH] app/procinfo: add device registers dump X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 2021/7/18 1:53, Stephen Hemminger wrote: > On Sun, 25 Apr 2021 21:02:22 +0800 > "Min Hu (Connor)" wrote: > >> snprintf(file_name, MAX_FILE_NAME_SZ, "%s-port%u", >> + file_prefix, i); >> + fp_regs = fopen(file_name, "wb"); >> + if (fp_regs == NULL) { >> + printf("Error during opening '%s' for writing\n", >> + file_name); >> + } else { >> + if ((int)fwrite(buf_data, 1, buf_size, fp_regs) != >> + buf_size) >> + printf("Error during writing %s\n", >> + file_prefix); >> + else >> + printf("dump device (%s) regs successfully, " >> + "driver:%s version:0X%08X\n", >> + dev_info.device->name, >> + dev_info.driver_name, reg_info.version); >> + >> + fclose(fp_regs); >> + > > I don't like applications opening and writing an arbitrary file in the > current directory. Any file should be an argument to the application > and optional. I think the use of the file here does not seem to be exactly the same as the behavior you object to. The directories of the file and its name prefix is passed by user. some suffixes has been added based on user's input. This is mainly considering the scenario where the user does not specify a device. If no device is specified, this command will dump regs for all devices, and their dumped files are distinguished by the suffixes. If the user is required to give a name to the dumped file of each device, the ease of use of this command may decreases > > Also, since you are writing binary data, there is no point in using > stdio here. > . >