[opensuse-packaging] need help to fix " libtrash no-return-in-nonvoid-function open-funs.c:751"

Hello, How can this build problem be fixed[1] Thanks Glenn Spec ->https://build.opensuse.org/package/view_file?expand=1&file=libtrash.spec&pac... Project -> https://build.opensuse.org/package/show?package=libtrash&project=home%3Adoig... [1] [ 56s] Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1 [ 56s] Processing files: libtrash-debuginfo-3.2-19.1.x86_64 [ 56s] Provides: debuginfo(build-id) = e075e289f98dabe15e78e4d907a56355e6e6e1c1 [ 56s] Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1 [ 56s] Checking for unpackaged file(s): /usr/lib/rpm/check-files /home/abuild/rpmbuild/BUILDROOT/libtrash-3.2-19.1.x86_64 [ 56s] Wrote: /home/abuild/rpmbuild/SRPMS/libtrash-3.2-19.1.src.rpm [ 56s] Wrote: /home/abuild/rpmbuild/RPMS/x86_64/libtrash-3.2-19.1.x86_64.rpm [ 56s] Wrote: /home/abuild/rpmbuild/RPMS/x86_64/libtrash-debugsource-3.2-19.1.x86_64.rpm [ 56s] Wrote: /home/abuild/rpmbuild/RPMS/x86_64/libtrash-devel-3.2-19.1.x86_64.rpm [ 56s] Wrote: /home/abuild/rpmbuild/RPMS/x86_64/libtrash-debuginfo-3.2-19.1.x86_64.rpm [ 56s] Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.SOiFiO [ 56s] + umask 022 [ 56s] + cd /home/abuild/rpmbuild/BUILD [ 56s] + cd libtrash-3.2 [ 56s] + rm -rf /home/abuild/rpmbuild/BUILDROOT/libtrash-3.2-19.1.x86_64 [ 56s] + exit 0 [ 56s] ... checking for files with abuild user/group [ 56s] ... running 00-check-install-rpms [ 57s] ... installing all built rpms [ 57s] Preparing packages for installation... [ 57s] libtrash-3.2-19.1 [ 57s] libtrash-devel-3.2-19.1 [ 57s] libtrash-debuginfo-3.2-19.1 [ 57s] libtrash-debugsource-3.2-19.1 [ 57s] ... running 01-check-debuginfo [ 57s] ... testing for empty debuginfo packages [ 57s] ... running 02-check-gcc-output [ 57s] ... testing for serious compiler warnings [ 57s] (using /usr/lib/build/checks-data/check_gcc_output) [ 57s] (using //.build.log) [ 57s] [ 57s] I: Program returns random data in a function [ 57s] E: libtrash no-return-in-nonvoid-function open-funs.c:751 [ 57s] [ 57s] I: Program returns random data in a function [ 57s] E: libtrash no-return-in-nonvoid-function open-funs.c:751 [ 58s] /.build/build: line 313: 204 Killed background_monitor_process / &>/dev/null [ 60s] [ 46.482439] SysRq : Power Off [ 60s] [ 46.883161] Power down. -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org

Am Mittwoch, 2. Januar 2013, 21:42:04 schrieb doiggl@velocitynet.com.au:
Hello, How can this build problem be fixed[1]
By adding a return statement at the end of the function (otherwise random data gets returned which even can be a security problem).
Thanks Glenn
Spec ->https://build.opensuse.org/package/view_file?expand=1&file=libtrash.spec&pac... Project -> https://build.opensuse.org/package/show?package=libtrash&project=home%3Adoig...
[1] [ 56s] Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1 [ 56s] Processing files: libtrash-debuginfo-3.2-19.1.x86_64 [ 56s] Provides: debuginfo(build-id) = e075e289f98dabe15e78e4d907a56355e6e6e1c1 [ 56s] Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1 [ 56s] Checking for unpackaged file(s): /usr/lib/rpm/check-files /home/abuild/rpmbuild/BUILDROOT/libtrash-3.2-19.1.x86_64 [ 56s] Wrote: /home/abuild/rpmbuild/SRPMS/libtrash-3.2-19.1.src.rpm [ 56s] Wrote: /home/abuild/rpmbuild/RPMS/x86_64/libtrash-3.2-19.1.x86_64.rpm [ 56s] Wrote: /home/abuild/rpmbuild/RPMS/x86_64/libtrash-debugsource-3.2-19.1.x86_64.rpm [ 56s] Wrote: /home/abuild/rpmbuild/RPMS/x86_64/libtrash-devel-3.2-19.1.x86_64.rpm [ 56s] Wrote: /home/abuild/rpmbuild/RPMS/x86_64/libtrash-debuginfo-3.2-19.1.x86_64.rpm [ 56s] Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.SOiFiO [ 56s] + umask 022 [ 56s] + cd /home/abuild/rpmbuild/BUILD [ 56s] + cd libtrash-3.2 [ 56s] + rm -rf /home/abuild/rpmbuild/BUILDROOT/libtrash-3.2-19.1.x86_64 [ 56s] + exit 0 [ 56s] ... checking for files with abuild user/group [ 56s] ... running 00-check-install-rpms [ 57s] ... installing all built rpms [ 57s] Preparing packages for installation... [ 57s] libtrash-3.2-19.1 [ 57s] libtrash-devel-3.2-19.1 [ 57s] libtrash-debuginfo-3.2-19.1 [ 57s] libtrash-debugsource-3.2-19.1 [ 57s] ... running 01-check-debuginfo [ 57s] ... testing for empty debuginfo packages [ 57s] ... running 02-check-gcc-output [ 57s] ... testing for serious compiler warnings [ 57s] (using /usr/lib/build/checks-data/check_gcc_output) [ 57s] (using //.build.log) [ 57s] [ 57s] I: Program returns random data in a function [ 57s] E: libtrash no-return-in-nonvoid-function open-funs.c:751 [ 57s] [ 57s] I: Program returns random data in a function [ 57s] E: libtrash no-return-in-nonvoid-function open-funs.c:751 [ 58s] /.build/build: line 313: 204 Killed background_monitor_process / &>/dev/null [ 60s] [ 46.482439] SysRq : Power Off [ 60s] [ 46.883161] Power down.
-- Adrian Schroeter SUSE Linux Products GmbH email: adrian@suse.de -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org

El 02/01/13 07:42, doiggl@velocitynet.com.au escribió:
Hello, How can this build problem be fixed[1]
ok E: libtrash no-return-in-nonvoid-function open-funs.c:751 let's take a look at the source code.. the error is in file open-funs.c *around* line 751 function has definition static FdOrFp do_fopen_or_freopen_or_open(int function, const char *path, ...) at the end there is a comment /* (No return statement because all cases in the above switch-statement contain one.) */ that's wrong, a non-void function MUST return something, otherwise the compiler can do anything, as it is undefined behaviour. add "return NULL" ;) -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org

Am 03.01.2013 04:23, schrieb Cristian Rodríguez:
function has definition
static FdOrFp do_fopen_or_freopen_or_open(int function, const char *path, ...)
at the end there is a comment
/* (No return statement because all cases in the above switch-statement contain one.) */
that's wrong, a non-void function MUST return something, otherwise the compiler can do anything, as it is undefined behaviour.
No, the comment is right. That piece of code is never reached.
add "return NULL" ;)
Better fix the compiler to not spew unnecessary warnings. -- Stefan Seyfried "If your lighter runs out of fluid or flint and stops making fire, and you can't be bothered to figure out about lighter fluid or flint, that is not Zippo's fault." -- bkw -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org

On Thu, 03 Jan 2013 10:51:11 +0100 Stefan Seyfried <stefan.seyfried@googlemail.com> wrote:
Am 03.01.2013 04:23, schrieb Cristian Rodríguez:
function has definition
static FdOrFp do_fopen_or_freopen_or_open(int function, const char *path, ...)
at the end there is a comment
/* (No return statement because all cases in the above switch-statement contain one.) */
that's wrong, a non-void function MUST return something, otherwise the compiler can do anything, as it is undefined behaviour.
No, the comment is right. That piece of code is never reached.
add "return NULL" ;)
Better fix the compiler to not spew unnecessary warnings.
Well, thats really bad practice. If you want to do it with switch, then there should be something like default: assert(false, "Unknown statement"); //or log or anything that shout loudly enough to notice that there is problem when extending software return NULL; Reason is, that when you extend program, you should be warned if you forget to modify some use case. In C it is more tricky, as it is not C++ and enum is just constant definition, so it is not easy to check other integer can come to it. Josef -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org

Am 03.01.2013 12:47, schrieb Josef Reidinger:
Better fix the compiler to not spew unnecessary warnings.
Well, thats really bad practice. If you want to do it with switch, then there should be something like default: assert(false, "Unknown statement"); //or log or anything that shout loudly enough to notice that there is problem when extending software return NULL;
Reason is, that when you extend program, you should be warned if you forget to modify some use case. In C it is more tricky, as it is not C++ and enum is just constant definition, so it is not easy to check other integer can come to it.
I certainly agree that this piece of code is ugly as hell and probably crap. Anyway, the function that generates the value for the switch statement can only return 3 different values, and all of those are handled in the switch. So the compiler *is* wrong in this case. Even if the code is ugly. -- Stefan Seyfried "If your lighter runs out of fluid or flint and stops making fire, and you can't be bothered to figure out about lighter fluid or flint, that is not Zippo's fault." -- bkw -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org

On Fri, Jan 4, 2013 at 2:37 AM, Stefan Seyfried <stefan.seyfried@googlemail.com> wrote:
Anyway, the function that generates the value for the switch statement can only return 3 different values, and all of those are handled in the switch. So the compiler *is* wrong in this case. Even if the code is ugly.
Compilers cannot possibly be expected to prove all properties of the code. That's been proven to be impossible. Sometimes code must conform to the compiler. Ugly code is usually especially confounding to compilers, since we perceive unnecessary complexity as ugliness, and that complexity is what confounds the compiler. So maybe this is one of those times, and rather than complain about the compiler, and requiring impossible things of it, adapting the code would be best (to either be less ugly, and more analyzable, or to add the unnecessary return statement). -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org

On Fri, 4 Jan 2013, Stefan Seyfried wrote:
Am 03.01.2013 12:47, schrieb Josef Reidinger:
Better fix the compiler to not spew unnecessary warnings.
Well, thats really bad practice. If you want to do it with switch, then there should be something like default: assert(false, "Unknown statement"); //or log or anything that shout loudly enough to notice that there is problem when extending software return NULL;
Reason is, that when you extend program, you should be warned if you forget to modify some use case. In C it is more tricky, as it is not C++ and enum is just constant definition, so it is not easy to check other integer can come to it.
I certainly agree that this piece of code is ugly as hell and probably crap.
Anyway, the function that generates the value for the switch statement can only return 3 different values, and all of those are handled in the switch. So the compiler *is* wrong in this case. Even if the code is ugly.
The compiler is not wrong - there is no return. The conclusion drawn from the compiler message, that the program is necessarily buggy, is wrong. Richard. -- Richard Biener <rguenther@suse.de> SUSE / SUSE Labs SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746 GF: Jeff Hawn, Jennifer Guild, Felix Imend -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org

El 04/01/13 02:37, Stefan Seyfried escribió:
I certainly agree that this piece of code is ugly as hell and probably crap.
It is total crap, I suggest not packaging this thing at all. :-) -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
participants (7)
-
Adrian Schröter
-
Claudio Freire
-
Cristian Rodríguez
-
doiggl@velocitynet.com.au
-
Josef Reidinger
-
Richard Biener
-
Stefan Seyfried