All of lore.kernel.org
 help / color / mirror / Atom feed
From: Li Wang <liwang@redhat.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v3 1/2] include: add an exponential backoff macro for function repeat
Date: Mon, 23 Apr 2018 18:53:24 +0800	[thread overview]
Message-ID: <20180423105324.GA13013@gmail.com> (raw)
In-Reply-To: <20180423095855.GA24481@rei>

Cyril Hrubis wrote:

> hi!
> > +#define tst_retry_fn_exp_backoff(func, eret, max_delay)	\
> > +({	int tst_delay = 1;					\
> > +	for (;;) {						\
> > +		typeof(FUNC) ret = FUNC;			\
>                               ^
> 		I prefixed this variable with tst_ and even added _
> 		suffix to make sure that it will not alias either.

Good catch.

> 
> > +		if (ret == ERET)				\
> > +			break;					\
> > +		if (tst_delay < MAX_DELAY * 1000000) {		\
> > +			tst_res(TINFO,				\
> > +				#FUNC" returned %i, retrying"	\
> > +				" in %ius", ret, tst_delay);	\
> > +			usleep(tst_delay);			\
> > +			tst_delay *= 2;				\
> > +		} else {					\
> > +			tst_brk(TBROK, #FUNC" failed");		\
> > +		}						\
> > +	}							\
> > +	ERET;							\
> > +})
> 
> And pushed, thanks.
> 
> I know that the documentation is there in the comment but we should
> probably add a note about the macro into the test-writing-guidelines.txt
> as well...

Yes, we should. I will do that when I'm free. Thanks for reviewing.

Li Wang

      reply	other threads:[~2018-04-23 10:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-21  2:15 [LTP] [PATCH v3 1/2] include: add an exponential backoff macro for function repeat Li Wang
2018-04-23  9:58 ` Cyril Hrubis
2018-04-23 10:53   ` Li Wang [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=20180423105324.GA13013@gmail.com \
    --to=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 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.