Netdev List
 help / color / mirror / Atom feed
From: Johannes Eigner <johannes.eigner@a-eberle.de>
To: Danielle Ratson <danieller@nvidia.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	Michal Kubecek <mkubecek@suse.cz>,
	Stephan Wurm <stephan.wurm@a-eberle.de>
Subject: Re: [PATCH ethtool 1/2] sfpid: Fix JSON output of SFP diagnostics
Date: Wed, 22 Oct 2025 16:52:33 +0200	[thread overview]
Message-ID: <aPjvsU-YEwdIyYha@PC-LX-JohEi> (raw)
In-Reply-To: <DM6PR12MB451638CD4E7B3DC33F16E58AD8F3A@DM6PR12MB4516.namprd12.prod.outlook.com>

[-- Attachment #1: Type: text/plain, Size: 2120 bytes --]

Am Wed, Oct 22, 2025 at 12:55:45PM +0000 schrieb Danielle Ratson:
> > -----Original Message-----
> > From: Johannes Eigner <johannes.eigner@a-eberle.de>
> > Sent: Tuesday, 21 October 2025 17:00
> > To: netdev@vger.kernel.org
> > Cc: Michal Kubecek <mkubecek@suse.cz>; Danielle Ratson
> > <danieller@nvidia.com>; Stephan Wurm <stephan.wurm@a-eberle.de>;
> > Johannes Eigner <johannes.eigner@a-eberle.de>
> > Subject: [PATCH ethtool 1/2] sfpid: Fix JSON output of SFP diagnostics
> > 
> > Close and delete JSON object only after output of SFP diagnostics so
> > that it is also JSON formatted. If the JSON object is deleted too early,
> > some of the output will not be JSON formatted, resulting in mixed output
> > formats.
> > 
> > Signed-off-by: Johannes Eigner <johannes.eigner@a-eberle.de>
> 
> Hi Johannes,
> 
> Please add a fixes tag.
> 

Will update patches with fixes tags.

> > ---
> >  sfpid.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/sfpid.c b/sfpid.c
> > index 62acb4f..5216ce3 100644
> > --- a/sfpid.c
> > +++ b/sfpid.c
> > @@ -520,8 +520,6 @@ int sff8079_show_all_nl(struct cmd_context *ctx)
> >  	new_json_obj(ctx->json);
> >  	open_json_object(NULL);
> >  	sff8079_show_all_common(buf);
> > -	close_json_object();
> > -	delete_json_obj();
> > 
> >  	/* Finish if A2h page is not present */
> >  	if (!(buf[92] & (1 << 6)))
> > @@ -537,6 +535,8 @@ int sff8079_show_all_nl(struct cmd_context *ctx)
> > 
> >  	sff8472_show_all(buf);
> >  out:
> > +	close_json_object();
> > +	delete_json_obj();
> 
> If sff8079_get_eeprom_page() fails, then close_json_object() and delete_json_object() lines will be called although the object was never opened.
> I think those lines should be after the sff8472_show_all(), but outside the out label.
> 

You are right in case the first sff8079_get_eeprom_page() fails,
close_json_object() and delete_json_object() should not be called. But
for the later goto we need to call close_json_object() and
delete_json_object(). Will add second goto mark to resolve this.

> >  	free(buf);
> > 
> >  	return ret;
> > 
> > --
> > 2.43.0
> 

[-- Attachment #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 4153 bytes --]

  reply	other threads:[~2025-10-22 14:53 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-21 14:00 [PATCH ethtool 0/2] fix module info JSON output Johannes Eigner
2025-10-21 14:00 ` [PATCH ethtool 1/2] sfpid: Fix JSON output of SFP diagnostics Johannes Eigner
2025-10-22 12:55   ` Danielle Ratson
2025-10-22 14:52     ` Johannes Eigner [this message]
2025-10-21 14:00 ` [PATCH ethtool 2/2] sff-common: Fix naming of JSON keys for thresholds Johannes Eigner
2025-10-22 13:32   ` Andrew Lunn
2025-10-22 14:59     ` Johannes Eigner
2025-10-22 15:34       ` Andrew Lunn
2025-10-23 10:02         ` Johannes Eigner
2025-10-23 13:14           ` Andrew Lunn

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=aPjvsU-YEwdIyYha@PC-LX-JohEi \
    --to=johannes.eigner@a-eberle.de \
    --cc=danieller@nvidia.com \
    --cc=mkubecek@suse.cz \
    --cc=netdev@vger.kernel.org \
    --cc=stephan.wurm@a-eberle.de \
    /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