ni_routing: Check when the file could not be opened
PATCH 1/1 ni_routing: Check when the file could not be opened
Signed-off-by Ruffalo Lavoisier <[email protected]>
--- drivers/comedi/drivers/ni_routing/tools/convert_c_to_py.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/comedi/drivers/ni_routing/tools/convert_c_to_py.c +4 -0
@@ -139,6 +139,10 @@ void device_write(const struct ni_device_routes *dR, FILE *fp)int main (void ) {FILE *fp =fopen ("ni_values.py" ,"w" ); +if (fp ==NULL ) { +fprintf (stderr,"Could not open file!" ); +return -1 ; + }/* write route register values */ fprintf (fp,"ni_route_values = {\n" );
Signature · 1 line
2.43.0
Quoted 1 line · Ruffalo Lavoisier
Signed-off-by Ruffalo Lavoisier <[email protected]>
For obvious reasons, we can't take patches without a changelog :(
Quoted 9 lines
--- drivers/comedi/drivers/ni_routing/tools/convert_c_to_py.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/comedi/drivers/ni_routing/tools/convert_c_to_py.c +0
-0
drivers/comedi/drivers/ni_routing/tools/convert_c_to_py.c void device_write(const struct ni_device_routes *dR, FILE *fp) · line 145
Quoted 7 lines
drivers/comedi/drivers/ni_routing/tools/convert_c_to_py.c +4
-0@@ -139,6 +139,10 @@ void device_write(const struct ni_device_routes *dR, FILE *fp)int main (void ) {FILE *fp =fopen ("ni_values.py" ,"w" ); +if (fp ==NULL ) { +fprintf (stderr,"Could not open file!" ); +return -1 ; + }
Did you run this through checkpatch.pl? I think you need a blank line before your check.
And is this fixing a real-world issue, or just something you noticed?
thanks,
greg k-h