Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | childinfo_t is a union that contains both signed (error) and unsigned |
| 2 | (threadid) members. Thus a large threadid could appear as a negative error |
| 3 | value, which will cause unexpected failures. |
| 4 | |
| 5 | childinfo_t should be changed to a struct, but it could potentially affect the |
| 6 | performance. So we keep it as a union but only check error against -1. There is |
| 7 | still a chance of false alarm but it's small. |
| 8 | |
| 9 | Upstream-Status: Pending |
| 10 | |
| 11 | Signed-off-by: Song.Li <Song.Li@windriver.com> |
| 12 | Signed-off-by: Jesse Zhang <sen.zhang@windriver.com> |
| 13 | --- |
| 14 | src/hackbench/hackbench.c | 4 ++-- |
| 15 | 1 file changed, 2 insertions(+), 2 deletions(-) |
| 16 | |
| 17 | diff --git a/src/hackbench/hackbench.c b/src/hackbench/hackbench.c |
| 18 | index 8baeb23..dc0de8f 100644 |
| 19 | --- a/src/hackbench/hackbench.c |
| 20 | +++ b/src/hackbench/hackbench.c |
| 21 | @@ -317,7 +317,7 @@ static unsigned int group(childinfo_t *child, |
| 22 | ctx->wakefd = wakefd; |
| 23 | |
| 24 | child[tab_offset+i] = create_worker(ctx, (void *)(void *)receiver); |
| 25 | - if( child[tab_offset+i].error < 0 ) { |
| 26 | + if( child[tab_offset+i].error == -1 ) { |
| 27 | return (i > 0 ? i-1 : 0); |
| 28 | } |
| 29 | snd_ctx->out_fds[i] = fds[1]; |
| 30 | @@ -332,7 +332,7 @@ static unsigned int group(childinfo_t *child, |
| 31 | snd_ctx->num_fds = num_fds; |
| 32 | |
| 33 | child[tab_offset+num_fds+i] = create_worker(snd_ctx, (void *)(void *)sender); |
| 34 | - if( child[tab_offset+num_fds+i].error < 0 ) { |
| 35 | + if( child[tab_offset+num_fds+i].error == -1 ) { |
| 36 | return (num_fds+i)-1; |
| 37 | } |
| 38 | } |
| 39 | -- |
| 40 | 1.7.9.5 |
| 41 | |