From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Alexander Shiyan <shc_work@mail.ru>, linux-can@vger.kernel.org
Subject: Re: [PATCH 1/2] libsocketcan: Initialize stack variables properly
Date: Fri, 07 Feb 2014 10:40:30 +0100 [thread overview]
Message-ID: <52F4AA0E.9080704@pengutronix.de> (raw)
In-Reply-To: <1391764887-9085-1-git-send-email-shc_work@mail.ru>
[-- Attachment #1: Type: text/plain, Size: 1398 bytes --]
On 02/07/2014 10:21 AM, Alexander Shiyan wrote:
> Stack variables may have unpredictable data if it not initialized.
> This patch adds the necessary cleanup stack variables.
>
> Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
> ---
> src/libsocketcan.c | 40 ++++++++++++++++++++++------------------
> 1 file changed, 22 insertions(+), 18 deletions(-)
>
> diff --git a/src/libsocketcan.c b/src/libsocketcan.c
> index 02714ae..4e7842f 100644
> --- a/src/libsocketcan.c
> +++ b/src/libsocketcan.c
> @@ -705,6 +705,7 @@ int can_do_stop(const char *name)
> */
> int can_do_restart(const char *name)
> {
> + struct req_info req;
> int err = -1;
> int state;
> __u32 restart_ms;
> @@ -731,11 +732,10 @@ int can_do_restart(const char *name)
> goto err_out;
> }
>
> - struct req_info req_info = {
> - .restart = 1,
> - };
> + memset(&req, 0, sizeof(req));
> + req.restart = 1;
This is equivalent, all other members of req_info are set to 0x0,
guaranteed by C standard. It was added with C99 and support by gcc for a
long time.
If think we can drop the patch.
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 242 bytes --]
prev parent reply other threads:[~2014-02-07 9:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-07 9:21 [PATCH 1/2] libsocketcan: Initialize stack variables properly Alexander Shiyan
2014-02-07 9:21 ` [PATCH 2/2] libsocketcan: Remove excess goto's Alexander Shiyan
2014-02-07 9:42 ` Marc Kleine-Budde
2014-02-07 9:40 ` Marc Kleine-Budde [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=52F4AA0E.9080704@pengutronix.de \
--to=mkl@pengutronix.de \
--cc=linux-can@vger.kernel.org \
--cc=shc_work@mail.ru \
/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.