From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v3 2/2] API: Remove TEST macro usage from library
Date: Thu, 10 Jun 2021 15:44:27 +0200 [thread overview]
Message-ID: <YMIXO6IGN/1VHtbe@yuki> (raw)
In-Reply-To: <20210610121819.24626-2-rpalethorpe@suse.com>
Hi!
> diff --git a/lib/tst_netdevice.c b/lib/tst_netdevice.c
> index d098173d5..cc2766be8 100644
> --- a/lib/tst_netdevice.c
> +++ b/lib/tst_netdevice.c
> @@ -149,7 +149,7 @@ int tst_create_veth_pair(const char *file, const int lineno,
> tst_rtnl_destroy_context(file, lineno, ctx);
>
> if (!ret) {
> - tst_brk_(file, lineno, TBROK | TTERRNO,
> + tst_brk_(file, lineno, TBROK | TERRNO,
> "Failed to create veth interfaces %s+%s", ifname1,
> ifname2);
> }
> @@ -183,7 +183,7 @@ int tst_remove_netdev(const char *file, const int lineno, const char *ifname)
> tst_rtnl_destroy_context(file, lineno, ctx);
>
> if (!ret) {
> - tst_brk_(file, lineno, TBROK | TTERRNO,
> + tst_brk_(file, lineno, TBROK | TERRNO,
> "Failed to remove netdevice %s", ifname);
> }
>
> @@ -232,7 +232,7 @@ static int modify_address(const char *file, const int lineno,
> tst_rtnl_destroy_context(file, lineno, ctx);
>
> if (!ret) {
> - tst_brk_(file, lineno, TBROK | TTERRNO,
> + tst_brk_(file, lineno, TBROK | TERRNO,
> "Failed to modify %s network address", ifname);
> }
>
> @@ -301,7 +301,7 @@ static int change_ns(const char *file, const int lineno, const char *ifname,
> tst_rtnl_destroy_context(file, lineno, ctx);
>
> if (!ret) {
> - tst_brk_(file, lineno, TBROK | TTERRNO,
> + tst_brk_(file, lineno, TBROK | TERRNO,
> "Failed to move %s to another namespace", ifname);
> }
>
> @@ -392,7 +392,7 @@ static int modify_route(const char *file, const int lineno, unsigned int action,
> tst_rtnl_destroy_context(file, lineno, ctx);
>
> if (!ret) {
> - tst_brk_(file, lineno, TBROK | TTERRNO,
> + tst_brk_(file, lineno, TBROK | TERRNO,
> "Failed to modify network route");
> }
>
> diff --git a/lib/tst_rtnetlink.c b/lib/tst_rtnetlink.c
> index 1ecda3a9f..d93f7e18d 100644
> --- a/lib/tst_rtnetlink.c
> +++ b/lib/tst_rtnetlink.c
> @@ -380,7 +380,7 @@ int tst_rtnl_check_acks(const char *file, const int lineno,
> }
>
> if (res->err->error) {
> - TST_ERR = -res->err->error;
> + errno = -res->err->error;
> return 0;
> }
> }
> @@ -394,7 +394,7 @@ int tst_rtnl_send_validate(const char *file, const int lineno,
> struct tst_rtnl_message *response;
> int ret;
>
> - TST_ERR = 0;
> + errno = 0;
>
> if (tst_rtnl_send(file, lineno, ctx) <= 0)
> return 0;
I've did a careful review and this part is actually not correct. The
tst_rtnl_send_validate() function uses TST_ERR to propagate error while
the caller calls tst_rtnl_destroy_context() before it reads the value.
It's not correct to use errno this way since it may be modified in the
functions that free messages or destroys the context.
I guess that fixing this part correctly would mean to change the
tst_rtnl_send_validate() to return the return value from
tst_rtnl_check_acks() and the tst_rtnl_check_acks() would have to return
error on a failure.
It may also make sense to split this patch into two and keep changes to
these two files in a separate patch, since the rest is more or less
mechanical replacement of the TEST() macro use which is as far as I can
tell correct.
--
Cyril Hrubis
chrubis@suse.cz
prev parent reply other threads:[~2021-06-10 13:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-10 12:18 [LTP] [PATCH v3 1/2] Add Coccinelle helper scripts for reference Richard Palethorpe
2021-06-10 12:18 ` [LTP] [PATCH v3 2/2] API: Remove TEST macro usage from library Richard Palethorpe
2021-06-10 13:44 ` Cyril Hrubis [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=YMIXO6IGN/1VHtbe@yuki \
--to=chrubis@suse.cz \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.