Hi Andre, On Thu, Oct 29, 2020 at 10:23:39AM +0000, André Przywara wrote:
[...] > > +static int arm_spe_pkt_snprintf(int *err, char **buf_p, size_t *blen, > > + const char *fmt, ...) > > +{ > > + va_list ap; > > + int ret; > > + > > + va_start(ap, fmt); > > + ret = vsnprintf(*buf_p, *blen, fmt, ap); > > + va_end(ap); > > + > > + if (ret < 0) { > > + if (err && !*err) > > + *err = ret; > > + } else { > > + *buf_p += ret; > > + *blen -= ret; > > + } > > + > > + return ret; > > +} > > So this now implements the old behaviour of ignoring previous errors, in > all cases, since we don't check for errors and bail out in the callers. > > If you simply check for validity of err and for it being 0 before > proceeding with the va_start() above, this should be fixed. I think you are suggesting below code, could you take a look for it before I proceed to respin new patch? static int arm_spe_pkt_snprintf(int *err, char **buf_p, size_t *blen, const char *fmt, ...) { va_list ap; int ret; /* Bail out if any error occurred */ if (err && *err) return *err; va_start(ap, fmt); ret = vsnprintf(*buf_p, *blen, fmt, ap); va_end(ap); if (ret < 0) { if (err && !*err) *err = ret; } else { *buf_p += ret; *blen -= ret; } return ret; } Thanks, Leo