dm-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Benjamin Marzinski <bmarzins@redhat.com>
To: Martin Wilck <mwilck@suse.com>
Cc: dm-devel@redhat.com
Subject: Re: [dm-devel] [PATCH 4/9] libmultipath: use strbuf in dict.c
Date: Mon, 30 Aug 2021 13:23:44 -0500	[thread overview]
Message-ID: <20210830182344.GV3087@octiron.msp.redhat.com> (raw)
In-Reply-To: <fb0961e9e14bdfc655561cc078069614fb7268a6.camel@suse.com>

On Wed, Aug 11, 2021 at 05:27:05PM +0200, Martin Wilck wrote:
> On Mi, 2021-07-28 at 14:03 -0500, Benjamin Marzinski wrote:
> > On Thu, Jul 15, 2021 at 12:52:18PM +0200, mwilck@suse.com wrote:
> > > From: Martin Wilck <mwilck@suse.com>
> > > 
> > > Temporary solution for snprint_keyword(), as print.c hasn't been
> > > migrated yet.
> > 
> > Mostly good. I have some minor issues with this.
> > 
> > > 
> > > Signed-off-by: Martin Wilck <mwilck@suse.com>
> > > ---
> > >  libmultipath/dict.c    | 313 ++++++++++++++++++-------------------
> > > ----
> > >  libmultipath/dict.h    |  19 +--
> > >  libmultipath/parser.c  |  47 ++++---
> > >  libmultipath/parser.h  |  15 +-
> > >  libmultipath/propsel.c | 147 +++++++++----------
> > >  5 files changed, 253 insertions(+), 288 deletions(-)
> > > 
> > >  
> > > @@ -419,21 +381,18 @@ declare_ovr_snprint(selector, print_str)
> > >  declare_mp_handler(selector, set_str)
> > >  declare_mp_snprint(selector, print_str)
> > >  
> > > -static int snprint_uid_attrs(struct config *conf, char *buff, int
> > > len,
> > > +static int snprint_uid_attrs(struct config *conf, struct strbuf
> > > *buff,
> > >                              const void *dummy)
> > >  {
> > > -       char *p = buff;
> > > -       int n, j;
> > > +       int j, ret;
> > >         const char *att;
> > >  
> > >         vector_foreach_slot(&conf->uid_attrs, att, j) {
> > > -               n = snprintf(p, len, "%s%s", j == 0 ? "" : " ",
> > > att);
> > > -               if (n >= len)
> > > -                       return (p - buff) + n;
> > > -               p += n;
> > > -               len -= n;
> > > +               ret = print_strbuf(buff, "%s%s", j == 0 ? "" : " ",
> > > att);
> > > +               if (ret < 0)
> > > +                       return ret;
> > >         }
> > 
> > On success, this should return the amount of data written, instead of
> > like the other snprint_* functions, not 0.
> > 
> > > -       return p - buff;
> > > +       return 0;
> 
> Right, thanks!
> 
> 
> > > +snprint_ble_simple (struct config *conf, struct strbuf *buff,
> > > const void *data)
> > >  {
> > > -       const struct blentry * ble = (const struct blentry *)data;
> > > +       const struct blentry *ble = (const struct blentry *)data;
> > >  
> > > -       return snprintf(buff, len, "\"%s\"", ble->str);
> > 
> > We should probably quote the regexes when printing them, so either
> > append_strbuf_quoted() or, if you're worried about how that would
> > handle
> > interior quotes, print_strbud with "\"%s\"".
> > 
> > > +       return print_str(buff, ble->str);
> 
> print_str() already calls append_strbuf_quoted(). Am I overlooking
> something?

I'm not sure what I was thinking here.  This looks fine.

-Ben

> 
> Thanks,
> Martin
> 

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


  reply	other threads:[~2021-08-30 18:26 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-15 10:52 [dm-devel] [PATCH 0/9] multipath-tools: use variable-size string buffers mwilck
2021-07-15 10:52 ` [dm-devel] [PATCH 1/9] libmultipath: variable-size parameters in dm_get_map() mwilck
2021-07-26 22:17   ` Benjamin Marzinski
2021-08-11 14:18     ` Martin Wilck
2021-07-15 10:52 ` [dm-devel] [PATCH 2/9] libmultipath: strbuf: simple api for growing string buffers mwilck
2021-07-27  4:54   ` Benjamin Marzinski
2021-08-11 15:03     ` Martin Wilck
2021-07-15 10:52 ` [dm-devel] [PATCH 3/9] libmultipath: variable-size parameters in assemble_map() mwilck
2021-07-28 15:54   ` Benjamin Marzinski
2021-08-11 15:15     ` Martin Wilck
2021-07-15 10:52 ` [dm-devel] [PATCH 4/9] libmultipath: use strbuf in dict.c mwilck
2021-07-28 19:03   ` Benjamin Marzinski
2021-08-11 15:27     ` Martin Wilck
2021-08-30 18:23       ` Benjamin Marzinski [this message]
2021-07-15 10:52 ` [dm-devel] [PATCH 5/9] libmultipath: use strbuf in print.c mwilck
2021-07-29  0:00   ` Benjamin Marzinski
2021-07-15 10:52 ` [dm-devel] [PATCH 6/9] libmultipath: print.c: fail hard if keywords are not found mwilck
2021-07-29  2:36   ` Benjamin Marzinski
2021-07-15 10:52 ` [dm-devel] [PATCH 7/9] libmultipath: print.h: move macros to print.c mwilck
2021-07-29  2:36   ` Benjamin Marzinski
2021-07-15 10:52 ` [dm-devel] [PATCH 8/9] libmultipath: use strbuf in alias.c mwilck
2021-07-29 15:22   ` Benjamin Marzinski
2021-07-15 10:52 ` [dm-devel] [PATCH 9/9] multipathd: use strbuf in cli.c mwilck
2021-07-29 15:46   ` Benjamin Marzinski

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=20210830182344.GV3087@octiron.msp.redhat.com \
    --to=bmarzins@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=mwilck@suse.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;
as well as URLs for NNTP newsgroup(s).