Message ID | 20210512171550.476130-4-thuth@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Fix Travis-CI / compiling with older versions of Clang | expand |
On 5/12/21 7:15 PM, Thomas Huth wrote: > Older versions of Clang complain if there is no prototype for main(). > Add one, and while we're at it, make sure that we use the same type > for main.c and netmain.c - since the return value does not matter, > declare the return type of main() as "void". > > Signed-off-by: Thomas Huth <thuth@redhat.com> > --- > pc-bios/s390-ccw/main.c | 3 +-- > pc-bios/s390-ccw/s390-ccw.h | 1 + > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c > index 5d2b7ba94d..835341457d 100644 > --- a/pc-bios/s390-ccw/main.c > +++ b/pc-bios/s390-ccw/main.c > @@ -281,7 +281,7 @@ static void probe_boot_device(void) > sclp_print("Could not find a suitable boot device (none specified)\n"); > } > > -int main(void) > +void main(void) > { > sclp_setup(); > css_setup(); > @@ -294,5 +294,4 @@ int main(void) > } > > panic("Failed to load OS from hard disk\n"); > - return 0; /* make compiler happy */ > } > diff --git a/pc-bios/s390-ccw/s390-ccw.h b/pc-bios/s390-ccw/s390-ccw.h > index 79db69ff54..b88e0550ab 100644 > --- a/pc-bios/s390-ccw/s390-ccw.h > +++ b/pc-bios/s390-ccw/s390-ccw.h > @@ -57,6 +57,7 @@ void write_subsystem_identification(void); > void write_iplb_location(void); > extern char stack[PAGE_SIZE * 8] __attribute__((__aligned__(PAGE_SIZE))); > unsigned int get_loadparm_index(void); > +void main(void); Can we keep the forward declaration in the source?
On 12/05/2021 21.54, Philippe Mathieu-Daudé wrote: > On 5/12/21 7:15 PM, Thomas Huth wrote: >> Older versions of Clang complain if there is no prototype for main(). >> Add one, and while we're at it, make sure that we use the same type >> for main.c and netmain.c - since the return value does not matter, >> declare the return type of main() as "void". >> >> Signed-off-by: Thomas Huth <thuth@redhat.com> >> --- >> pc-bios/s390-ccw/main.c | 3 +-- >> pc-bios/s390-ccw/s390-ccw.h | 1 + >> 2 files changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c >> index 5d2b7ba94d..835341457d 100644 >> --- a/pc-bios/s390-ccw/main.c >> +++ b/pc-bios/s390-ccw/main.c >> @@ -281,7 +281,7 @@ static void probe_boot_device(void) >> sclp_print("Could not find a suitable boot device (none specified)\n"); >> } >> >> -int main(void) >> +void main(void) >> { >> sclp_setup(); >> css_setup(); >> @@ -294,5 +294,4 @@ int main(void) >> } >> >> panic("Failed to load OS from hard disk\n"); >> - return 0; /* make compiler happy */ >> } >> diff --git a/pc-bios/s390-ccw/s390-ccw.h b/pc-bios/s390-ccw/s390-ccw.h >> index 79db69ff54..b88e0550ab 100644 >> --- a/pc-bios/s390-ccw/s390-ccw.h >> +++ b/pc-bios/s390-ccw/s390-ccw.h >> @@ -57,6 +57,7 @@ void write_subsystem_identification(void); >> void write_iplb_location(void); >> extern char stack[PAGE_SIZE * 8] __attribute__((__aligned__(PAGE_SIZE))); >> unsigned int get_loadparm_index(void); >> +void main(void); > > Can we keep the forward declaration in the source? There are two main() functions, one in main.c and one in netmain.c, that's why I think it's better to declare the prototype only in one place, i.e. in a header? Thomas
On Wed, 12 May 2021 19:15:50 +0200 Thomas Huth <thuth@redhat.com> wrote: > Older versions of Clang complain if there is no prototype for main(). > Add one, and while we're at it, make sure that we use the same type > for main.c and netmain.c - since the return value does not matter, > declare the return type of main() as "void". > > Signed-off-by: Thomas Huth <thuth@redhat.com> > --- > pc-bios/s390-ccw/main.c | 3 +-- > pc-bios/s390-ccw/s390-ccw.h | 1 + > 2 files changed, 2 insertions(+), 2 deletions(-) It's probably not strictly needed for both to have the same prototype, but this looks sane to me. Reviewed-by: Cornelia Huck <cohuck@redhat.com>
On 5/14/21 12:09 PM, Thomas Huth wrote: > On 12/05/2021 21.54, Philippe Mathieu-Daudé wrote: >> On 5/12/21 7:15 PM, Thomas Huth wrote: >>> Older versions of Clang complain if there is no prototype for main(). >>> Add one, and while we're at it, make sure that we use the same type >>> for main.c and netmain.c - since the return value does not matter, >>> declare the return type of main() as "void". >>> >>> Signed-off-by: Thomas Huth <thuth@redhat.com> >>> --- >>> pc-bios/s390-ccw/main.c | 3 +-- >>> pc-bios/s390-ccw/s390-ccw.h | 1 + >>> 2 files changed, 2 insertions(+), 2 deletions(-) >>> >>> diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c >>> index 5d2b7ba94d..835341457d 100644 >>> --- a/pc-bios/s390-ccw/main.c >>> +++ b/pc-bios/s390-ccw/main.c >>> @@ -281,7 +281,7 @@ static void probe_boot_device(void) >>> sclp_print("Could not find a suitable boot device (none >>> specified)\n"); >>> } >>> -int main(void) >>> +void main(void) >>> { >>> sclp_setup(); >>> css_setup(); >>> @@ -294,5 +294,4 @@ int main(void) >>> } >>> panic("Failed to load OS from hard disk\n"); >>> - return 0; /* make compiler happy */ >>> } >>> diff --git a/pc-bios/s390-ccw/s390-ccw.h b/pc-bios/s390-ccw/s390-ccw.h >>> index 79db69ff54..b88e0550ab 100644 >>> --- a/pc-bios/s390-ccw/s390-ccw.h >>> +++ b/pc-bios/s390-ccw/s390-ccw.h >>> @@ -57,6 +57,7 @@ void write_subsystem_identification(void); >>> void write_iplb_location(void); >>> extern char stack[PAGE_SIZE * 8] >>> __attribute__((__aligned__(PAGE_SIZE))); >>> unsigned int get_loadparm_index(void); >>> +void main(void); >> >> Can we keep the forward declaration in the source? > > There are two main() functions, one in main.c and one in netmain.c, > that's why I think it's better to declare the prototype only in one > place, i.e. in a header? Since it is a kludge to make the compiler happy, I'd rather keep it local, but I don't mind much :)
diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c index 5d2b7ba94d..835341457d 100644 --- a/pc-bios/s390-ccw/main.c +++ b/pc-bios/s390-ccw/main.c @@ -281,7 +281,7 @@ static void probe_boot_device(void) sclp_print("Could not find a suitable boot device (none specified)\n"); } -int main(void) +void main(void) { sclp_setup(); css_setup(); @@ -294,5 +294,4 @@ int main(void) } panic("Failed to load OS from hard disk\n"); - return 0; /* make compiler happy */ } diff --git a/pc-bios/s390-ccw/s390-ccw.h b/pc-bios/s390-ccw/s390-ccw.h index 79db69ff54..b88e0550ab 100644 --- a/pc-bios/s390-ccw/s390-ccw.h +++ b/pc-bios/s390-ccw/s390-ccw.h @@ -57,6 +57,7 @@ void write_subsystem_identification(void); void write_iplb_location(void); extern char stack[PAGE_SIZE * 8] __attribute__((__aligned__(PAGE_SIZE))); unsigned int get_loadparm_index(void); +void main(void); /* sclp.c */ void sclp_print(const char *string);
Older versions of Clang complain if there is no prototype for main(). Add one, and while we're at it, make sure that we use the same type for main.c and netmain.c - since the return value does not matter, declare the return type of main() as "void". Signed-off-by: Thomas Huth <thuth@redhat.com> --- pc-bios/s390-ccw/main.c | 3 +-- pc-bios/s390-ccw/s390-ccw.h | 1 + 2 files changed, 2 insertions(+), 2 deletions(-)