All of lore.kernel.org
 help / color / mirror / Atom feed
From: Libor Pechacek <lpechacek at suse.cz>
To: accel-config@lists.01.org
Subject: [Accel-config] Re: [PATCH] accel-config: Replace unsigned long with uint64_t
Date: Wed, 03 Mar 2021 09:57:37 +0100	[thread overview]
Message-ID: <YD9PgUEPsOy5yO1M@fmn> (raw)
In-Reply-To: 20210302214838.267342-1-ramesh.thomas@intel.com

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

Thanks for CCing me on the patch, Ramesh!

On Út 02-03-21 16:48:38, ramesh.thomas(a)intel.com wrote:
> From: Ramesh Thomas <ramesh.thomas(a)intel.com>
> 
> Makes 64 bit data type portable across 32 bit and 62 bit targets. This
> fixes compilation errors reported by 32 bit compilers.
> 
> Signed-off-by: Ramesh Thomas <ramesh.thomas(a)intel.com>
> Reported-by: Libor Pecháček <lpechacek(a)gmx.com>

Feel free to use my lpechacek(a)suse.cz address in this patch. I'm using
the GMX one for my spare-time opensource involvement.

[...]

> @@ -678,7 +678,7 @@ static void *add_wq(void *parent, int id, const char *wq_base,
>  	}
>  
>  	if (sscanf(basename(wq_base_string),
> -				"wq%ld.%ld", &device_id, &wq_id) != 2) {
> +				"wq%" PRIu64 ".%" PRIu64, &device_id, &wq_id) != 2) {
                                      ^^^^^^
Just a nit. I know that the resulting format string is the same in
this case but aren't SCN* macros intended for use with *scanf
functions?

In addition, GCC 10 on openSUSE reported about a few more places which
would benefit from the portable formatting strings. Otherwise,

Acked-by: Libor Pecháček <lpechacek(a)suse.cz>

Thanks!

Libor

Index: idxd-config-accel-config-v3.0.1/accfg/config_attr.c
===================================================================
--- idxd-config-accel-config-v3.0.1.orig/accfg/config_attr.c
+++ idxd-config-accel-config-v3.0.1/accfg/config_attr.c
@@ -3,6 +3,7 @@
 
 #include <stdio.h>
 #include <errno.h>
+#include <inttypes.h>
 #include <stdlib.h>
 #include <time.h>
 #include <json-c/json.h>
@@ -184,7 +185,7 @@ static int accel_config_parse_wq_attribs
 		|| wq_params->max_transfer_size > max_transfer_size)
 		&& (wq_params->max_transfer_size != INT_MAX)) {
 		fprintf(stderr,
-			"valid max-transfer-size should be 1 to %ld\n", max_transfer_size);
+			"valid max-transfer-size should be 1 to %" PRIu64 "\n", max_transfer_size);
 		return -EINVAL;
 	}
 
Index: idxd-config-accel-config-v3.0.1/accfg/enable.c
===================================================================
--- idxd-config-accel-config-v3.0.1.orig/accfg/enable.c
+++ idxd-config-accel-config-v3.0.1/accfg/enable.c
@@ -3,6 +3,7 @@
 
 #include <stdio.h>
 #include <errno.h>
+#include <inttypes.h>
 #include <stdlib.h>
 #include <time.h>
 #include <json-c/json.h>
@@ -263,7 +264,7 @@ static int wq_action(int argc, const cha
 		char dev_name[MAX_DEV_LEN], wq_name[MAX_DEV_LEN];
 		int found = 0;
 
-		if (sscanf(argv[i], "%[^/]/wq%lu.%lu", dev_name, &dev_id, &wq_id) != 3) {
+		if (sscanf(argv[i], "%[^/]/wq%" SCNu64 ".%" SCNu64, dev_name, &dev_id, &wq_id) != 3) {
 			fprintf(stderr, "'%s' is not a valid wq name\n",
 				argv[i]);
 			return -EINVAL;
@@ -272,7 +273,7 @@ static int wq_action(int argc, const cha
 		if (!accfg_device_type_validate(dev_name))
 			return -EINVAL;
 
-		rc = sprintf(wq_name, "wq%lu.%lu", dev_id, wq_id);
+		rc = sprintf(wq_name, "wq%" PRIu64 ".%" PRIu64, dev_id, wq_id);
 		if (rc < 0)
 			return errno;
 
-- 
Libor Pechacek
SUSE Labs                                Remember to have fun...

             reply	other threads:[~2021-03-03  8:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-03  8:57 Libor Pechacek [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-03-03 21:34 [Accel-config] Re: [PATCH] accel-config: Replace unsigned long with uint64_t Thomas, Ramesh
2021-03-03  4:24 Dave Jiang

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=YD9PgUEPsOy5yO1M@fmn \
    --to=accel-config@lists.01.org \
    /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.