Em Thu, Jan 21, 2021 at 11:35:19AM +0000, Giuliano Procida escreveu: > * Report the correct filename when objcopy fails. > * Unlink the temporary file on error. Thanks, applied. - Arnaldo > Acked-by: Andrii Nakryiko <andrii@xxxxxxxxxx> > Signed-off-by: Giuliano Procida <gprocida@xxxxxxxxxx> > --- > libbtf.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/libbtf.c b/libbtf.c > index 3709087..7552d8e 100644 > --- a/libbtf.c > +++ b/libbtf.c > @@ -786,18 +786,19 @@ static int btf_elf__write(const char *filename, struct btf *btf) > if (write(fd, raw_btf_data, raw_btf_size) != raw_btf_size) { > fprintf(stderr, "%s: write of %d bytes to '%s' failed: %d!\n", > __func__, raw_btf_size, tmp_fn, errno); > - goto out; > + goto unlink; > } > > snprintf(cmd, sizeof(cmd), "%s --add-section .BTF=%s %s", > llvm_objcopy, tmp_fn, filename); > if (system(cmd)) { > fprintf(stderr, "%s: failed to add .BTF section to '%s': %d!\n", > - __func__, tmp_fn, errno); > - goto out; > + __func__, filename, errno); > + goto unlink; > } > > err = 0; > + unlink: > unlink(tmp_fn); > } > > -- > 2.30.0.296.g2bfb1c46d8-goog > -- - Arnaldo