- if (batch_prefix != NULL) {
- char *fmt = "";
- if (write_batch)
- fmt = "--write-batch=%s";
- else
- if (read_batch)
- fmt = "--read-batch=%s";
- snprintf(fext, sizeof fext, fmt, batch_prefix);
- args[ac++] = fext;
+ if (batch_prefix) {
+ char *r_or_w = write_batch ? "write" : "read";
+ if (asprintf(&arg, "--%s-batch=%s", r_or_w, batch_prefix) < 0)
+ goto oom;
+ args[ac++] = arg;