lkml.org 
[lkml]   [2023]   [Dec]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH v3 01/29] selftests/resctrl: Convert perror() to ksft_perror() or ksft_print_msg()
    On Wed, 13 Dec 2023, Reinette Chatre wrote:

    > Hi Ilpo,
    >
    > On 12/11/2023 4:17 AM, Ilpo Järvinen wrote:
    > > The resctrl selftest code contains a number of perror() calls. Some of
    > > them come with hash character and some don't. The kselftest framework
    > > provides ksft_perror() that is compatible with test output formatting
    > > so it should be used instead of adding custom hash signs.
    > >
    > > Some perror() calls are too far away from anything that sets error.
    > > For those call sites, ksft_print_msg() must be used instead.
    > >
    > > Convert perror() to ksft_perror() or ksft_print_msg().
    > >
    > > Other related changes:
    > > - Remove hash signs
    > > - Remove trailing stops & newlines from ksft_perror()
    > > - Add terminating newlines for converted ksft_print_msg()
    > > - Use consistent capitalization
    > >
    >
    > Another great cleanup. Also thanks for fixing some non-sensical messages.
    >
    > ...
    >
    > > @@ -149,7 +149,7 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type)
    > > param.num_of_runs = 0;
    > >
    > > if (pipe(pipefd)) {
    > > - perror("# Unable to create pipe");
    > > + ksft_perror("Unable to create pipe");
    > > return errno;
    > > }
    > >
    > > @@ -185,7 +185,7 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type)
    > > * Just print the error message.
    > > * Let while(1) run and wait for itself to be killed.
    > > */
    > > - perror("# failed signaling parent process");
    > > + ksft_perror("Failed signaling parent process");
    > >
    >
    > Partial writes are not actually errors and it cannot be expected that errno be set
    > in these cases. In these cases I think ksft_print_msg() would be more appropriate.

    I can change those to use print instead although I don't think these will
    fail for other reasons than a real error as the pipe should be empty and
    only single byte is written to it.

    > > if (fprintf(fp, "Pid: %d \t Mem_BW_iMC: %f \t Mem_BW_resc: %lu \t Difference: %lu\n",
    > > bm_pid, bw_imc, bw_resc, diff) <= 0) {
    > > + ksft_perror("Could not log results");
    > > fclose(fp);
    > > - perror("Could not log results.");
    > >
    > > return errno;
    >
    > >From what I can tell fprintf() does not set errno on error. Perhaps this
    > should rather be ksft_print_msg()?

    Oh, what a stupid gotcha in libc. I just assumed it does set errno without
    even checking... because why it wouldn't follow the custom. ...It seems
    nothing can be relied on :-/.

    --
    i.
    \
     
     \ /
      Last update: 2023-12-14 11:13    [W:5.878 / U:0.028 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site