From: Petr Vorel <pvorel@suse.cz>
To: Li Wang <liwang@redhat.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v5 8/8] libswap: Refactor is_swap_supported function to return status
Date: Mon, 29 Jan 2024 13:22:49 +0100 [thread overview]
Message-ID: <20240129122249.GA615626@pevik> (raw)
In-Reply-To: <CAEemH2drVzga9NqWN4i5jZ76n5Q6Np-Cra61mGbnOttRbgbYnQ@mail.gmail.com>
> Hi Petr,
> On Mon, Jan 29, 2024 at 4:03 PM Petr Vorel <pvorel@suse.cz> wrote:
> > > This updates the is_swap_supported function in the libltpswap
> > > to return an integer status instead of void, allowing the function
> > > to communicate success or failure to the caller. It introduces
> > > checks and returns 0 on various failure conditions while logging
> > > the failure without aborting the test case.
> > > Signed-off-by: Li Wang <liwang@redhat.com>
> > > ---
> > > include/libswap.h | 2 +-
> > > libs/libltpswap/libswap.c | 28 ++++++++++++++++++----------
> > > 2 files changed, 19 insertions(+), 11 deletions(-)
> > > diff --git a/include/libswap.h b/include/libswap.h
> > > index e67d65756..1e09db031 100644
> > > --- a/include/libswap.h
> > > +++ b/include/libswap.h
> > > @@ -20,5 +20,5 @@ int make_swapfile(const char *swapfile, int blocks,
> > int safe);
> > > * Check swapon/swapoff support status of filesystems or files
> > > * we are testing on.
> > > */
> > Reviewed-by: Petr Vorel <pvorel@suse.cz>
> > Thanks for further improving it. Few comments to fix old issues, when we
> > are at
> > it (and plan to merge after the release). But feel free to ignore.
> > BTW do you plan to use it somewhere?
> > testcases/kernel/syscalls/swapoff/swapoff01.c
> > nit: I would comment here the return code.
> > Also maybe use bool (from stdbool.h)? The advantage is that we don't think
> > what
> > the return code is (sometimes we use syscalls approach when 0 is success,
> > otherwise - like here - 0 is failure). Slowly converting to bool would be
> > the
> > best.
> Good point, actually I am tired of figuring out the return 0 means 'FAIL' or
> 'SUCCESS' in the lib, it messes a lot in some functions. And as you suggest,
> bool value should be a good way to resolve this.
> But the bool type is not built into the language prior to the C99 standard.
> The C99 standard introduced a _Bool type and the header <stdbool.h>,
> which defines bool as a macro for _Bool.
> I am not sure if LTP nowadays only supports C99 and later.
> or should we make use of bool safely (or use syscalls approach
> 0 == success) in our patch?
FYI now compile with -std=gnu99, see include/mk/config.mk.in
dc7be30e2 ("config: Explicitly set gnu99")
So I would say LTP supports C99 with GNU extensions.
> @Cyril Hrubis <chrubis@suse.cz> what do you think?
FYI we already use stdbool.h and bool on some places in the library.
Kind regards,
Petr
> > > @@ -168,7 +168,7 @@ int make_swapfile(const char *swapfile, int blocks,
> > int safe)
> > > * Check swapon/swapoff support status of filesystems or files
> > > * we are testing on.
> > > */
> > nit: Although I did not like doc being just at the header, I now prefer it
> > now
> > to have it just at the header because we don't have to sync the same text
> > on two
> > places.
> Agree.
--
Mailing list info: https://lists.linux.it/listinfo/ltp
prev parent reply other threads:[~2024-01-29 12:23 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-28 2:48 [LTP] [PATCH v5 0/8] improvement work on libswap library Li Wang
2024-01-28 2:48 ` [LTP] [PATCH v5 1/8] libswap: add known swap supported fs check Li Wang
2024-01-28 2:48 ` [LTP] [PATCH v5 2/8] swapon01: Test on all filesystems Li Wang
2024-01-28 2:48 ` [LTP] [PATCH v5 3/8] swapon01: Improving test with memory limits and swap reporting Li Wang
2024-01-28 2:48 ` [LTP] [PATCH v5 4/8] libswap: add function to prealloc contiguous file Li Wang
2024-01-28 2:48 ` [LTP] [PATCH v5 5/8] libswap: Introduce file contiguity check Li Wang
2024-01-28 2:48 ` [LTP] [PATCH v5 6/8] libswap: customize swapfile size Li Wang
2024-01-28 2:48 ` [LTP] [PATCH v5 7/8] swapon/off: enable all_filesystem in swap test Li Wang
2024-01-29 8:03 ` Petr Vorel
2024-01-29 8:26 ` Li Wang
2024-01-28 2:48 ` [LTP] [PATCH v5 8/8] libswap: Refactor is_swap_supported function to return status Li Wang
2024-01-29 8:03 ` Petr Vorel
2024-01-29 11:36 ` Li Wang
2024-01-29 12:22 ` Petr Vorel [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240129122249.GA615626@pevik \
--to=pvorel@suse.cz \
--cc=liwang@redhat.com \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox