]> xenbits.xensource.com Git - libvirt.git/commitdiff
virNWFilterSnoopLeaseFileLoad: Don't typecast 'ipl.timeout'
authorPeter Krempa <pkrempa@redhat.com>
Fri, 6 Jan 2023 15:22:42 +0000 (16:22 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 9 Jan 2023 12:54:56 +0000 (13:54 +0100)
Use a temporary variable to avoid memory alignment issues on ARM:

../src/nwfilter/nwfilter_dhcpsnoop.c: In function â€˜virNWFilterSnoopLeaseFileLoad’:
../src/nwfilter/nwfilter_dhcpsnoop.c:1745:20: error: cast increases required alignment of target type [-Werror=cast-align]
 1745 |                    (unsigned long long *) &ipl.timeout,
      |

Fixes: 0d278aa089bf3a00bf2d6e56d2f01ea4677190a7
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
src/nwfilter/nwfilter_dhcpsnoop.c

index e604d67b9677caeaef94cdfdfef2d903d6664705..20afc1b2d415682e9c7debac14957e5512ad2e95 100644 (file)
@@ -1733,6 +1733,8 @@ virNWFilterSnoopLeaseFileLoad(void)
     fp = fopen(LEASEFILE, "r");
     time(&now);
     while (fp && fgets(line, sizeof(line), fp)) {
+        unsigned long long timeout;
+
         if (line[strlen(line)-1] != '\n') {
             virReportError(VIR_ERR_INTERNAL_ERROR,
                            _("virNWFilterSnoopLeaseFileLoad lease file "
@@ -1742,13 +1744,13 @@ virNWFilterSnoopLeaseFileLoad(void)
         ln++;
         /* key len 54 = "VMUUID"+'-'+"MAC" */
         if (sscanf(line, "%llu %54s %15s %15s",
-                   (unsigned long long *) &ipl.timeout,
-                   ifkey, ipstr, srvstr) < 4) {
+                   &timeout, ifkey, ipstr, srvstr) < 4) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
                            _("virNWFilterSnoopLeaseFileLoad lease file "
                              "line %d corrupt"), ln);
             break;
         }
+        ipl.timeout = timeout;
         if (ipl.timeout && ipl.timeout < now)
             continue;
         req = virNWFilterSnoopReqGetByIFKey(ifkey);