Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1583979
| From | Joe Perches <joe@perches.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 1/6] staging: vt6655: Compress return logic |
| Date | 2017-02-18 22:00 +0100 |
| Message-ID | <tckgO-6HX-17@gated-at.bofh.it> (permalink) |
| References | <tcjNM-6pO-9@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Sun, 2017-02-19 at 01:50 +0530, simran singhal wrote:
> Simplify function returns by merging assignment and return into
> one command line.
> Found with Coccinelle
> @@
> local idexpression ret;
> expression e;
> @@
>
> -ret =
> +return
> e;
> -return ret;
[]
> diff --git a/drivers/staging/vt6655/card.c b/drivers/staging/vt6655/card.c
[]
> @@ -920,7 +920,7 @@ u64 CARDqGetTSFOffset(unsigned char byRxRate, u64 qwTSF1, u64 qwTSF2)
>
> qwTSFOffset = qwTSF1 - qwTSF2;
>
> - return qwTSFOffset;
> + return qwTSF1 - qwTSF2;
> }
It's not a problem here but generically, this transformation may
introduce defects when the local idexpression being assigned to
is a smaller type than the return type. e.g.:
u64 foo(u64 a, u64 b)
{
u8 bar = a - b;
return bar;
}
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[PATCH 1/6] staging: vt6655: Compress return logic simran singhal <singhalsimran0@gmail.com> - 2017-02-18 21:30 +0100 Re: [Outreachy kernel] [PATCH 1/6] staging: vt6655: Compress return logic Julia Lawall <julia.lawall@lip6.fr> - 2017-02-18 21:50 +0100 Re: [PATCH 1/6] staging: vt6655: Compress return logic Joe Perches <joe@perches.com> - 2017-02-18 22:00 +0100
csiph-web