[PATCH 09/22] nwfilter: Fix misaligned arguments and misaligned conditions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch fixes misaligned arguments and misaligned conditions.

Signed-off-by: Shi Lei <shi_lei@xxxxxxxxxxxxxx>
---
 src/nwfilter/nwfilter_dhcpsnoop.c         | 10 +++----
 src/nwfilter/nwfilter_driver.c            |  8 ++---
 src/nwfilter/nwfilter_ebiptables_driver.c | 18 +++++-------
 src/nwfilter/nwfilter_learnipaddr.c       | 36 +++++++++--------------
 4 files changed, 31 insertions(+), 41 deletions(-)

diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcpsnoop.c
index e40f649..535c88d 100644
--- a/src/nwfilter/nwfilter_dhcpsnoop.c
+++ b/src/nwfilter/nwfilter_dhcpsnoop.c
@@ -1537,12 +1537,12 @@ virNWFilterDHCPSnoopThread(void *req0)
                 }
 
                 if (virNWFilterSnoopDHCPDecodeJobSubmit(worker, packet,
-                                                      hdr->caplen,
-                                                      pcapConf[i].dir,
-                                                      &pcapConf[i].qCtr) < 0) {
+                                                        hdr->caplen,
+                                                        pcapConf[i].dir,
+                                                        &pcapConf[i].qCtr) < 0) {
                     virReportError(VIR_ERR_INTERNAL_ERROR,
-                                   _("Job submission failed on "
-                                     "interface '%s'"), req->binding->portdevname);
+                                   _("Job submission failed on interface '%s'"),
+                                   req->binding->portdevname);
                     error = true;
                     break;
                 }
diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c
index 1ee5162..8737769 100644
--- a/src/nwfilter/nwfilter_driver.c
+++ b/src/nwfilter/nwfilter_driver.c
@@ -228,7 +228,7 @@ nwfilterStateInitialize(bool privileged,
         nwfilterDriverInstallDBusMatches(sysbus) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("DBus matches could not be installed. "
-                       "Disabling nwfilter driver"));
+                         "Disabling nwfilter driver"));
         /*
          * unfortunately this is fatal since virNWFilterTechDriversInit
          * may have caused the ebiptables driver to use the firewall tool
@@ -495,7 +495,7 @@ nwfilterConnectNumOfNWFilters(virConnectPtr conn)
         return -1;
 
     return virNWFilterObjListNumOfNWFilters(driver->nwfilters, conn,
-                                        virConnectNumOfNWFiltersCheckACL);
+                                            virConnectNumOfNWFiltersCheckACL);
 }
 
 
@@ -511,8 +511,8 @@ nwfilterConnectListNWFilters(virConnectPtr conn,
 
     nwfilterDriverLock();
     nnames = virNWFilterObjListGetNames(driver->nwfilters, conn,
-                                    virConnectListNWFiltersCheckACL,
-                                    names, maxnames);
+                                        virConnectListNWFiltersCheckACL,
+                                        names, maxnames);
     nwfilterDriverUnlock();
     return nnames;
 }
diff --git a/src/nwfilter/nwfilter_ebiptables_driver.c b/src/nwfilter/nwfilter_ebiptables_driver.c
index 5be1c9b..7ace424 100644
--- a/src/nwfilter/nwfilter_ebiptables_driver.c
+++ b/src/nwfilter/nwfilter_ebiptables_driver.c
@@ -1703,7 +1703,7 @@ iptablesCreateRuleInstance(virFirewallPtr fw,
     const char *matchState;
 
     if (!(rule->flags & RULE_FLAG_NO_STATEMATCH) &&
-         (rule->flags & IPTABLES_STATE_FLAGS)) {
+        (rule->flags & IPTABLES_STATE_FLAGS)) {
         return iptablesCreateRuleInstanceStateCtrl(fw,
                                                    layer,
                                                    rule,
@@ -1833,8 +1833,7 @@ ebtablesCreateRuleInstance(virFirewallPtr fw,
     virBuffer buf = VIR_BUFFER_INITIALIZER;
 
     if (STREQ(chainSuffix,
-              virNWFilterChainSuffixTypeToString(
-                  VIR_NWFILTER_CHAINSUFFIX_ROOT)))
+              virNWFilterChainSuffixTypeToString(VIR_NWFILTER_CHAINSUFFIX_ROOT)))
         PRINT_ROOT_CHAIN(chain, chainPrefix, ifname);
     else
         PRINT_CHAIN(chain, chainPrefix, ifname,
@@ -1927,7 +1926,7 @@ ebtablesCreateRuleInstance(virFirewallPtr fw,
                            _("STP filtering in %s direction with "
                              "source MAC address set is not supported"),
                            virNWFilterRuleDirectionTypeToString(
-                               VIR_NWFILTER_RULE_DIRECTION_INOUT));
+                            VIR_NWFILTER_RULE_DIRECTION_INOUT));
             return -1;
         }
 
@@ -2441,8 +2440,7 @@ ebtablesCreateRuleInstance(virFirewallPtr fw,
     switch (rule->action) {
     case VIR_NWFILTER_RULE_ACTION_REJECT:
         /* REJECT not supported */
-        target = virNWFilterJumpTargetTypeToString(
-                                     VIR_NWFILTER_RULE_ACTION_DROP);
+        target = virNWFilterJumpTargetTypeToString(VIR_NWFILTER_RULE_ACTION_DROP);
         break;
     default:
         target = virNWFilterJumpTargetTypeToString(rule->action);
@@ -2722,7 +2720,7 @@ ebtablesRemoveSubChainsQuery(virFirewallPtr fw,
                 virFirewallAddRuleFull(fw, VIR_FIREWALL_LAYER_ETHERNET,
                                        false, ebtablesRemoveSubChainsQuery,
                                        (void *)chainprefixes,
-                                        "-t", "nat", "-L", tmp, NULL);
+                                       "-t", "nat", "-L", tmp, NULL);
                 virFirewallAddRuleFull(fw, VIR_FIREWALL_LAYER_ETHERNET,
                                        true, NULL, NULL,
                                        "-t", "nat", "-F", tmp, NULL);
@@ -3161,7 +3159,7 @@ virNWFilterRuleInstSort(const void *a, const void *b)
     const virNWFilterRuleInst *insta = a;
     const virNWFilterRuleInst *instb = b;
     const char *root = virNWFilterChainSuffixTypeToString(
-                                     VIR_NWFILTER_CHAINSUFFIX_ROOT);
+                        VIR_NWFILTER_CHAINSUFFIX_ROOT);
     bool root_a = STREQ(insta->chainSuffix, root);
     bool root_b = STREQ(instb->chainSuffix, root);
 
@@ -3222,7 +3220,7 @@ iptablesCheckBridgeNFCallEnabled(bool isIPv6)
                     char msg[256];
                     snprintf(msg, sizeof(msg),
                              _("To enable ip%stables filtering for the VM do "
-                              "'echo 1 > %s'"),
+                               "'echo 1 > %s'"),
                              isIPv6 ? "6" : "",
                              pathname);
                     VIR_WARN("%s", msg);
@@ -3361,7 +3359,7 @@ ebtablesGetSubChainInsts(virHashTablePtr chains,
     for (i = 0; filter_names[i].key; i++) {
         struct ebtablesSubChainInst *inst;
         enum l3_proto_idx idx = ebtablesGetProtoIdxByFiltername(
-                                  filter_names[i].key);
+                                    filter_names[i].key);
 
         if ((int)idx < 0)
             continue;
diff --git a/src/nwfilter/nwfilter_learnipaddr.c b/src/nwfilter/nwfilter_learnipaddr.c
index 008c24b..28bd8ad 100644
--- a/src/nwfilter/nwfilter_learnipaddr.c
+++ b/src/nwfilter/nwfilter_learnipaddr.c
@@ -556,11 +556,9 @@ learnIPAddressThread(void *arg)
                 /* packets from the VM */
 
                 if (etherType == ETHERTYPE_IP &&
-                    (header.len >= ethHdrSize +
-                                   sizeof(struct iphdr))) {
+                    (header.len >= ethHdrSize + sizeof(struct iphdr))) {
                     VIR_WARNINGS_NO_CAST_ALIGN
-                    struct iphdr *iphdr = (struct iphdr*)(packet +
-                                                          ethHdrSize);
+                    struct iphdr *iphdr = (struct iphdr*)(packet + ethHdrSize);
                     VIR_WARNINGS_RESET
                     vmaddr = iphdr->saddr;
                     /* skip mcast addresses (224.0.0.0 - 239.255.255.255),
@@ -574,11 +572,10 @@ learnIPAddressThread(void *arg)
 
                     howDetected = DETECT_STATIC;
                 } else if (etherType == ETHERTYPE_ARP &&
-                           (header.len >= ethHdrSize +
-                                          sizeof(struct f_arphdr))) {
+                           (header.len >= ethHdrSize + sizeof(struct f_arphdr))) {
                     VIR_WARNINGS_NO_CAST_ALIGN
                     struct f_arphdr *arphdr = (struct f_arphdr*)(packet +
-                                                         ethHdrSize);
+                                                                 ethHdrSize);
                     VIR_WARNINGS_RESET
                     switch (ntohs(arphdr->arphdr.ar_op)) {
                     case ARPOP_REPLY:
@@ -597,32 +594,27 @@ learnIPAddressThread(void *arg)
                        virMacAddrIsBroadcastRaw(ether_hdr->ether_dhost)) {
                 /* packets to the VM */
                 if (etherType == ETHERTYPE_IP &&
-                    (header.len >= ethHdrSize +
-                                   sizeof(struct iphdr))) {
+                    (header.len >= ethHdrSize + sizeof(struct iphdr))) {
                     VIR_WARNINGS_NO_CAST_ALIGN
-                    struct iphdr *iphdr = (struct iphdr*)(packet +
-                                                          ethHdrSize);
+                    struct iphdr *iphdr = (struct iphdr*)(packet + ethHdrSize);
                     VIR_WARNINGS_RESET
                     if ((iphdr->protocol == IPPROTO_UDP) &&
-                        (header.len >= ethHdrSize +
-                                       iphdr->ihl * 4 +
-                                       sizeof(struct udphdr))) {
+                        (header.len >=
+                         ethHdrSize + iphdr->ihl * 4 + sizeof(struct udphdr))) {
                         VIR_WARNINGS_NO_CAST_ALIGN
                         struct udphdr *udphdr = (struct udphdr *)
                                           ((char *)iphdr + iphdr->ihl * 4);
                         VIR_WARNINGS_RESET
                         if (ntohs(udphdr->source) == 67 &&
                             ntohs(udphdr->dest)   == 68 &&
-                            header.len >= ethHdrSize +
-                                          iphdr->ihl * 4 +
-                                          sizeof(struct udphdr) +
-                                          sizeof(struct dhcp)) {
+                            (header.len >= (ethHdrSize + iphdr->ihl * 4 +
+                                            sizeof(struct udphdr) +
+                                            sizeof(struct dhcp)))) {
                             struct dhcp *dhcp = (struct dhcp *)
                                         ((char *)udphdr + sizeof(udphdr));
                             if (dhcp->op == 2 /* BOOTREPLY */ &&
-                                virMacAddrCmpRaw(
-                                        &req->binding->mac,
-                                        &dhcp->chaddr[0]) == 0) {
+                                virMacAddrCmpRaw(&req->binding->mac,
+                                                 &dhcp->chaddr[0]) == 0) {
                                 dhcp_opts_len = header.len -
                                     (ethHdrSize + iphdr->ihl * 4 +
                                      sizeof(struct udphdr) +
@@ -670,7 +662,7 @@ learnIPAddressThread(void *arg)
         if ((inetaddr = virSocketAddrFormat(&sa)) != NULL) {
             if (virNWFilterIPAddrMapAddIPAddr(req->binding->portdevname, inetaddr) < 0) {
                 VIR_ERROR(_("Failed to add IP address %s to IP address "
-                          "cache for interface %s"), inetaddr, req->binding->portdevname);
+                            "cache for interface %s"), inetaddr, req->binding->portdevname);
             }
 
             ret = virNWFilterInstantiateFilterLate(req->driver,
-- 
2.17.1


--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux