[LTP] [PATCH v2 2/2] Add shutdown02 test

Petr Vorel pvorel@suse.cz
Mon Jun 10 15:44:34 CEST 2024


Hi Andrea,

...
> +static int file_desc = -1;
> +static int valid_sock = -1;
> +static int invalid_sock = -1;
FYI many LTP tests (or even lib/tst_cgroup.c) just expect that 0 is for stdin,
thus they happily expect 0 is invalid). e.g.

static int file_desc;

Then in cleanup:
if (valid_sock > 0)
	SAFE_CLOSE(valid_sock);

Sure, your way is correct, but I'd be also OK with 0.

(SAFE_SOCKET() and SAFE_CLOSE() also checks it should be >= 0 for valid file
descriptor or just -1 for error).

Reviewed-by: Petr Vorel <pvorel@suse.cz>

Kind regards,
Petr


More information about the ltp mailing list