[LTP] [PATCH 2/3] syscalls/umask02: Cleanup && Convert to new API

Cyril Hrubis chrubis@suse.cz
Mon Oct 31 12:35:05 CET 2016


Hi!
> +	for (umask(mskval++); mskval < 01000; mskval++) {
> +		TEST(umask(mskval));
> +		if (TEST_RETURN < 0) {
> +			tst_res(TFAIL | TTERRNO,
> +				"umask(%o) failed unexpectedly", mskval);
> +			return;
> +		}

Again umask() cannot fail this way. I guess that what we can do here is
to check that the return value is in a valid range, i.e.

if (TEST_RETURN < 0 || TEST_RETURN > 0777)
	tst_brk(TFAIL, "umask result outside range %i", TEST_RETURN);

> -		for (umask(++mskval), i = 1; mskval < 01000;
> -		     uret = umask(++mskval), i++) {
> -			if ((uret != mskval - 1) && (mskval != 0000)) {
> -				failcnt = 1;
> -				tst_resm(TFAIL, "umask(%d) returned bad mask "
> -					 "value %d.", mskval, uret);
> -			}
> +		if (TEST_RETURN != mskval - 1) {
> +			failflag = 1;
> +			tst_res(TFAIL, "umask(%o) returned %ld, expected %d",
> +				mskval, TEST_RETURN, mskval - 1);
>  		}
> -		if (!failcnt)
> -			tst_resm(TPASS, "All umask values return correct "
> -				 "values");
>  	}
> -	cleanup();
> -	tst_exit();
> -
> -}

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list