[igt-dev] [PATCH i-g-t 3/4] lib/kselftests: return non-zero on open(kmsg) failure

Maíra Canal mairacanal at riseup.net
Thu Aug 4 18:09:32 UTC 2022


Hi Tales,

On 8/3/22 02:26, Tales Aparecida wrote:
> Previously igt_kselftest_begin() always returned 0.
> Return non-zero if failed to open kmsg, instead.
> 
> Signed-off-by: Tales Aparecida <tales.aparecida at gmail.com>
> ---
>  lib/igt_kmod.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/lib/igt_kmod.c b/lib/igt_kmod.c
> index bde0461a..63636243 100644
> --- a/lib/igt_kmod.c
> +++ b/lib/igt_kmod.c
> @@ -933,6 +933,8 @@ int igt_kselftest_begin(struct igt_kselftest *tst)
>  	igt_require(err == 0 || err == -ENOENT);
>  
>  	tst->kmsg = open("/dev/kmsg", O_RDONLY | O_NONBLOCK);
> +	if (tst->kmsg < 0)
> +		return 1;

Wouldn't be better to return the open() error? As open() returns an
errno, it would make it easier to identify what went wrong while opening
kmsg.

Best Regards,
- Maíra Canal

>  
>  	return 0;
>  }


More information about the igt-dev mailing list