]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: Remove dead SRv6 code
authorCarmine Scarpitta <cscarpit@cisco.com>
Fri, 21 Jun 2024 15:01:49 +0000 (17:01 +0200)
committerCarmine Scarpitta <cscarpit@cisco.com>
Mon, 24 Jun 2024 08:43:00 +0000 (10:43 +0200)
At line 1736, `alloc_mode` is set to `SRV6_SID_ALLOC_MODE_EXPLICIT` or
`SRV6_SID_ALLOC_MODE_DYNAMIC` depending on the `sid_value` variable.

There will never be a case where alloc_mode will be `SRV6_SID_ALLOC_MODE_MAX`
or `SRV6_SID_ALLOC_MODE_UNSPEC`.

Let's replace the `switch(alloc_mode) {...}` with an if-else.

Fixes CID 1594015.

** CID 1594015:    (DEADCODE)
/zebra/zebra_srv6.c: 1782 in get_srv6_sid()
/zebra/zebra_srv6.c: 1781 in get_srv6_sid()

________________________________________________________________________________________________________
*** CID 1594015:    (DEADCODE)
/zebra/zebra_srv6.c: 1782 in get_srv6_sid()
1776      }
1777
1778      ret = get_srv6_sid_dynamic(sid, ctx, locator);
1779
1780      break;
1781      case SRV6_SID_ALLOC_MODE_MAX:
     CID 1594015:    (DEADCODE)
     Execution cannot reach this statement: "case SRV6_SID_ALLOC_MODE_UN...".
1782      case SRV6_SID_ALLOC_MODE_UNSPEC:
1783      default:
1784      flog_err(EC_ZEBRA_SM_CANNOT_ASSIGN_SID,
1785       "%s: SRv6 Manager: Unrecognized alloc mode %u",
1786       __func__, alloc_mode);
1787      /* We should never arrive here */
/zebra/zebra_srv6.c: 1781 in get_srv6_sid()
1775      return -1;
1776      }
1777
1778      ret = get_srv6_sid_dynamic(sid, ctx, locator);
1779
1780      break;
     CID 1594015:    (DEADCODE)
     Execution cannot reach this statement: "case SRV6_SID_ALLOC_MODE_MAX:".
1781      case SRV6_SID_ALLOC_MODE_MAX:
1782      case SRV6_SID_ALLOC_MODE_UNSPEC:
1783      default:
1784      flog_err(EC_ZEBRA_SM_CANNOT_ASSIGN_SID,
1785       "%s: SRv6 Manager: Unrecognized alloc mode %u",
1786       __func__, alloc_mode);

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
zebra/zebra_srv6.c

index 0ca77a49740c5c3d88d7b043a4dd5fe3037a30ff..2c1f86a3fc3ccb7e6752c7a96d4601a9864f8db2 100644 (file)
@@ -1742,8 +1742,7 @@ int get_srv6_sid(struct zebra_srv6_sid **sid, struct srv6_sid_ctx *ctx,
                           __func__, srv6_sid_ctx2str(buf, sizeof(buf), ctx),
                           sid_value, srv6_sid_alloc_mode2str(alloc_mode));
 
-       switch (alloc_mode) {
-       case SRV6_SID_ALLOC_MODE_EXPLICIT:
+       if (alloc_mode == SRV6_SID_ALLOC_MODE_EXPLICIT) {
                /*
                 * Explicit SID allocation: allocate a specific SID value
                 */
@@ -1755,9 +1754,7 @@ int get_srv6_sid(struct zebra_srv6_sid **sid, struct srv6_sid_ctx *ctx,
                }
 
                ret = get_srv6_sid_explicit(sid, ctx, sid_value);
-
-               break;
-       case SRV6_SID_ALLOC_MODE_DYNAMIC:
+       } else {
                /*
                 * Dynamic SID allocation: allocate any available SID value
                 */
@@ -1776,16 +1773,6 @@ int get_srv6_sid(struct zebra_srv6_sid **sid, struct srv6_sid_ctx *ctx,
                }
 
                ret = get_srv6_sid_dynamic(sid, ctx, locator);
-
-               break;
-       case SRV6_SID_ALLOC_MODE_MAX:
-       case SRV6_SID_ALLOC_MODE_UNSPEC:
-       default:
-               flog_err(EC_ZEBRA_SM_CANNOT_ASSIGN_SID,
-                        "%s: SRv6 Manager: Unrecognized alloc mode %u",
-                        __func__, alloc_mode);
-               /* We should never arrive here */
-               assert(0);
        }
 
        return ret;