On Mi, 2021-07-28 at 14:03 -0500, Benjamin Marzinski wrote: > On Thu, Jul 15, 2021 at 12:52:18PM +0200, mwilck@xxxxxxxx wrote: > > From: Martin Wilck <mwilck@xxxxxxxx> > > > > 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@xxxxxxxx> > > --- > > 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? Thanks, Martin -- dm-devel mailing list dm-devel@xxxxxxxxxx https://listman.redhat.com/mailman/listinfo/dm-devel