From: keith.busch@intel.com (Keith Busch)
Subject: [PATCH 1/2] nvme-cli wdc plugin: Add get pfail dump command.
Date: Thu, 25 Oct 2018 10:00:17 -0600 [thread overview]
Message-ID: <20181025160017.GA7035@localhost.localdomain> (raw)
In-Reply-To: <SN1PR04MB19845135D5239B300018EFA0EAF70@SN1PR04MB1984.namprd04.prod.outlook.com>
On Thu, Oct 25, 2018@03:58:00PM +0000, Jeffrey Lien wrote:
> How does this look? I've verified it on my Ubuntu system, but don't have a Fedora 28 system to verify the warning message has been resolved.
>
> diff --git a/wdc-nvme.c b/wdc-nvme.c
> index 55b2889..db68d58 100644
> --- a/wdc-nvme.c
> +++ b/wdc-nvme.c
> @@ -1141,16 +1141,16 @@ static int wdc_do_crash_dump(int fd, char *file, int type)
> static int wdc_crash_dump(int fd, char *file, int type)
> {
> char f[PATH_MAX] = {0};
> - char dump_type[PATH_MAX] = {0};
> + char dump_type[12] = {0};
>
> if (file != NULL) {
> strncpy(f, file, PATH_MAX - 1);
> }
>
> if (type == WDC_NVME_PFAIL_DUMP_TYPE)
> - strncpy(dump_type, "_pfail_dump", 11);
> + strcpy(dump_type, "_pfail_dump");
> else
> - strncpy(dump_type, "_crash_dump", 11);
> + strcpy(dump_type, "_crash_dump");
>
> if (wdc_get_serial_name(fd, f, PATH_MAX, dump_type) == -1) {
> fprintf(stderr, "ERROR : WDC : failed to generate file name\n");
> --
I just don't see the point in having multiple copies of the string. Why
not just use it directly?
---
diff --git a/plugins/wdc/wdc-nvme.c b/plugins/wdc/wdc-nvme.c
index 8d61fa7..cd12edb 100644
--- a/plugins/wdc/wdc-nvme.c
+++ b/plugins/wdc/wdc-nvme.c
@@ -1141,16 +1141,16 @@ static int wdc_do_crash_dump(int fd, char *file, int type)
static int wdc_crash_dump(int fd, char *file, int type)
{
char f[PATH_MAX] = {0};
- char dump_type[PATH_MAX] = {0};
+ char *dump_type;
if (file != NULL) {
strncpy(f, file, PATH_MAX - 1);
}
if (type == WDC_NVME_PFAIL_DUMP_TYPE)
- strncpy(dump_type, "_pfail_dump", PATH_MAX - 1);
+ dump_type = "_pfail_dump";
else
- strncpy(dump_type, "_crash_dump", PATH_MAX - 1);
+ dump_type = "_crash_dump";
if (wdc_get_serial_name(fd, f, PATH_MAX, dump_type) == -1) {
fprintf(stderr, "ERROR : WDC : failed to generate file name\n");
--
next prev parent reply other threads:[~2018-10-25 16:00 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-18 21:06 [PATCH 1/2] nvme-cli wdc plugin: Add get pfail dump command Dong Ho
2018-10-18 21:06 ` [PATCH 2/2] nvme-cli wdc plugin: Add documentation for pfail dump Dong Ho
2018-10-19 17:17 ` [PATCH 1/2] nvme-cli wdc plugin: Add get pfail dump command Keith Busch
2018-10-24 16:10 ` Eyal BenDavid
2018-10-24 16:22 ` Keith Busch
2018-10-24 16:28 ` Eyal BenDavid
2018-10-24 21:42 ` Jeffrey Lien
2018-10-24 21:51 ` Keith Busch
2018-10-24 22:19 ` Chaitanya Kulkarni
2018-10-25 15:58 ` Jeffrey Lien
2018-10-25 16:00 ` Keith Busch [this message]
2018-10-25 17:25 ` Jeffrey Lien
2018-10-25 17:28 ` Jeffrey Lien
2018-10-25 17:47 ` Jeffrey Lien
2018-10-25 18:02 ` Keith Busch
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=20181025160017.GA7035@localhost.localdomain \
--to=keith.busch@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