public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: Martin Doucha <mdoucha@suse.cz>
Cc: Kushal Chand <kushalkataria5@gmail.com>, ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v1] Fixes: #776, tst_taint prints human readable error messages instead of numerical codes
Date: Tue, 18 Jan 2022 14:00:21 +0100	[thread overview]
Message-ID: <Yea55fzU/RRqPPPa@pevik> (raw)
In-Reply-To: <26152227-acdf-50a4-e1bc-1a1850880040@suse.cz>

Hi Martin, Kushal,

...
> > +const char *tst_strtaint(int err)
> > +{
> > +	static const struct pair taint_pairs[] = {
> > +		STRPAIR(TST_TAINT_A, "TAINT_A(ACPI table overridden)")
> > +		STRPAIR(TST_TAINT_B, "TAINT_B(Bad page reference)")
> > +		STRPAIR(TST_TAINT_C, "TAINT_C(Staging driver loaded)")
> > +		STRPAIR(TST_TAINT_D, "TAINT_D(OOPS/BUG)")
> > +		STRPAIR(TST_TAINT_E, "TAINT_E(Unsigned module loaded)")
> > +		STRPAIR(TST_TAINT_F, "TAINT_F(Module force loaded)")
> > +		STRPAIR(TST_TAINT_G, "TAINT_G(Propriety module loaded)")
> > +		STRPAIR(TST_TAINT_I, "TAINT_I(Workaround BIOS/FW bug)")
> > +		STRPAIR(TST_TAINT_K, "TAINT_K(Live patched)")
> > +		STRPAIR(TST_TAINT_L, "TAINT_L(Soft lock up occured)")
> > +		STRPAIR(TST_TAINT_M, "TAINT_M(Machine check exception)")
> > +		STRPAIR(TST_TAINT_O, "TAINT_O(Out of tree module loaded)")
> > +		STRPAIR(TST_TAINT_R, "TAINT_R(Module force unloaded)")
> > +		STRPAIR(TST_TAINT_S, "TAINT_S(Running on out of spec system)")
> > +		STRPAIR(TST_TAINT_T, "TAINT_T(Built with struct randomization)")
> > +		STRPAIR(TST_TAINT_U, "TAINT_U(User request)")
> > +		STRPAIR(TST_TAINT_W, "TAINT_W(Warning)")
> > +		STRPAIR(TST_TAINT_X, "TAINT_X(Auxilary)")
> > +	};
> > +
> > +	PAIR_LOOKUP(taint_pairs, err);

> This is not the correct approach. You've constructed an array with
> 131,073 items to store a total of 18 strings. And the value passed in
> the "err" parameter is a bitmask which can hold multiple taint flags.

> What you should do is this:

> const char *taint_strings[] = {
> 	"G (Propriety module loaded)",
> 	"F (Module force loaded)",
> 	"S (Running on out of spec system)",
> 	"R (Module force unloaded)",
> 	...
> 	"X (Auxilary)",
> 	"T (Built with struct randomization)"
> };

> Then loop from 0 to ARRAY_SIZE(taint_strings) and print taint_strings[i]
> if (err & (1 << i)) != 0

Martin thanks a lot for correcting me. Kushal, I'm sorry for wrong advice,
please follow Martin's suggestion in v3.

Kind regards,
Petr

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

      reply	other threads:[~2022-01-18 13:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-14 16:16 [LTP] [PATCH v1] Fixes: #776, tst_taint prints human readable error messages instead of numerical codes Kushal Chand
2022-01-17 22:08 ` Petr Vorel
2022-01-18 11:28 ` Martin Doucha
2022-01-18 13:00   ` 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=Yea55fzU/RRqPPPa@pevik \
    --to=pvorel@suse.cz \
    --cc=kushalkataria5@gmail.com \
    --cc=ltp@lists.linux.it \
    --cc=mdoucha@suse.cz \
    /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