meta-virtualization.lists.yoctoproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCHv2] diod: Build in 32bit systems with 64bit time_t
@ 2024-04-20  7:29 Martin Jansa
  2024-04-20 16:10 ` [meta-virtualization] " Khem Raj
  2024-04-22  1:29 ` Bruce Ashfield
  0 siblings, 2 replies; 5+ messages in thread
From: Martin Jansa @ 2024-04-20  7:29 UTC (permalink / raw)
  To: meta-virtualization; +Cc: Ola x Nilsson, Martin Jansa

From: Ola x Nilsson <olani@axis.com>

Signed-off-by: Ola x Nilsson <olani@axis.com>
Signed-off-by: Martin Jansa <martin.jansa@gmail.com>
---
v2: just fixed Author

 recipes-extended/diod/diod_1.0.24.bb          |   1 +
 ...ous-time_t-sizes-in-printf-and-scanf.patch | 100 ++++++++++++++++++
 2 files changed, 101 insertions(+)
 create mode 100644 recipes-extended/diod/files/0002-Handle-various-time_t-sizes-in-printf-and-scanf.patch

diff --git a/recipes-extended/diod/diod_1.0.24.bb b/recipes-extended/diod/diod_1.0.24.bb
index 5e191dc0..6019fbfb 100644
--- a/recipes-extended/diod/diod_1.0.24.bb
+++ b/recipes-extended/diod/diod_1.0.24.bb
@@ -14,6 +14,7 @@ SRC_URI = "git://github.com/chaos/diod.git;protocol=https;branch=master \
            file://diod \
            file://diod.conf \
            file://0001-build-Find-lua-with-pkg-config.patch \
+           file://0002-Handle-various-time_t-sizes-in-printf-and-scanf.patch \
            "
 DEPENDS = "libcap ncurses tcp-wrappers lua"
 
diff --git a/recipes-extended/diod/files/0002-Handle-various-time_t-sizes-in-printf-and-scanf.patch b/recipes-extended/diod/files/0002-Handle-various-time_t-sizes-in-printf-and-scanf.patch
new file mode 100644
index 00000000..3c13c101
--- /dev/null
+++ b/recipes-extended/diod/files/0002-Handle-various-time_t-sizes-in-printf-and-scanf.patch
@@ -0,0 +1,100 @@
+From 04b0c5a5cb9e32090b177ff7327ad3260783abe0 Mon Sep 17 00:00:00 2001
+From: Ola x Nilsson <olani@axis.com>
+Date: Mon, 15 Apr 2024 17:31:44 +0200
+Subject: [PATCH] Handle various time_t sizes in printf and scanf
+
+The members of the timeval struct are both signed (defined by POSIX)
+and typically both 64 bits on a system where time_t is 64 bits.  This
+is possible also on 32 bit systems where time_t is larger to handle
+the 2038 problem.
+
+It's practically impossible to find a type and printf format that
+works even on all glibc systems.  Play it safe and always use printf
+with intmax_t and explict int64_t variables for scanf.
+
+Upstream-Status: Submitted [https://github.com/chaos/diod/pull/100]
+Signed-off-by: Ola x Nilsson <olani@axis.com>
+---
+ libnpfs/conn.c   | 5 +++--
+ libnpfs/ctl.c    | 7 ++++---
+ utils/dioddate.c | 8 +++++++-
+ 3 files changed, 14 insertions(+), 6 deletions(-)
+
+diff --git a/libnpfs/conn.c b/libnpfs/conn.c
+index 6e85fff..c34c840 100644
+--- a/libnpfs/conn.c
++++ b/libnpfs/conn.c
+@@ -16,6 +16,7 @@
+ #include <stdio.h>
+ #include <string.h>
+ #include <stdint.h>
++#include <inttypes.h>
+ #include <stdarg.h>
+ #include <errno.h>
+ #include <pthread.h>
+@@ -133,8 +134,8 @@ _debug_trace (Npsrv *srv, Npfcall *fc)
+ 				(void)gettimeofday(&b, NULL);
+ 			(void)gettimeofday(&a, NULL);
+ 			timersub(&a, &b, &c);
+-			np_logmsg(srv, "[%lu.%-3lu] %s",
+-				  c.tv_sec, c.tv_usec/1000, s);
++			np_logmsg(srv, "[%"PRIdMAX".%-3"PRIdMAX"] %s",
++				  (intmax_t)c.tv_sec, (intmax_t)c.tv_usec/1000, s);
+ 		} else
+ 			np_logmsg(srv, "%s", s);
+ 	}
+diff --git a/libnpfs/ctl.c b/libnpfs/ctl.c
+index f40cde4..317a22e 100644
+--- a/libnpfs/ctl.c
++++ b/libnpfs/ctl.c
+@@ -16,6 +16,7 @@
+ #include <stdio.h>
+ #include <string.h>
+ #include <stdint.h>
++#include <inttypes.h>
+ #include <stdarg.h>
+ #include <pthread.h>
+ #include <errno.h>
+@@ -291,9 +292,9 @@ _ctl_get_date (char *name, void *a)
+ 		np_uerror (errno);
+ 		goto error;
+ 	}
+-	if (aspf (&s, &len, "%lu.%lu %d.%d\n",
+-					tv.tv_sec,         tv.tv_usec,
+-					tz.tz_minuteswest, tz.tz_dsttime) < 0) {
++	if (aspf (&s, &len, "%"PRIdMAX".%"PRIdMAX" %d.%d\n",
++					(uintmax_t)tv.tv_sec, (uintmax_t)tv.tv_usec,
++					tz.tz_minuteswest,    tz.tz_dsttime) < 0) {
+ 		np_uerror (ENOMEM);
+ 		goto error;
+ 	}
+diff --git a/utils/dioddate.c b/utils/dioddate.c
+index bde002f..f392792 100644
+--- a/utils/dioddate.c
++++ b/utils/dioddate.c
+@@ -21,6 +21,7 @@
+ #include <unistd.h>
+ #include <stdlib.h>
+ #include <stdint.h>
++#include <inttypes.h>
+ #include <stdarg.h>
+ #include <stdio.h>
+ #if HAVE_GETOPT_H
+@@ -142,11 +143,16 @@ main (int argc, char *argv[])
+         errn (np_rerror (), "error reading date");
+         goto done;
+     }
+-    if (sscanf (buf, "%lu.%lu %d.%d", &tv.tv_sec, &tv.tv_usec,
++
++    int64_t sec = 0, usec = 0;
++    if (sscanf (buf, "%"SCNd64".%"SCNd64" %d.%d", &sec, &usec,
+                                     &tz.tz_minuteswest, &tz.tz_dsttime) != 4) {
+         msg ("error scanning returned date: %s", buf);
+         goto done;
+     }
++    tv.tv_sec = sec;
++    tv.tv_usec = usec;
++
+     if (Sopt) {
+         if (settimeofday (&tv, &tz) < 0)
+             err_exit ("settimeofday");
-- 
2.44.0



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

* Re: [meta-virtualization] [PATCHv2] diod: Build in 32bit systems with 64bit time_t
  2024-04-20  7:29 [PATCHv2] diod: Build in 32bit systems with 64bit time_t Martin Jansa
@ 2024-04-20 16:10 ` Khem Raj
  2024-04-22  1:29 ` Bruce Ashfield
  1 sibling, 0 replies; 5+ messages in thread
From: Khem Raj @ 2024-04-20 16:10 UTC (permalink / raw)
  To: martin.jansa; +Cc: meta-virtualization, Ola x Nilsson

On Sat, Apr 20, 2024 at 12:29 AM Martin Jansa via
lists.yoctoproject.org <martin.jansa=gmail.com@lists.yoctoproject.org>
wrote:
>
> From: Ola x Nilsson <olani@axis.com>
>
> Signed-off-by: Ola x Nilsson <olani@axis.com>
> Signed-off-by: Martin Jansa <martin.jansa@gmail.com>
> ---
> v2: just fixed Author
>
>  recipes-extended/diod/diod_1.0.24.bb          |   1 +
>  ...ous-time_t-sizes-in-printf-and-scanf.patch | 100 ++++++++++++++++++
>  2 files changed, 101 insertions(+)
>  create mode 100644 recipes-extended/diod/files/0002-Handle-various-time_t-sizes-in-printf-and-scanf.patch
>
> diff --git a/recipes-extended/diod/diod_1.0.24.bb b/recipes-extended/diod/diod_1.0.24.bb
> index 5e191dc0..6019fbfb 100644
> --- a/recipes-extended/diod/diod_1.0.24.bb
> +++ b/recipes-extended/diod/diod_1.0.24.bb
> @@ -14,6 +14,7 @@ SRC_URI = "git://github.com/chaos/diod.git;protocol=https;branch=master \
>             file://diod \
>             file://diod.conf \
>             file://0001-build-Find-lua-with-pkg-config.patch \
> +           file://0002-Handle-various-time_t-sizes-in-printf-and-scanf.patch \
>             "
>  DEPENDS = "libcap ncurses tcp-wrappers lua"
>
> diff --git a/recipes-extended/diod/files/0002-Handle-various-time_t-sizes-in-printf-and-scanf.patch b/recipes-extended/diod/files/0002-Handle-various-time_t-sizes-in-printf-and-scanf.patch
> new file mode 100644
> index 00000000..3c13c101
> --- /dev/null
> +++ b/recipes-extended/diod/files/0002-Handle-various-time_t-sizes-in-printf-and-scanf.patch
> @@ -0,0 +1,100 @@
> +From 04b0c5a5cb9e32090b177ff7327ad3260783abe0 Mon Sep 17 00:00:00 2001
> +From: Ola x Nilsson <olani@axis.com>
> +Date: Mon, 15 Apr 2024 17:31:44 +0200
> +Subject: [PATCH] Handle various time_t sizes in printf and scanf
> +
> +The members of the timeval struct are both signed (defined by POSIX)
> +and typically both 64 bits on a system where time_t is 64 bits.  This
> +is possible also on 32 bit systems where time_t is larger to handle
> +the 2038 problem.
> +
> +It's practically impossible to find a type and printf format that
> +works even on all glibc systems.  Play it safe and always use printf
> +with intmax_t and explict int64_t variables for scanf.
> +
> +Upstream-Status: Submitted [https://github.com/chaos/diod/pull/100]
> +Signed-off-by: Ola x Nilsson <olani@axis.com>
> +---
> + libnpfs/conn.c   | 5 +++--
> + libnpfs/ctl.c    | 7 ++++---
> + utils/dioddate.c | 8 +++++++-
> + 3 files changed, 14 insertions(+), 6 deletions(-)
> +
> +diff --git a/libnpfs/conn.c b/libnpfs/conn.c
> +index 6e85fff..c34c840 100644
> +--- a/libnpfs/conn.c
> ++++ b/libnpfs/conn.c
> +@@ -16,6 +16,7 @@
> + #include <stdio.h>
> + #include <string.h>
> + #include <stdint.h>
> ++#include <inttypes.h>
> + #include <stdarg.h>
> + #include <errno.h>
> + #include <pthread.h>
> +@@ -133,8 +134,8 @@ _debug_trace (Npsrv *srv, Npfcall *fc)
> +                               (void)gettimeofday(&b, NULL);
> +                       (void)gettimeofday(&a, NULL);
> +                       timersub(&a, &b, &c);
> +-                      np_logmsg(srv, "[%lu.%-3lu] %s",
> +-                                c.tv_sec, c.tv_usec/1000, s);
> ++                      np_logmsg(srv, "[%"PRIdMAX".%-3"PRIdMAX"] %s",
> ++                                (intmax_t)c.tv_sec, (intmax_t)c.tv_usec/1000, s);
> +               } else
> +                       np_logmsg(srv, "%s", s);
> +       }
> +diff --git a/libnpfs/ctl.c b/libnpfs/ctl.c
> +index f40cde4..317a22e 100644
> +--- a/libnpfs/ctl.c
> ++++ b/libnpfs/ctl.c
> +@@ -16,6 +16,7 @@
> + #include <stdio.h>
> + #include <string.h>
> + #include <stdint.h>
> ++#include <inttypes.h>
> + #include <stdarg.h>
> + #include <pthread.h>
> + #include <errno.h>
> +@@ -291,9 +292,9 @@ _ctl_get_date (char *name, void *a)
> +               np_uerror (errno);
> +               goto error;
> +       }
> +-      if (aspf (&s, &len, "%lu.%lu %d.%d\n",
> +-                                      tv.tv_sec,         tv.tv_usec,
> +-                                      tz.tz_minuteswest, tz.tz_dsttime) < 0) {
> ++      if (aspf (&s, &len, "%"PRIdMAX".%"PRIdMAX" %d.%d\n",
> ++                                      (uintmax_t)tv.tv_sec, (uintmax_t)tv.tv_usec,
> ++                                      tz.tz_minuteswest,    tz.tz_dsttime) < 0) {

LGTM

> +               np_uerror (ENOMEM);
> +               goto error;
> +       }
> +diff --git a/utils/dioddate.c b/utils/dioddate.c
> +index bde002f..f392792 100644
> +--- a/utils/dioddate.c
> ++++ b/utils/dioddate.c
> +@@ -21,6 +21,7 @@
> + #include <unistd.h>
> + #include <stdlib.h>
> + #include <stdint.h>
> ++#include <inttypes.h>
> + #include <stdarg.h>
> + #include <stdio.h>
> + #if HAVE_GETOPT_H
> +@@ -142,11 +143,16 @@ main (int argc, char *argv[])
> +         errn (np_rerror (), "error reading date");
> +         goto done;
> +     }
> +-    if (sscanf (buf, "%lu.%lu %d.%d", &tv.tv_sec, &tv.tv_usec,
> ++
> ++    int64_t sec = 0, usec = 0;
> ++    if (sscanf (buf, "%"SCNd64".%"SCNd64" %d.%d", &sec, &usec,
> +                                     &tz.tz_minuteswest, &tz.tz_dsttime) != 4) {
> +         msg ("error scanning returned date: %s", buf);
> +         goto done;
> +     }
> ++    tv.tv_sec = sec;
> ++    tv.tv_usec = usec;
> ++
> +     if (Sopt) {
> +         if (settimeofday (&tv, &tz) < 0)
> +             err_exit ("settimeofday");
> --
> 2.44.0
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#8686): https://lists.yoctoproject.org/g/meta-virtualization/message/8686
> Mute This Topic: https://lists.yoctoproject.org/mt/105632595/1997914
> Group Owner: meta-virtualization+owner@lists.yoctoproject.org
> Unsubscribe: https://lists.yoctoproject.org/g/meta-virtualization/unsub [raj.khem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>


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

* Re: [meta-virtualization] [PATCHv2] diod: Build in 32bit systems with 64bit time_t
  2024-04-20  7:29 [PATCHv2] diod: Build in 32bit systems with 64bit time_t Martin Jansa
  2024-04-20 16:10 ` [meta-virtualization] " Khem Raj
@ 2024-04-22  1:29 ` Bruce Ashfield
  2024-04-22 10:14   ` Ola x Nilsson
  1 sibling, 1 reply; 5+ messages in thread
From: Bruce Ashfield @ 2024-04-22  1:29 UTC (permalink / raw)
  To: martin.jansa; +Cc: meta-virtualization, Ola x Nilsson

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

On Sat, Apr 20, 2024 at 3:29 AM Martin Jansa via lists.yoctoproject.org
<martin.jansa=gmail.com@lists.yoctoproject.org> wrote:

> From: Ola x Nilsson <olani@axis.com>
>
> Signed-off-by: Ola x Nilsson <olani@axis.com>
> Signed-off-by: Martin Jansa <martin.jansa@gmail.com>
> ---
> v2: just fixed Author
>
>
While I appreciate the fix,  I'm going to wait until Ola ack's this, as I
need to know that their setup is fixed so that future patches have a
correct author field.

Otherwise, we are just pushing the issue of their configuration down the
road.

Bruce



>  recipes-extended/diod/diod_1.0.24.bb          |   1 +
>  ...ous-time_t-sizes-in-printf-and-scanf.patch | 100 ++++++++++++++++++
>  2 files changed, 101 insertions(+)
>  create mode 100644
> recipes-extended/diod/files/0002-Handle-various-time_t-sizes-in-printf-and-scanf.patch
>
> diff --git a/recipes-extended/diod/diod_1.0.24.bb b/recipes-extended/diod/
> diod_1.0.24.bb
> index 5e191dc0..6019fbfb 100644
> --- a/recipes-extended/diod/diod_1.0.24.bb
> +++ b/recipes-extended/diod/diod_1.0.24.bb
> @@ -14,6 +14,7 @@ SRC_URI = "git://
> github.com/chaos/diod.git;protocol=https;branch=master \
>             file://diod \
>             file://diod.conf \
>             file://0001-build-Find-lua-with-pkg-config.patch \
> +
>  file://0002-Handle-various-time_t-sizes-in-printf-and-scanf.patch \
>             "
>  DEPENDS = "libcap ncurses tcp-wrappers lua"
>
> diff --git
> a/recipes-extended/diod/files/0002-Handle-various-time_t-sizes-in-printf-and-scanf.patch
> b/recipes-extended/diod/files/0002-Handle-various-time_t-sizes-in-printf-and-scanf.patch
> new file mode 100644
> index 00000000..3c13c101
> --- /dev/null
> +++
> b/recipes-extended/diod/files/0002-Handle-various-time_t-sizes-in-printf-and-scanf.patch
> @@ -0,0 +1,100 @@
> +From 04b0c5a5cb9e32090b177ff7327ad3260783abe0 Mon Sep 17 00:00:00 2001
> +From: Ola x Nilsson <olani@axis.com>
> +Date: Mon, 15 Apr 2024 17:31:44 +0200
> +Subject: [PATCH] Handle various time_t sizes in printf and scanf
> +
> +The members of the timeval struct are both signed (defined by POSIX)
> +and typically both 64 bits on a system where time_t is 64 bits.  This
> +is possible also on 32 bit systems where time_t is larger to handle
> +the 2038 problem.
> +
> +It's practically impossible to find a type and printf format that
> +works even on all glibc systems.  Play it safe and always use printf
> +with intmax_t and explict int64_t variables for scanf.
> +
> +Upstream-Status: Submitted [https://github.com/chaos/diod/pull/100]
> +Signed-off-by: Ola x Nilsson <olani@axis.com>
> +---
> + libnpfs/conn.c   | 5 +++--
> + libnpfs/ctl.c    | 7 ++++---
> + utils/dioddate.c | 8 +++++++-
> + 3 files changed, 14 insertions(+), 6 deletions(-)
> +
> +diff --git a/libnpfs/conn.c b/libnpfs/conn.c
> +index 6e85fff..c34c840 100644
> +--- a/libnpfs/conn.c
> ++++ b/libnpfs/conn.c
> +@@ -16,6 +16,7 @@
> + #include <stdio.h>
> + #include <string.h>
> + #include <stdint.h>
> ++#include <inttypes.h>
> + #include <stdarg.h>
> + #include <errno.h>
> + #include <pthread.h>
> +@@ -133,8 +134,8 @@ _debug_trace (Npsrv *srv, Npfcall *fc)
> +                               (void)gettimeofday(&b, NULL);
> +                       (void)gettimeofday(&a, NULL);
> +                       timersub(&a, &b, &c);
> +-                      np_logmsg(srv, "[%lu.%-3lu] %s",
> +-                                c.tv_sec, c.tv_usec/1000, s);
> ++                      np_logmsg(srv, "[%"PRIdMAX".%-3"PRIdMAX"] %s",
> ++                                (intmax_t)c.tv_sec,
> (intmax_t)c.tv_usec/1000, s);
> +               } else
> +                       np_logmsg(srv, "%s", s);
> +       }
> +diff --git a/libnpfs/ctl.c b/libnpfs/ctl.c
> +index f40cde4..317a22e 100644
> +--- a/libnpfs/ctl.c
> ++++ b/libnpfs/ctl.c
> +@@ -16,6 +16,7 @@
> + #include <stdio.h>
> + #include <string.h>
> + #include <stdint.h>
> ++#include <inttypes.h>
> + #include <stdarg.h>
> + #include <pthread.h>
> + #include <errno.h>
> +@@ -291,9 +292,9 @@ _ctl_get_date (char *name, void *a)
> +               np_uerror (errno);
> +               goto error;
> +       }
> +-      if (aspf (&s, &len, "%lu.%lu %d.%d\n",
> +-                                      tv.tv_sec,         tv.tv_usec,
> +-                                      tz.tz_minuteswest, tz.tz_dsttime)
> < 0) {
> ++      if (aspf (&s, &len, "%"PRIdMAX".%"PRIdMAX" %d.%d\n",
> ++                                      (uintmax_t)tv.tv_sec,
> (uintmax_t)tv.tv_usec,
> ++                                      tz.tz_minuteswest,
> tz.tz_dsttime) < 0) {
> +               np_uerror (ENOMEM);
> +               goto error;
> +       }
> +diff --git a/utils/dioddate.c b/utils/dioddate.c
> +index bde002f..f392792 100644
> +--- a/utils/dioddate.c
> ++++ b/utils/dioddate.c
> +@@ -21,6 +21,7 @@
> + #include <unistd.h>
> + #include <stdlib.h>
> + #include <stdint.h>
> ++#include <inttypes.h>
> + #include <stdarg.h>
> + #include <stdio.h>
> + #if HAVE_GETOPT_H
> +@@ -142,11 +143,16 @@ main (int argc, char *argv[])
> +         errn (np_rerror (), "error reading date");
> +         goto done;
> +     }
> +-    if (sscanf (buf, "%lu.%lu %d.%d", &tv.tv_sec, &tv.tv_usec,
> ++
> ++    int64_t sec = 0, usec = 0;
> ++    if (sscanf (buf, "%"SCNd64".%"SCNd64" %d.%d", &sec, &usec,
> +                                     &tz.tz_minuteswest, &tz.tz_dsttime)
> != 4) {
> +         msg ("error scanning returned date: %s", buf);
> +         goto done;
> +     }
> ++    tv.tv_sec = sec;
> ++    tv.tv_usec = usec;
> ++
> +     if (Sopt) {
> +         if (settimeofday (&tv, &tz) < 0)
> +             err_exit ("settimeofday");
> --
> 2.44.0
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#8686):
> https://lists.yoctoproject.org/g/meta-virtualization/message/8686
> Mute This Topic: https://lists.yoctoproject.org/mt/105632595/1050810
> Group Owner: meta-virtualization+owner@lists.yoctoproject.org
> Unsubscribe: https://lists.yoctoproject.org/g/meta-virtualization/unsub [
> bruce.ashfield@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>

-- 
- Thou shalt not follow the NULL pointer, for chaos and madness await thee
at its end
- "Use the force Harry" - Gandalf, Star Trek II

[-- Attachment #2: Type: text/html, Size: 9754 bytes --]

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

* Re: [meta-virtualization] [PATCHv2] diod: Build in 32bit systems with 64bit time_t
  2024-04-22  1:29 ` Bruce Ashfield
@ 2024-04-22 10:14   ` Ola x Nilsson
  2024-04-22 10:37     ` Martin Jansa
  0 siblings, 1 reply; 5+ messages in thread
From: Ola x Nilsson @ 2024-04-22 10:14 UTC (permalink / raw)
  To: meta-virtualization


Sorry, I did not realize you required a new patch from me.
What was wrong with my patch exactly? I had already deleted the email
and could not see anything wrong in the groups.io web-ui.
I have not changed my setup and have sent patches successfully before.

(There is something wrong with our SMTP server today, I'm forced to use the outlook web client *shudder*.  Sorry if I sent this more than once by mistake. )

/Ola

On Sun, Apr 21 2024, Bruce Ashfield wrote:

> On Sat, Apr 20, 2024 at 3:29 AM Martin Jansa via lists.yoctoproject.org
> <martin.jansa=gmail.com@lists.yoctoproject.org> wrote:
>
>> From: Ola x Nilsson <olani@axis.com>
>>
>> Signed-off-by: Ola x Nilsson <olani@axis.com>
>> Signed-off-by: Martin Jansa <martin.jansa@gmail.com>
>> ---
>> v2: just fixed Author
>>
>>
> While I appreciate the fix,  I'm going to wait until Ola ack's this, as I
> need to know that their setup is fixed so that future patches have a
> correct author field.
>
> Otherwise, we are just pushing the issue of their configuration down the
> road.
>
> Bruce
>
>
>
>>  recipes-extended/diod/diod_1.0.24.bb          |   1 +
>>  ...ous-time_t-sizes-in-printf-and-scanf.patch | 100 ++++++++++++++++++
>>  2 files changed, 101 insertions(+)
>>  create mode 100644
>> recipes-extended/diod/files/0002-Handle-various-time_t-sizes-in-printf-and-scanf.patch
>>
>> diff --git a/recipes-extended/diod/diod_1.0.24.bb b/recipes-extended/diod/
>> diod_1.0.24.bb
>> index 5e191dc0..6019fbfb 100644
>> --- a/recipes-extended/diod/diod_1.0.24.bb
>> +++ b/recipes-extended/diod/diod_1.0.24.bb
>> @@ -14,6 +14,7 @@ SRC_URI = "git://
>> github.com/chaos/diod.git;protocol=https;branch=master \
>>             file://diod \
>>             file://diod.conf \
>>             file://0001-build-Find-lua-with-pkg-config.patch \
>> +
>>  file://0002-Handle-various-time_t-sizes-in-printf-and-scanf.patch \
>>             "
>>  DEPENDS = "libcap ncurses tcp-wrappers lua"
>>
>> diff --git
>> a/recipes-extended/diod/files/0002-Handle-various-time_t-sizes-in-printf-and-scanf.patch
>> b/recipes-extended/diod/files/0002-Handle-various-time_t-sizes-in-printf-and-scanf.patch
>> new file mode 100644
>> index 00000000..3c13c101
>> --- /dev/null
>> +++
>> b/recipes-extended/diod/files/0002-Handle-various-time_t-sizes-in-printf-and-scanf.patch
>> @@ -0,0 +1,100 @@
>> +From 04b0c5a5cb9e32090b177ff7327ad3260783abe0 Mon Sep 17 00:00:00 2001
>> +From: Ola x Nilsson <olani@axis.com>
>> +Date: Mon, 15 Apr 2024 17:31:44 +0200
>> +Subject: [PATCH] Handle various time_t sizes in printf and scanf
>> +
>> +The members of the timeval struct are both signed (defined by POSIX)
>> +and typically both 64 bits on a system where time_t is 64 bits.  This
>> +is possible also on 32 bit systems where time_t is larger to handle
>> +the 2038 problem.
>> +
>> +It's practically impossible to find a type and printf format that
>> +works even on all glibc systems.  Play it safe and always use printf
>> +with intmax_t and explict int64_t variables for scanf.
>> +
>> +Upstream-Status: Submitted [https://github.com/chaos/diod/pull/100]
>> +Signed-off-by: Ola x Nilsson <olani@axis.com>
>> +---
>> + libnpfs/conn.c   | 5 +++--
>> + libnpfs/ctl.c    | 7 ++++---
>> + utils/dioddate.c | 8 +++++++-
>> + 3 files changed, 14 insertions(+), 6 deletions(-)
>> +
>> +diff --git a/libnpfs/conn.c b/libnpfs/conn.c
>> +index 6e85fff..c34c840 100644
>> +--- a/libnpfs/conn.c
>> ++++ b/libnpfs/conn.c
>> +@@ -16,6 +16,7 @@
>> + #include <stdio.h>
>> + #include <string.h>
>> + #include <stdint.h>
>> ++#include <inttypes.h>
>> + #include <stdarg.h>
>> + #include <errno.h>
>> + #include <pthread.h>
>> +@@ -133,8 +134,8 @@ _debug_trace (Npsrv *srv, Npfcall *fc)
>> +                               (void)gettimeofday(&b, NULL);
>> +                       (void)gettimeofday(&a, NULL);
>> +                       timersub(&a, &b, &c);
>> +-                      np_logmsg(srv, "[%lu.%-3lu] %s",
>> +-                                c.tv_sec, c.tv_usec/1000, s);
>> ++                      np_logmsg(srv, "[%"PRIdMAX".%-3"PRIdMAX"] %s",
>> ++                                (intmax_t)c.tv_sec,
>> (intmax_t)c.tv_usec/1000, s);
>> +               } else
>> +                       np_logmsg(srv, "%s", s);
>> +       }
>> +diff --git a/libnpfs/ctl.c b/libnpfs/ctl.c
>> +index f40cde4..317a22e 100644
>> +--- a/libnpfs/ctl.c
>> ++++ b/libnpfs/ctl.c
>> +@@ -16,6 +16,7 @@
>> + #include <stdio.h>
>> + #include <string.h>
>> + #include <stdint.h>
>> ++#include <inttypes.h>
>> + #include <stdarg.h>
>> + #include <pthread.h>
>> + #include <errno.h>
>> +@@ -291,9 +292,9 @@ _ctl_get_date (char *name, void *a)
>> +               np_uerror (errno);
>> +               goto error;
>> +       }
>> +-      if (aspf (&s, &len, "%lu.%lu %d.%d\n",
>> +-                                      tv.tv_sec,         tv.tv_usec,
>> +-                                      tz.tz_minuteswest, tz.tz_dsttime)
>> < 0) {
>> ++      if (aspf (&s, &len, "%"PRIdMAX".%"PRIdMAX" %d.%d\n",
>> ++                                      (uintmax_t)tv.tv_sec,
>> (uintmax_t)tv.tv_usec,
>> ++                                      tz.tz_minuteswest,
>> tz.tz_dsttime) < 0) {
>> +               np_uerror (ENOMEM);
>> +               goto error;
>> +       }
>> +diff --git a/utils/dioddate.c b/utils/dioddate.c
>> +index bde002f..f392792 100644
>> +--- a/utils/dioddate.c
>> ++++ b/utils/dioddate.c
>> +@@ -21,6 +21,7 @@
>> + #include <unistd.h>
>> + #include <stdlib.h>
>> + #include <stdint.h>
>> ++#include <inttypes.h>
>> + #include <stdarg.h>
>> + #include <stdio.h>
>> + #if HAVE_GETOPT_H
>> +@@ -142,11 +143,16 @@ main (int argc, char *argv[])
>> +         errn (np_rerror (), "error reading date");
>> +         goto done;
>> +     }
>> +-    if (sscanf (buf, "%lu.%lu %d.%d", &tv.tv_sec, &tv.tv_usec,
>> ++
>> ++    int64_t sec = 0, usec = 0;
>> ++    if (sscanf (buf, "%"SCNd64".%"SCNd64" %d.%d", &sec, &usec,
>> +                                     &tz.tz_minuteswest, &tz.tz_dsttime)
>> != 4) {
>> +         msg ("error scanning returned date: %s", buf);
>> +         goto done;
>> +     }
>> ++    tv.tv_sec = sec;
>> ++    tv.tv_usec = usec;
>> ++
>> +     if (Sopt) {
>> +         if (settimeofday (&tv, &tz) < 0)
>> +             err_exit ("settimeofday");
>> --
>> 2.44.0
>>
>>
>> 
>>
>>


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

* Re: [meta-virtualization] [PATCHv2] diod: Build in 32bit systems with 64bit time_t
  2024-04-22 10:14   ` Ola x Nilsson
@ 2024-04-22 10:37     ` Martin Jansa
  0 siblings, 0 replies; 5+ messages in thread
From: Martin Jansa @ 2024-04-22 10:37 UTC (permalink / raw)
  To: ola.x.nilsson; +Cc: meta-virtualization

The From: in your original e-mail was mangled by ML:

...
From: "Ola x Nilsson via lists.yoctoproject.org"
<ola.x.nilsson=axis.com@lists.yoctoproject.org>
To: <meta-virtualization@lists.yoctoproject.org>
CC: <olani@axis.com>
Subject: [meta-virtualization][PATCH] diod: Build in 32bit systems
with 64bit time_t
...

See the e-mail from Bruce (with a link how to fix that):
https://lists.yoctoproject.org/g/meta-virtualization/message/8677

On Mon, Apr 22, 2024 at 12:14 PM Ola x Nilsson via
lists.yoctoproject.org <ola.x.nilsson=axis.com@lists.yoctoproject.org>
wrote:
>
>
> Sorry, I did not realize you required a new patch from me.
> What was wrong with my patch exactly? I had already deleted the email
> and could not see anything wrong in the groups.io web-ui.
> I have not changed my setup and have sent patches successfully before.
>
> (There is something wrong with our SMTP server today, I'm forced to use the outlook web client *shudder*.  Sorry if I sent this more than once by mistake. )
>
> /Ola
>
> On Sun, Apr 21 2024, Bruce Ashfield wrote:
>
> > On Sat, Apr 20, 2024 at 3:29 AM Martin Jansa via lists.yoctoproject.org
> > <martin.jansa=gmail.com@lists.yoctoproject.org> wrote:
> >
> >> From: Ola x Nilsson <olani@axis.com>
> >>
> >> Signed-off-by: Ola x Nilsson <olani@axis.com>
> >> Signed-off-by: Martin Jansa <martin.jansa@gmail.com>
> >> ---
> >> v2: just fixed Author
> >>
> >>
> > While I appreciate the fix,  I'm going to wait until Ola ack's this, as I
> > need to know that their setup is fixed so that future patches have a
> > correct author field.
> >
> > Otherwise, we are just pushing the issue of their configuration down the
> > road.
> >
> > Bruce
> >
> >
> >
> >>  recipes-extended/diod/diod_1.0.24.bb          |   1 +
> >>  ...ous-time_t-sizes-in-printf-and-scanf.patch | 100 ++++++++++++++++++
> >>  2 files changed, 101 insertions(+)
> >>  create mode 100644
> >> recipes-extended/diod/files/0002-Handle-various-time_t-sizes-in-printf-and-scanf.patch
> >>
> >> diff --git a/recipes-extended/diod/diod_1.0.24.bb b/recipes-extended/diod/
> >> diod_1.0.24.bb
> >> index 5e191dc0..6019fbfb 100644
> >> --- a/recipes-extended/diod/diod_1.0.24.bb
> >> +++ b/recipes-extended/diod/diod_1.0.24.bb
> >> @@ -14,6 +14,7 @@ SRC_URI = "git://
> >> github.com/chaos/diod.git;protocol=https;branch=master \
> >>             file://diod \
> >>             file://diod.conf \
> >>             file://0001-build-Find-lua-with-pkg-config.patch \
> >> +
> >>  file://0002-Handle-various-time_t-sizes-in-printf-and-scanf.patch \
> >>             "
> >>  DEPENDS = "libcap ncurses tcp-wrappers lua"
> >>
> >> diff --git
> >> a/recipes-extended/diod/files/0002-Handle-various-time_t-sizes-in-printf-and-scanf.patch
> >> b/recipes-extended/diod/files/0002-Handle-various-time_t-sizes-in-printf-and-scanf.patch
> >> new file mode 100644
> >> index 00000000..3c13c101
> >> --- /dev/null
> >> +++
> >> b/recipes-extended/diod/files/0002-Handle-various-time_t-sizes-in-printf-and-scanf.patch
> >> @@ -0,0 +1,100 @@
> >> +From 04b0c5a5cb9e32090b177ff7327ad3260783abe0 Mon Sep 17 00:00:00 2001
> >> +From: Ola x Nilsson <olani@axis.com>
> >> +Date: Mon, 15 Apr 2024 17:31:44 +0200
> >> +Subject: [PATCH] Handle various time_t sizes in printf and scanf
> >> +
> >> +The members of the timeval struct are both signed (defined by POSIX)
> >> +and typically both 64 bits on a system where time_t is 64 bits.  This
> >> +is possible also on 32 bit systems where time_t is larger to handle
> >> +the 2038 problem.
> >> +
> >> +It's practically impossible to find a type and printf format that
> >> +works even on all glibc systems.  Play it safe and always use printf
> >> +with intmax_t and explict int64_t variables for scanf.
> >> +
> >> +Upstream-Status: Submitted [https://github.com/chaos/diod/pull/100]
> >> +Signed-off-by: Ola x Nilsson <olani@axis.com>
> >> +---
> >> + libnpfs/conn.c   | 5 +++--
> >> + libnpfs/ctl.c    | 7 ++++---
> >> + utils/dioddate.c | 8 +++++++-
> >> + 3 files changed, 14 insertions(+), 6 deletions(-)
> >> +
> >> +diff --git a/libnpfs/conn.c b/libnpfs/conn.c
> >> +index 6e85fff..c34c840 100644
> >> +--- a/libnpfs/conn.c
> >> ++++ b/libnpfs/conn.c
> >> +@@ -16,6 +16,7 @@
> >> + #include <stdio.h>
> >> + #include <string.h>
> >> + #include <stdint.h>
> >> ++#include <inttypes.h>
> >> + #include <stdarg.h>
> >> + #include <errno.h>
> >> + #include <pthread.h>
> >> +@@ -133,8 +134,8 @@ _debug_trace (Npsrv *srv, Npfcall *fc)
> >> +                               (void)gettimeofday(&b, NULL);
> >> +                       (void)gettimeofday(&a, NULL);
> >> +                       timersub(&a, &b, &c);
> >> +-                      np_logmsg(srv, "[%lu.%-3lu] %s",
> >> +-                                c.tv_sec, c.tv_usec/1000, s);
> >> ++                      np_logmsg(srv, "[%"PRIdMAX".%-3"PRIdMAX"] %s",
> >> ++                                (intmax_t)c.tv_sec,
> >> (intmax_t)c.tv_usec/1000, s);
> >> +               } else
> >> +                       np_logmsg(srv, "%s", s);
> >> +       }
> >> +diff --git a/libnpfs/ctl.c b/libnpfs/ctl.c
> >> +index f40cde4..317a22e 100644
> >> +--- a/libnpfs/ctl.c
> >> ++++ b/libnpfs/ctl.c
> >> +@@ -16,6 +16,7 @@
> >> + #include <stdio.h>
> >> + #include <string.h>
> >> + #include <stdint.h>
> >> ++#include <inttypes.h>
> >> + #include <stdarg.h>
> >> + #include <pthread.h>
> >> + #include <errno.h>
> >> +@@ -291,9 +292,9 @@ _ctl_get_date (char *name, void *a)
> >> +               np_uerror (errno);
> >> +               goto error;
> >> +       }
> >> +-      if (aspf (&s, &len, "%lu.%lu %d.%d\n",
> >> +-                                      tv.tv_sec,         tv.tv_usec,
> >> +-                                      tz.tz_minuteswest, tz.tz_dsttime)
> >> < 0) {
> >> ++      if (aspf (&s, &len, "%"PRIdMAX".%"PRIdMAX" %d.%d\n",
> >> ++                                      (uintmax_t)tv.tv_sec,
> >> (uintmax_t)tv.tv_usec,
> >> ++                                      tz.tz_minuteswest,
> >> tz.tz_dsttime) < 0) {
> >> +               np_uerror (ENOMEM);
> >> +               goto error;
> >> +       }
> >> +diff --git a/utils/dioddate.c b/utils/dioddate.c
> >> +index bde002f..f392792 100644
> >> +--- a/utils/dioddate.c
> >> ++++ b/utils/dioddate.c
> >> +@@ -21,6 +21,7 @@
> >> + #include <unistd.h>
> >> + #include <stdlib.h>
> >> + #include <stdint.h>
> >> ++#include <inttypes.h>
> >> + #include <stdarg.h>
> >> + #include <stdio.h>
> >> + #if HAVE_GETOPT_H
> >> +@@ -142,11 +143,16 @@ main (int argc, char *argv[])
> >> +         errn (np_rerror (), "error reading date");
> >> +         goto done;
> >> +     }
> >> +-    if (sscanf (buf, "%lu.%lu %d.%d", &tv.tv_sec, &tv.tv_usec,
> >> ++
> >> ++    int64_t sec = 0, usec = 0;
> >> ++    if (sscanf (buf, "%"SCNd64".%"SCNd64" %d.%d", &sec, &usec,
> >> +                                     &tz.tz_minuteswest, &tz.tz_dsttime)
> >> != 4) {
> >> +         msg ("error scanning returned date: %s", buf);
> >> +         goto done;
> >> +     }
> >> ++    tv.tv_sec = sec;
> >> ++    tv.tv_usec = usec;
> >> ++
> >> +     if (Sopt) {
> >> +         if (settimeofday (&tv, &tz) < 0)
> >> +             err_exit ("settimeofday");
> >> --
> >> 2.44.0
> >>
> >>
> >>
> >>
> >>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#8689): https://lists.yoctoproject.org/g/meta-virtualization/message/8689
> Mute This Topic: https://lists.yoctoproject.org/mt/105632595/3617156
> Group Owner: meta-virtualization+owner@lists.yoctoproject.org
> Unsubscribe: https://lists.yoctoproject.org/g/meta-virtualization/unsub [martin.jansa@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>


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

end of thread, other threads:[~2024-04-22 10:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-20  7:29 [PATCHv2] diod: Build in 32bit systems with 64bit time_t Martin Jansa
2024-04-20 16:10 ` [meta-virtualization] " Khem Raj
2024-04-22  1:29 ` Bruce Ashfield
2024-04-22 10:14   ` Ola x Nilsson
2024-04-22 10:37     ` Martin Jansa

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