kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* unlikely compiler flag propagation
@ 2015-02-18 18:09 Matthias Brugger
  2015-02-18 18:24 ` Greg KH
  0 siblings, 1 reply; 8+ messages in thread
From: Matthias Brugger @ 2015-02-18 18:09 UTC (permalink / raw)
  To: kernelnewbies

Hi all,

I have a question about the unlikely compiler flag.
When a called function is only returns an error with the unlikely flag
set, should I set the unlikely compiler flag for the return value
check in the callee as well?

For example:

int function_one(int *list, int num_elements)
{
    int i;
    for (i =0; i < num_elements; i++) {
        if (unlikely(check_element(list + i)))
           return 1;
    }

[...]

    return 0;
}

int function_two(...)
{
[...]

     if (function_one(list, num))
         return -1;
}


So my question is, if function_two should instead implement:
if (unlikely(function_one(list, num))

Or does the unlikely compiler flag propagate to calling functions?

Thanks a lot,
Matthias
-- 
motzblog.wordpress.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-02-19 11:34 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-18 18:09 unlikely compiler flag propagation Matthias Brugger
2015-02-18 18:24 ` Greg KH
2015-02-18 18:35   ` Matthias Brugger
2015-02-18 19:02     ` Greg KH
2015-02-18 18:38   ` Nicholas Mc Guire
2015-02-18 18:57     ` Valdis.Kletnieks at vt.edu
2015-02-18 19:02       ` Nicholas Mc Guire
2015-02-19 11:34     ` Anupam Kapoor

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).