linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] slcanpty: declare command buffer static
@ 2014-01-13 13:29 yegorslists
  2014-01-13 17:56 ` Oliver Hartkopp
  2014-01-16 16:18 ` Marc Kleine-Budde
  0 siblings, 2 replies; 3+ messages in thread
From: yegorslists @ 2014-01-13 13:29 UTC (permalink / raw)
  To: linux-can; +Cc: socketcan, mkl, Yegor Yefremov

From: Yegor Yefremov <yegorslists@googlemail.com>

ASCII command buffer char buf[200] must be declared as static,
because it holds incomplete commands between pty2can() calls.
Without static it is not guaranteed, that buf retains the same
data between calls.

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
---
 slcanpty.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/slcanpty.c b/slcanpty.c
index 2c1cabe..c062a02 100644
--- a/slcanpty.c
+++ b/slcanpty.c
@@ -68,7 +68,7 @@ int pty2can(int pty, int socket, struct can_filter *fi,
 {
 	int nbytes;
 	char cmd;
-	char buf[200];
+	static char buf[200];
 	char replybuf[10]; /* for answers to received commands */
 	int ptr;
 	struct can_frame frame;
-- 
1.7.7


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

* Re: [PATCH] slcanpty: declare command buffer static
  2014-01-13 13:29 [PATCH] slcanpty: declare command buffer static yegorslists
@ 2014-01-13 17:56 ` Oliver Hartkopp
  2014-01-16 16:18 ` Marc Kleine-Budde
  1 sibling, 0 replies; 3+ messages in thread
From: Oliver Hartkopp @ 2014-01-13 17:56 UTC (permalink / raw)
  To: yegorslists, linux-can; +Cc: mkl



On 13.01.2014 14:29, yegorslists@googlemail.com wrote:
> From: Yegor Yefremov <yegorslists@googlemail.com>
> 
> ASCII command buffer char buf[200] must be declared as static,
> because it holds incomplete commands between pty2can() calls.
> Without static it is not guaranteed, that buf retains the same
> data between calls.
> 
> Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>

Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>

Hi Yegor,

indeed the rxoffset is a static variable to handle incomplete ASCII commands
(in buf[]) and therefore it makes no sense when the referenced buffer would
not be static then ...

Thanks for catching this.

Best regards,
Oliver

> ---
>  slcanpty.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/slcanpty.c b/slcanpty.c
> index 2c1cabe..c062a02 100644
> --- a/slcanpty.c
> +++ b/slcanpty.c
> @@ -68,7 +68,7 @@ int pty2can(int pty, int socket, struct can_filter *fi,
>  {
>  	int nbytes;
>  	char cmd;
> -	char buf[200];
> +	static char buf[200];
>  	char replybuf[10]; /* for answers to received commands */
>  	int ptr;
>  	struct can_frame frame;
> 

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

* Re: [PATCH] slcanpty: declare command buffer static
  2014-01-13 13:29 [PATCH] slcanpty: declare command buffer static yegorslists
  2014-01-13 17:56 ` Oliver Hartkopp
@ 2014-01-16 16:18 ` Marc Kleine-Budde
  1 sibling, 0 replies; 3+ messages in thread
From: Marc Kleine-Budde @ 2014-01-16 16:18 UTC (permalink / raw)
  To: yegorslists, linux-can; +Cc: socketcan

[-- Attachment #1: Type: text/plain, Size: 715 bytes --]

On 01/13/2014 02:29 PM, yegorslists@googlemail.com wrote:
> From: Yegor Yefremov <yegorslists@googlemail.com>
> 
> ASCII command buffer char buf[200] must be declared as static,
> because it holds incomplete commands between pty2can() calls.
> Without static it is not guaranteed, that buf retains the same
> data between calls.
> 
> Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>

Applied to master.

Tnx,
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 --]

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

end of thread, other threads:[~2014-01-16 16:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-13 13:29 [PATCH] slcanpty: declare command buffer static yegorslists
2014-01-13 17:56 ` Oliver Hartkopp
2014-01-16 16:18 ` Marc Kleine-Budde

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