Skip to contentSkip to conversation

Documentation/rs485: Fix missing zero init on sample code

PATCH In review Ricardo Ribalda Delgado 2 participants 3 messages Nov 6, 2017 – Nov 7, 2017 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Documentation/rs485: Fix missing zero init on sample code

The sample code does not initialize to zero a local variable and then it uses the uninitialized code.

Fix in case someone copy/paste the sample code.

---
 Documentation/serial/serial-rs485.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/serial/serial-rs485.txt +1 -1
index 389fcd4759e9..2bbae93bf279 100644
@@ -54,7 +54,7 @@
 		/* Error handling. See errno. */
 	}
 
-	struct serial_rs485 rs485conf;
+	struct serial_rs485 rs485conf = {};
 
 	/* Enable RS485 mode: */
 	rs485conf.flags |= SER_RS485_ENABLED;
Signature · 1 line
2.14.2
#1 lore raw
Quoted 15 lines · Ricardo Ribalda Delgado

The sample code does not initialize to zero a local variable and then it uses the uninitialized code.

Fix in case someone copy/paste the sample code.

---
 Documentation/serial/serial-rs485.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/serial/serial-rs485.txt +0 -0
index 389fcd4759e9..2bbae93bf279 100644

Documentation/serial/serial-rs485.txt line 57

Quoted 5 lines
Documentation/serial/serial-rs485.txt +1 -1
@@ -54,7 +54,7 @@
 		/* Error handling. See errno. */
 	}
 
-	struct serial_rs485 rs485conf;
+	struct serial_rs485 rs485conf = {};

I think that TIOCGRS485 is missing here instead. Ccing the author of the text.

Does it break classifying potatoes :)?

Documentation/serial/serial-rs485.txt

Quoted 3 lines
Documentation/serial/serial-rs485.txt +0 -0
 	/* Enable RS485 mode: */
 	rs485conf.flags |= SER_RS485_ENABLED;
 

thanks,

Signature · 2 lines
js
suse labs
#2 lore raw

Hi Jiri

Quoted 19 lines · Jiri Slaby
Quoted 18 lines · Ricardo Ribalda Delgado

The sample code does not initialize to zero a local variable and then it uses the uninitialized code.

Fix in case someone copy/paste the sample code.

---
 Documentation/serial/serial-rs485.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/serial/serial-rs485.txt +0 -0
index 389fcd4759e9..2bbae93bf279 100644
@@ -54,7 +54,7 @@
              /* Error handling. See errno. */
      }
 
Quoted 6 lines

Documentation/serial/serial-rs485.txt line 57

Quoted 2 lines
Documentation/serial/serial-rs485.txt +1 -1
-     struct serial_rs485 rs485conf;
+     struct serial_rs485 rs485conf = {};

I think that TIOCGRS485 is missing here instead. Ccing the author of the text.

That will also do.

Quoted 1 line

Does it break classifying potatoes :)?

The potato machine has to speak to other industrial machines :).

Hey!: I am running of potatoes!, Need another truck.

Quoted 9 lines

Documentation/serial/serial-rs485.txt

Quoted 4 lines
Documentation/serial/serial-rs485.txt +0 -0
      /* Enable RS485 mode: */
      rs485conf.flags |= SER_RS485_ENABLED;
 

thanks,
--
js
suse labs

Signature · 1 line
Ricardo Ribalda