lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6259e494-bab3-0aeb-0bf6-e4e384f8f0b0@linux.intel.com>
Date: Wed, 31 Jan 2024 14:04:57 +0200 (EET)
From: Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
To: Maciej Wieczor-Retman <maciej.wieczor-retman@...el.com>
cc: Reinette Chatre <reinette.chatre@...el.com>, fenghua.yu@...el.com, 
    shuah@...nel.org, LKML <linux-kernel@...r.kernel.org>, 
    linux-kselftest@...r.kernel.org
Subject: Re: [PATCH v3 2/5] selftests/resctrl: Add helpers for the non-contiguous
 test

On Wed, 31 Jan 2024, Maciej Wieczor-Retman wrote:
> On 2024-01-26 at 10:58:04 -0800, Reinette Chatre wrote:
> >On 1/25/2024 4:14 AM, Ilpo Järvinen wrote:
> >> On Thu, 25 Jan 2024, Maciej Wieczor-Retman wrote:
> >
> >>> +	fp = fopen(file_path, "r");
> >>> +	if (!fp) {
> >>> +		snprintf(reason, sizeof(reason), "Error in opening %s file\n", filename);
> >>> +		ksft_perror(reason);
> >> 
> >> Was this the conclusion of the kstf_perror() discussion with Reinette? I 
> >> expected a bit different outcome when I stopped following it...
> >> 
> >> In any case, it would be nice though if ksft_perror() (or some kselftest.h 
> >> function yet to be added with a different name) would accept full printf 
> >> interface and just add the errno string into the end of the string so one 
> >> would not need to build constructs like this at all.
> >> 
> >> It will require a bit of macro trickery into kselftest.h. I don't know how 
> >> it should handle the case where somebody just passes a char pointer to it, 
> >> not a string literal, but I guess it would just throw an error while 
> >> compiling if somebody tries to do that as the macro string literal 
> >> concatenation could not build useful/compilable token.
> >> 
> >> It would make these prints informative enough to become actually useful 
> >> without needed to resort to preparing the string in advance which seems
> >> to be required almost every single case with the current interface.
> >
> >I think this can be accomplished with a new:
> >	void  ksft_vprint_msg(const char *msg, va_list args)
> >
> >... but ksft_perror() does conform to perror() and I expect that having one
> >support variable number of arguments while the other does to cause confusion.
> >
> >To support variable number of arguments with errno I'd propose just to use
> >ksft_print_msg() with strerror(errno), errno as the arguments (or even %m
> >that that errno handling within ksft_print_msg() aims to support). This does
> >indeed seem to be the custom in other tests.
> 
> Does something like this look okay?
> 
> 	fp = fopen(file_path, "r");
> 	if (!fp) {
> 		ksft_print_msg("Error in opening %s\n: %m\n", file_path);
> 		return -1;
> 	}
> 
> The '%m' seems to work fine but doesn't print errno's number code. Do you want
> me to add errno after '%m' so it is the same as ksft_perror()? I looked through
> some other tests where '%m' is used, and only few ones add errno with '%d'.

I think %m is enough.

-- 
 i.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ