Message ID | 20220424190811.1678416-3-masahiroy@kernel.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | kbuild: yet another series of cleanups (modpost and LTO) | expand |
On Sun, Apr 24, 2022 at 12:09 PM Masahiro Yamada <masahiroy@kernel.org> wrote: > > If an error occurs, modpost will fail anyway. Do not write out > any content (, which might be invalid). > > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> The callers could probably do less work before calling write_buf, too, but this is ok. Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> > --- > > scripts/mod/modpost.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c > index 141370ebbfd3..f0d48f65fb33 100644 > --- a/scripts/mod/modpost.c > +++ b/scripts/mod/modpost.c > @@ -2333,6 +2333,9 @@ static void write_buf(struct buffer *b, const char *fname) > { > FILE *file; > > + if (error_occurred) > + return; > + > file = fopen(fname, "w"); > if (!file) { > perror(fname); > -- > 2.32.0 >
On Tue, Apr 26, 2022 at 3:15 AM Nick Desaulniers <ndesaulniers@google.com> wrote: > > On Sun, Apr 24, 2022 at 12:09 PM Masahiro Yamada <masahiroy@kernel.org> wrote: > > > > If an error occurs, modpost will fail anyway. Do not write out > > any content (, which might be invalid). > > > > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> > > The callers could probably do less work before calling write_buf, too, > but this is ok. There are two call-sites for write_buf(). I thought it is better to add this if-conditional in the callee instead of the callers. > Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> > > > --- > > > > scripts/mod/modpost.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c > > index 141370ebbfd3..f0d48f65fb33 100644 > > --- a/scripts/mod/modpost.c > > +++ b/scripts/mod/modpost.c > > @@ -2333,6 +2333,9 @@ static void write_buf(struct buffer *b, const char *fname) > > { > > FILE *file; > > > > + if (error_occurred) > > + return; > > + > > file = fopen(fname, "w"); > > if (!file) { > > perror(fname); > > -- > > 2.32.0 > > > > > -- > Thanks, > ~Nick Desaulniers
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 141370ebbfd3..f0d48f65fb33 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -2333,6 +2333,9 @@ static void write_buf(struct buffer *b, const char *fname) { FILE *file; + if (error_occurred) + return; + file = fopen(fname, "w"); if (!file) { perror(fname);
If an error occurs, modpost will fail anyway. Do not write out any content (, which might be invalid). Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> --- scripts/mod/modpost.c | 3 +++ 1 file changed, 3 insertions(+)