Re: [PATCH] selftests/exec: Avoid future NULL argv execve warning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jan 31, 2022 at 04:08:07PM -0800, Kees Cook wrote:
> Build actual argv for launching recursion test to avoid future warning
> about using an empty argv in execve().

> --- a/tools/testing/selftests/exec/recursion-depth.c
> +++ b/tools/testing/selftests/exec/recursion-depth.c
> @@ -24,8 +24,14 @@
>  #include <sys/mount.h>
>  #include <unistd.h>
>  
> +#define FILENAME "/tmp/1"
> +#define HASHBANG "#!" FILENAME "\n"
> +
>  int main(void)
>  {
> +	char * const argv[] = { FILENAME, NULL };
> +	int rv;

Can we move out of -Wdeclaration-after-statement mentality in tests at least?

> -	int rv = execve(FILENAME, NULL, NULL);
> +	rv = execve(FILENAME, argv, NULL);

	int rv = execve(FILENAME, (char*[]){FILENAME, NULL}, NULL);

is cleaner (and modern)!

>  	if (rv == -1 && errno == ELOOP) {
>  		return 0;
>  	}



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux