[LTP] [PATCH] lib/tst_lockdown.c: Add PPC64 architecture support

Martin Doucha mdoucha@suse.cz
Mon Sep 4 14:09:08 CEST 2023


On 04. 09. 23 11:54, Cyril Hrubis wrote:
>> +	#if defined(__powerpc64__) || defined(__ppc64__)
>> +	SAFE_READ(1, fd, data, 4);
>> +	#else
>>   	SAFE_READ(1, fd, data, 5);
>> +	#endif
> 
> Here as well, the ifdefs has to start at first character in the line:
> 
> #if ...
> 	SAFE_READ(...);
> #else
> 	SAFE_READ(...);
> #endif
> 
>>   	SAFE_CLOSE(fd);
>> +
>> +	#if defined(__powerpc64__) || defined(__ppc64__)
>> +	tst_res(TINFO, "SecureBoot: %s", data[3] ? "on" : "off");
>> +	return data[3];
>> +	#else
>>   	tst_res(TINFO, "SecureBoot: %s", data[4] ? "on" : "off");
>>   	return data[4];
>> +	#endif
> 
> However all of these cases we can just define a few constants instead of
> cluttering the code with ifdefs.
> 
> #ifdef ppc
> # define VAR_DATA_SIZE 5
> # define VAR_DATA_OFF 4
> # define KERNEL_KCONFIG1 "CONFIG_SECURITY_LOCKDOWN_LSM"
> # define KERNEL_KCONFIG2 "CONFIG_SECURITY_LOCKDOWN_LSM_EARLY"
> ...
> #else
> # define VAR_DATA_SIZE 4
> # define VAR_DATA_OFF 3

I'd also recommend using named constant for read size and offset. But we 
only need one constant. The read size will always be VAR_DATA_OFF+1. We 
don't care whether there's any additional data after the the byte we 
want to check.

-- 
Martin Doucha   mdoucha@suse.cz
SW Quality Engineer
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic



More information about the ltp mailing list