public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ni_routing: Check when the file could not be opened
@ 2024-09-05 14:42 Ruffalo Lavoisier
  2024-09-06 10:43 ` Ian Abbott
  0 siblings, 1 reply; 5+ messages in thread
From: Ruffalo Lavoisier @ 2024-09-05 14:42 UTC (permalink / raw)
  To: Ian Abbott, H Hartley Sweeten; +Cc: Ruffalo Lavoisier, linux-kernel

Signed-off-by: Ruffalo Lavoisier <RuffaloLavoisier@gmail.com>
---
 drivers/comedi/drivers/ni_routing/tools/convert_c_to_py.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/comedi/drivers/ni_routing/tools/convert_c_to_py.c b/drivers/comedi/drivers/ni_routing/tools/convert_c_to_py.c
index d55521b5bdcb..d0321a7565c5 100644
--- a/drivers/comedi/drivers/ni_routing/tools/convert_c_to_py.c
+++ b/drivers/comedi/drivers/ni_routing/tools/convert_c_to_py.c
@@ -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");
-- 
2.43.0


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

* Re: [PATCH] ni_routing: Check when the file could not be opened
  2024-09-05 14:42 Ruffalo Lavoisier
@ 2024-09-06 10:43 ` Ian Abbott
  0 siblings, 0 replies; 5+ messages in thread
From: Ian Abbott @ 2024-09-06 10:43 UTC (permalink / raw)
  To: Ruffalo Lavoisier, H Hartley Sweeten; +Cc: linux-kernel

On 05/09/2024 15:42, Ruffalo Lavoisier wrote:
> Signed-off-by: Ruffalo Lavoisier <RuffaloLavoisier@gmail.com>
> ---
>   drivers/comedi/drivers/ni_routing/tools/convert_c_to_py.c | 4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/comedi/drivers/ni_routing/tools/convert_c_to_py.c b/drivers/comedi/drivers/ni_routing/tools/convert_c_to_py.c
> index d55521b5bdcb..d0321a7565c5 100644
> --- a/drivers/comedi/drivers/ni_routing/tools/convert_c_to_py.c
> +++ b/drivers/comedi/drivers/ni_routing/tools/convert_c_to_py.c
> @@ -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");

Looks good, but it could with some minimal description in addition to 
the patch header line.

The change is not urgent as the utility is only built manually and not 
part of the usual kernel build process. (It is only used to maintain a 
few source files, and not very often.)  Still, it's good to fix it.

Please could you add Greg Kroah-Hartman to the Cc list, as he is the 
person who normally commits comedi-related patches.

Thanks,

Ian

-- 
-=( Ian Abbott <abbotti@mev.co.uk> || MEV Ltd. is a company  )=-
-=( registered in England & Wales.  Regd. number: 02862268.  )=-
-=( Regd. addr.: S11 & 12 Building 67, Europa Business Park, )=-
-=( Bird Hall Lane, STOCKPORT, SK3 0XA, UK. || www.mev.co.uk )=-


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

* [PATCH] ni_routing: Check when the file could not be opened
@ 2024-09-06 11:54 Ruffalo Lavoisier
  2024-09-06 11:59 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 5+ messages in thread
From: Ruffalo Lavoisier @ 2024-09-06 11:54 UTC (permalink / raw)
  To: Ian Abbott, H Hartley Sweeten
  Cc: Greg Kroah-Hartman, Ruffalo Lavoisier, linux-kernel

Signed-off-by: Ruffalo Lavoisier <RuffaloLavoisier@gmail.com>
---
 drivers/comedi/drivers/ni_routing/tools/convert_c_to_py.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/comedi/drivers/ni_routing/tools/convert_c_to_py.c b/drivers/comedi/drivers/ni_routing/tools/convert_c_to_py.c
index d55521b5bdcb..d0321a7565c5 100644
--- a/drivers/comedi/drivers/ni_routing/tools/convert_c_to_py.c
+++ b/drivers/comedi/drivers/ni_routing/tools/convert_c_to_py.c
@@ -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");
-- 
2.43.0


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

* Re: [PATCH] ni_routing: Check when the file could not be opened
  2024-09-06 11:54 [PATCH] ni_routing: Check when the file could not be opened Ruffalo Lavoisier
@ 2024-09-06 11:59 ` Greg Kroah-Hartman
  0 siblings, 0 replies; 5+ messages in thread
From: Greg Kroah-Hartman @ 2024-09-06 11:59 UTC (permalink / raw)
  To: Ruffalo Lavoisier; +Cc: Ian Abbott, H Hartley Sweeten, linux-kernel

On Fri, Sep 06, 2024 at 08:54:02PM +0900, Ruffalo Lavoisier wrote:
> Signed-off-by: Ruffalo Lavoisier <RuffaloLavoisier@gmail.com>

For obvious reasons, we can't take patches without a changelog :(

> ---
>  drivers/comedi/drivers/ni_routing/tools/convert_c_to_py.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/comedi/drivers/ni_routing/tools/convert_c_to_py.c b/drivers/comedi/drivers/ni_routing/tools/convert_c_to_py.c
> index d55521b5bdcb..d0321a7565c5 100644
> --- a/drivers/comedi/drivers/ni_routing/tools/convert_c_to_py.c
> +++ b/drivers/comedi/drivers/ni_routing/tools/convert_c_to_py.c
> @@ -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

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

* [PATCH] ni_routing: Check when the file could not be opened
@ 2024-09-06 12:32 Ruffalo Lavoisier
  0 siblings, 0 replies; 5+ messages in thread
From: Ruffalo Lavoisier @ 2024-09-06 12:32 UTC (permalink / raw)
  To: Ian Abbott, H Hartley Sweeten
  Cc: Greg Kroah-Hartman, Ruffalo Lavoisier, linux-kernel

Signed-off-by: Ruffalo Lavoisier <RuffaloLavoisier@gmail.com>
---

I'm sorry. I think it's dirty because I'm not used to the patch. I'm going to write it all over again and send it to you.

This is just a defense code just in case.

 drivers/comedi/drivers/ni_routing/tools/convert_c_to_py.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/comedi/drivers/ni_routing/tools/convert_c_to_py.c b/drivers/comedi/drivers/ni_routing/tools/convert_c_to_py.c
index d55521b5bdcb..892a66b2cea6 100644
--- a/drivers/comedi/drivers/ni_routing/tools/convert_c_to_py.c
+++ b/drivers/comedi/drivers/ni_routing/tools/convert_c_to_py.c
@@ -140,6 +140,11 @@ 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");
 	for (int i = 0; ni_all_route_values[i]; ++i)
-- 
2.43.0


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

end of thread, other threads:[~2024-09-06 13:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-06 11:54 [PATCH] ni_routing: Check when the file could not be opened Ruffalo Lavoisier
2024-09-06 11:59 ` Greg Kroah-Hartman
  -- strict thread matches above, loose matches on Subject: below --
2024-09-06 12:32 Ruffalo Lavoisier
2024-09-05 14:42 Ruffalo Lavoisier
2024-09-06 10:43 ` Ian Abbott

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox