netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ratheesh Kannoth <rkannoth@marvell.com>
To: Max Gautier <mg@max.gautier.name>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: RE: [EXTERNAL] Re: [PATCH iproute2-next v2] arpd: create /var/lib/arpd on first use
Date: Mon, 18 Mar 2024 09:18:59 +0000	[thread overview]
Message-ID: <MWHPR1801MB191828A6FF7D83103C75ED6AD32D2@MWHPR1801MB1918.namprd18.prod.outlook.com> (raw)
In-Reply-To: <ZfgCZNjlYrj5-rJz@framework>

> From: Max Gautier <mg@max.gautier.name>
> Sent: Monday, March 18, 2024 2:29 PM
> To: Ratheesh Kannoth <rkannoth@marvell.com>
> Cc: netdev@vger.kernel.org
> Subject: Re: [EXTERNAL] Re: [PATCH iproute2-next v2] arpd: create
> /var/lib/arpd on first use
> 
> On Mon, Mar 18, 2024 at 08:51:40AM +0000, Ratheesh Kannoth wrote:
> > > From: Max Gautier <mg@max.gautier.name>
> > > Sent: Monday, March 18, 2024 2:07 PM
> > > To: Ratheesh Kannoth <rkannoth@marvell.com>
> > > Cc: netdev@vger.kernel.org
> > > Subject: [EXTERNAL] Re: [PATCH iproute2-next v2] arpd: create
> > > /var/lib/arpd on first use
> >
> > > > > +	if (strcmp(default_dbname, dbname) == 0
> > > > > +			&& mkdir(ARPDDIR, 0755) != 0
> > > > > +			&& errno != EEXIST
> > > > why do you need errno != EEXIST case ? mkdir() will return error
> > > > in this case
> > > as well.
> > >
> > > EEXIST is not an error in this case: if the default location already
> > > exist, all is good. mkdir would still return -1 in this case, so we
> > > need to exclude it manually.
> >
> > ACK. IMO, it would make a more readable code if you consider splitting the
> "if" loop.
> 
> Something like this ? I tend to pack conditions unless branching is necessary,
> but no problem if this form is preferred.
> 
> if (strcmp(default_dbname, dbname) == 0) {
>     if (mkdir(ARPDDIR, 0755) != 0 && errno != EEXIST) {
>    ...
>    }
> }
ACK.   
instead of errno != EXIST ,  you may consider stat() before mkdir() call. Just my way thinking(please ignore it, if you don't like). 
My thinking is --> you need to execute mkdir () only first time, second time onwards, stat() call will return 0.



  reply	other threads:[~2024-03-18  9:19 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20240313093856.17fc459e@hermes.local>
2024-03-16  9:06 ` [PATCH iproute2-next] arpd: create /var/lib/arpd on first use Max Gautier
2024-03-16 15:07   ` Stephen Hemminger
2024-03-16 19:56     ` Jay Vosburgh
2024-03-17  0:14       ` Max Gautier
2024-03-17  9:01   ` [PATCH iproute2-next v2] " Max Gautier
2024-03-17 15:39     ` Stephen Hemminger
     [not found]     ` <09BB339D-A57C-4F67-BE67-2859F0262C86@126.com>
2024-03-17 17:23       ` Max Gautier
2024-03-18  2:56     ` Ratheesh Kannoth
2024-03-18  8:37       ` Max Gautier
2024-03-18  8:51         ` [EXTERNAL] " Ratheesh Kannoth
2024-03-18  8:59           ` Max Gautier
2024-03-18  9:18             ` Ratheesh Kannoth [this message]
2024-03-18  9:26               ` Max Gautier
2024-03-18  9:37                 ` Denis Kirjanov
2024-03-18  9:43                 ` Ratheesh Kannoth
2024-03-18 15:49   ` [PATCH iproute2-next v3] " Max Gautier
2024-03-28 20:40     ` patchwork-bot+netdevbpf

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=MWHPR1801MB191828A6FF7D83103C75ED6AD32D2@MWHPR1801MB1918.namprd18.prod.outlook.com \
    --to=rkannoth@marvell.com \
    --cc=mg@max.gautier.name \
    --cc=netdev@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).