ltp.lists.linux.it archive mirror
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: Avinesh Kumar <avinesh.kumar@suse.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v2] uevent02: Make wait_for_uevents() order-independent
Date: Thu, 3 Sep 2026 16:42:21 +0200	[thread overview]
Message-ID: <apmHTcCUhxRMdcVg@yuki.lan> (raw)
In-Reply-To: <20260828152631.254653-1-avinesh.kumar@suse.com>

Hi!
>  static inline void wait_for_uevents(int fd, const struct uevent_desc *const uevents[])
>  {
> -	int i = 0;
> +	const struct uevent_desc *pending[UEVENT_MAX_PENDING];
> +	int i, cnt = 0, remaining;
> +
> +	while (uevents[cnt]) {
> +		if (cnt >= UEVENT_MAX_PENDING)
> +			tst_brk(TBROK, "Too many expected uevents, increase UEVENT_MAX_PENDING");
> +		pending[cnt] = uevents[cnt];
> +		cnt++;
> +	}
> +	remaining = cnt;

We can as well count the uevents[] first, then create the pending[]
array with the cnt. Also I would have used array of bitflags.


	while (uevents[cnt])
		cnt++;

	uint8_t not_pending[cnt] = {};

	...
		if (not_pending[i])
			continue;

		if (uevent_match(buf, len, uevents[i])) {
			not_pendig[i] = 1;
			...
		}

With that we avoid copying the pointers and static limit.

But that is largerly cosmetic changes.

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  parent reply	other threads:[~2026-09-03 14:42 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-25 17:14 [LTP] [PATCH] uevent02: Make wait_for_uevents() order-independent Avinesh Kumar via ltp
2026-08-25 17:36 ` [LTP] " linuxtestproject.agent
2026-08-28 15:26   ` [LTP] [PATCH v2] " Avinesh Kumar via ltp
2026-08-28 21:09     ` [LTP] " linuxtestproject.agent
2026-09-03 13:25     ` [LTP] [PATCH v2] " Andrea Cervesato via ltp
2026-09-03 14:42     ` Cyril Hrubis [this message]
2026-09-07 19:44       ` [LTP] [PATCH v3] " Avinesh Kumar via ltp
2026-09-07 22:01         ` [LTP] " linuxtestproject.agent
2026-09-15 10:53         ` [LTP] [PATCH v3] " Cyril Hrubis
2026-09-15 11:37           ` [LTP] [PATCH v4] uevents: introduce wait_for_uevents_unordered() Avinesh Kumar via ltp
2026-09-15 12:36             ` Petr Vorel
2026-09-15 12:43               ` Cyril Hrubis
2026-09-15 12:55                 ` Petr Vorel
2026-09-15 12:41             ` Cyril Hrubis

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=apmHTcCUhxRMdcVg@yuki.lan \
    --to=chrubis@suse.cz \
    --cc=avinesh.kumar@suse.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;
as well as URLs for NNTP newsgroup(s).