3 2

Various compiler warnings on Arch Linux

Details
Message ID
<20190111032345.gmnofo25gua5uxgw@BlackBox>
DKIM signature
pass
Download raw message
I'm trying to package mrsh on Arch, and there are a couple of compiler 
warnings that don't appear when compiling normally:

The first refers to uninitialised variables in shell/redir.c.
I've attached the log for reference, but the gist of it is:

../mrsh/shell/redir.c: In function ‘process_redir’:
../mrsh/shell/redir.c:163:13: error: ‘default_redir_fd’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
   *redir_fd = default_redir_fd;
   ~~~~~~~~~~^~~~~~~~~~~~~~~~~~
../mrsh/shell/redir.c:153:5: error: ‘fd’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  if (fd < 0) {
     ^

A simple patch for this is attached (it sets fd & default_redir_fd to 
1). After this, another error occurs:

../mrsh/main.c: In function ‘main’:
../mrsh/main.c:114:3: error: ignoring return value of ‘getcwd’, declared with attribute warn_unused_result [-Werror=unused-result]
   getcwd(cwd, PATH_MAX);

I haven't investigated this one fully.
-- 
Stephen Gregoratto
PGP Fingerprint: 3FC6 3D0E 2801 C348 1C44 2D34 A80C 0F8E 8BAB EC8B
Need my key? Get it with:
	gpg --keyserver pgp.mit.edu --recv-keys 8BABEC8B
or off my server at https://www.sgregoratto.me/pubkey.txt
Details
Message ID
<wl-c7tPs2_1WLNULKMf4it2r1odLEsbSz2NOIlR7Kykr9G1NSF-unYfEQcVU0WjvMUy2wNJdzgNV2iL8p8Lr6feNo5QnjSXnHginpqEdb90=@emersion.fr>
In-Reply-To
<20190111032345.gmnofo25gua5uxgw@BlackBox> (view parent)
DKIM signature
pass
Download raw message
Hi,

On Friday, January 11, 2019 4:23 AM, Stephen Gregoratto <dev@sgregoratto.me> wrote:
> I'm trying to package mrsh on Arch, and there are a couple of compiler
> warnings that don't appear when compiling normally:

Thanks for reaching out!

I've tried to enable various compiler flags, but I've been unable to reproduce
these errors. We probably have a different GCC version.

> The first refers to uninitialised variables in shell/redir.c.
> I've attached the log for reference, but the gist of it is:
>
> ../mrsh/shell/redir.c: In function ‘process_redir’:
> ../mrsh/shell/redir.c:163:13: error: ‘default_redir_fd’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> *redir_fd = default_redir_fd;
> ^~~~~~~~
> ../mrsh/shell/redir.c:153:5: error: ‘fd’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> if (fd < 0) {
> ^
>
> A simple patch for this is attached (it sets fd & default_redir_fd to
> 1).

Thanks! Pushed [1].

> After this, another error occurs:
>
> ../mrsh/main.c: In function ‘main’:
> ../mrsh/main.c:114:3: error: ignoring return value of ‘getcwd’, declared with attribute warn_unused_result [-Werror=unused-result]
> getcwd(cwd, PATH_MAX);
>
> I haven't investigated this one fully.

Pushed a fix for this one: [2]. Maybe you'll hit other errors, feel free to
send more logs.

[1]: https://git.sr.ht/%7Eemersion/mrsh/commit/5fe985d331f830932eb3ca288238eabd2792ed4e
[2]: https://git.sr.ht/%7Eemersion/mrsh/commit/e73e175b93431b935661a83b570f7ba856354c37

--
Simon Ser
https://emersion.fr
Details
Message ID
<20190111115709.aw6tadksbm4k45y3@BlackBox>
In-Reply-To
<wl-c7tPs2_1WLNULKMf4it2r1odLEsbSz2NOIlR7Kykr9G1NSF-unYfEQcVU0WjvMUy2wNJdzgNV2iL8p8Lr6feNo5QnjSXnHginpqEdb90=@emersion.fr> (view parent)
DKIM signature
pass
Download raw message
Cheers Simon. All errors have disappeared on my builds. I've uploaded my 
port here[1]. Btw, the cflags I was using was listed in the compile.log 
(it's the standard Arch set).

[1] https://aur.archlinux.org/packages/mrsh-git
-- 
Stephen Gregoratto
PGP Fingerprint: 3FC6 3D0E 2801 C348 1C44 2D34 A80C 0F8E 8BAB EC8B
Need my key? Get it with:
	gpg --keyserver pgp.mit.edu --recv-keys 8BABEC8B
or off my server at https://www.sgregoratto.me/pubkey.txt
Details
Message ID
<5VRSHIAHxrR5a4v1NTSecrhTEWCa3_4SduKOcWqb2soH-s0SxgvTBs-Hyo3tjtUus1wGlLeintUp3pwi6VuaH1RqIpK1wcGVf4QUyLCzZkE=@emersion.fr>
In-Reply-To
<20190111115709.aw6tadksbm4k45y3@BlackBox> (view parent)
DKIM signature
pass
Download raw message
On Friday, January 11, 2019 12:57 PM, Stephen Gregoratto <dev@sgregoratto.me> wrote:
> Cheers Simon. All errors have disappeared on my builds. I've uploaded my
> port here[1]. Btw, the cflags I was using was listed in the compile.log
> (it's the standard Arch set).

Nice!

I've been adding an optimized build to the CI [1], hopefully this will help
catching similar issues in the future.

[1]: https://git.sr.ht/%7Eemersion/mrsh/commit/1c6cbcf40da4e92c3c4fc5a2bb86b86d60accef1