Linux CXL
 help / color / mirror / Atom feed
From: "Zhijian Li (Fujitsu)" <lizhijian@fujitsu.com>
To: "Verma, Vishal L" <vishal.l.verma@intel.com>,
	"nvdimm@lists.linux.dev" <nvdimm@lists.linux.dev>
Cc: "Jiang, Dave" <dave.jiang@intel.com>,
	"linux-cxl@vger.kernel.org" <linux-cxl@vger.kernel.org>,
	"Schofield, Alison" <alison.schofield@intel.com>
Subject: Re: [ndctl PATCH v3 3/6] cxl/monitor: use strcmp to compare the reserved word
Date: Mon, 10 Jul 2023 12:53:53 +0000	[thread overview]
Message-ID: <03e93966-cb4e-060c-efab-ddb2eaf8d876@fujitsu.com> (raw)
In-Reply-To: <d0378a7f915b2f9ef793214a366b5466c68d3204.camel@intel.com>



on 7/6/2023 5:03 AM, Verma, Vishal L wrote:
> On Wed, 2023-05-31 at 10:19 +0800, Li Zhijian wrote:
>> According to the tool's documentation, when '-l standard' is
>> specified,
>> log would be output to the stdout. But since it's using strncmp(a, b,
>> 10)
>> to compare the former 10 characters, it will also wrongly detect a
>> filename
>> starting with a substring 'standard' as stdout.
>>
>> For example:
>> $ cxl monitor -l standard.log
>>
>> User is most likely want to save log to ./standard.log instead of
>> stdout.
>>
>> Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
>> ---
>> V3: Improve commit log # Dave
>> V2: commit log updated # Dave
>> ---
>>   cxl/monitor.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/cxl/monitor.c b/cxl/monitor.c
>> index f0e3c4c3f45c..179646562187 100644
>> --- a/cxl/monitor.c
>> +++ b/cxl/monitor.c
>> @@ -188,7 +188,7 @@ int cmd_monitor(int argc, const char **argv,
>> struct cxl_ctx *ctx)
>>          else
>>                  monitor.ctx.log_priority = LOG_INFO;
>>   
>> -       if (strncmp(log, "./standard", 10) == 0)
>> +       if (strcmp(log, "./standard") == 0)
> As noted in patch 1, this should just be using 'standard', not
> './standard'.
>
> With these patches the behavior becomes:
>
> * if -l standard is used, it creates a file called standard in the cwd
> * if -l ./standard is used, it uses stdout

Not really, './standard' will become '././standard'  by 
parse_options_prefix()

Thanks
Zhijian

>
> It should behave the opposite way for both of those cases.
>
>>                  monitor.ctx.log_fn = log_standard;
>>          else {
>>                  monitor.ctx.log_file = fopen(log, "a+");

  reply	other threads:[~2023-07-10 12:55 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-31  2:19 [ndctl PATCH v3 0/6] cxl/monitor and ndctl/monitor fixes Li Zhijian
2023-05-31  2:19 ` [ndctl PATCH v3 1/6] cxl/monitor: Enable default_log and refactor sanity check Li Zhijian
2023-07-05 17:45   ` Dave Jiang
2023-07-05 20:53   ` Verma, Vishal L
2023-07-10 10:53     ` Zhijian Li (Fujitsu)
2023-07-10 16:59       ` Verma, Vishal L
2023-05-31  2:19 ` [ndctl PATCH v3 2/6] cxl/monitor: replace monitor.log_file with monitor.ctx.log_file Li Zhijian
2023-07-05 17:46   ` Dave Jiang
2023-05-31  2:19 ` [ndctl PATCH v3 3/6] cxl/monitor: use strcmp to compare the reserved word Li Zhijian
2023-07-05 18:20   ` Dave Jiang
2023-07-05 21:03   ` Verma, Vishal L
2023-07-10 12:53     ` Zhijian Li (Fujitsu) [this message]
2023-05-31  2:19 ` [ndctl PATCH v3 4/6] cxl/monitor: always log started message Li Zhijian
2023-07-05 18:21   ` Dave Jiang
2023-07-05 21:16   ` Verma, Vishal L
2023-07-10 13:05     ` Zhijian Li (Fujitsu)
2023-05-31  2:19 ` [ndctl PATCH v3 5/6] Documentation/cxl/cxl-monitor.txt: Fix inaccurate description Li Zhijian
2023-05-31  2:19 ` [ndctl PATCH v3 6/6] ndctl/monitor: use strcmp to compare the reserved word Li Zhijian
2023-07-05 18:22   ` Dave Jiang
2023-06-27 10:17 ` [ndctl PATCH v3 0/6] cxl/monitor and ndctl/monitor fixes Zhijian Li (Fujitsu)
2023-07-05 21:21   ` Verma, Vishal L
2023-07-05 23:53 ` Alison Schofield
2023-07-10 13:06   ` Zhijian Li (Fujitsu)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=03e93966-cb4e-060c-efab-ddb2eaf8d876@fujitsu.com \
    --to=lizhijian@fujitsu.com \
    --cc=alison.schofield@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=nvdimm@lists.linux.dev \
    --cc=vishal.l.verma@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox