Most of the time it is recoverable error, and it makes no sense to abort here.
Unified · Split
| @@ -376,17 +376,18 @@ void bstr_xappend(void *talloc_ctx, bstr *s, bstr append) · 375 unmodified lines | |||
| 376 | s->start[s->len] = '\0'; | 376 | s->start[s->len] = '\0'; |
| 377 | } | 377 | } |
| 378 | 378 | ||
| 379 | void bstr_xappend_asprintf(void *talloc_ctx, bstr *s, const char *fmt, ...) | 379 | int bstr_xappend_asprintf(void *talloc_ctx, bstr *s, const char *fmt, ...) |
| 380 | { | 380 | { |
| 381 | va_list ap; | 381 | va_list ap; |
| 382 | va_start(ap, fmt); | 382 | va_start(ap, fmt); |
| 383 | bstr_xappend_vasprintf(talloc_ctx, s, fmt, ap); | 383 | int ret = bstr_xappend_vasprintf(talloc_ctx, s, fmt, ap); |
| 384 | va_end(ap); | 384 | va_end(ap); |
| 385 | return ret; | ||
| 385 | } | 386 | } |
| 386 | 387 | ||
| 387 | // Exactly as bstr_xappend(), but with a formatted string. | 388 | // Exactly as bstr_xappend(), but with a formatted string. |
| 388 | void bstr_xappend_vasprintf(void *talloc_ctx, bstr *s, const char *fmt, | 389 | int bstr_xappend_vasprintf(void *talloc_ctx, bstr *s, const char *fmt, |
| 389 | va_list ap) | 390 | va_list ap) |
| 390 | { | 391 | { |
| 391 | int size; | 392 | int size; |
| 392 | va_list copy; | 393 | va_list copy; |
| @@ -397,13 +398,14 @@ void bstr_xappend_vasprintf(void *talloc_ctx, bstr *s, const char *fmt, · 4 unmodified lines | |||
| 397 | va_end(copy); | 398 | va_end(copy); |
| 398 | 399 | ||
| 399 | if (size < 0) | 400 | if (size < 0) |
| 400 | abort(); | 401 | return size; |
| 401 | 402 | ||
| 402 | if (avail < 1 || size + 1 > avail) { | 403 | if (avail < 1 || size + 1 > avail) { |
| 403 | resize_append(talloc_ctx, s, size + 1); | 404 | resize_append(talloc_ctx, s, size + 1); |
| 404 | vsnprintf(s->start + s->len, size + 1, fmt, ap); | 405 | vsnprintf(s->start + s->len, size + 1, fmt, ap); |
| 405 | } | 406 | } |
| 406 | s->len += size; | 407 | s->len += size; |
| 408 | return size; | ||
| 407 | } | 409 | } |
| 408 | 410 | ||
| 409 | bool bstr_case_startswith(struct bstr s, struct bstr prefix) | 411 | bool bstr_case_startswith(struct bstr s, struct bstr prefix) |
| @@ -136,9 +136,9 @@ static inline struct bstr bstr_getline(struct bstr str, struct bstr *rest) · 135 unmodified lines | |||
| 136 | struct bstr bstr_strip_linebreaks(struct bstr str); | 136 | struct bstr bstr_strip_linebreaks(struct bstr str); |
| 137 | 137 | ||
| 138 | void bstr_xappend(void *talloc_ctx, bstr *s, bstr append); | 138 | void bstr_xappend(void *talloc_ctx, bstr *s, bstr append); |
| 139 | void bstr_xappend_asprintf(void *talloc_ctx, bstr *s, const char *fmt, ...) | 139 | int bstr_xappend_asprintf(void *talloc_ctx, bstr *s, const char *fmt, ...) |
| 140 | PRINTF_ATTRIBUTE(3, 4); | 140 | PRINTF_ATTRIBUTE(3, 4); |
| 141 | void bstr_xappend_vasprintf(void *talloc_ctx, bstr *s, const char *fmt, va_list va) | 141 | int bstr_xappend_vasprintf(void *talloc_ctx, bstr *s, const char *fmt, va_list va) |
| 142 | PRINTF_ATTRIBUTE(3, 0); | 142 | PRINTF_ATTRIBUTE(3, 0); |
| 143 | 143 | ||
| 144 | // If s starts/ends with prefix, return true and return the rest of the string | 144 | // If s starts/ends with prefix, return true and return the rest of the string |