]> git.puffer.fish Git - mirror/frr.git/commitdiff
ospfd: changes for code maintainability 11853/head
authorsri-mohan1 <sri.mohan@samsung.com>
Tue, 23 Aug 2022 16:45:38 +0000 (22:15 +0530)
committersri-mohan1 <sri.mohan@samsung.com>
Tue, 23 Aug 2022 16:48:33 +0000 (22:18 +0530)
these changes are for improving the code maintainability

Signed-off-by: sri-mohan1 <sri.mohan@samsung.com>
ospfd/ospf_opaque.c

index c7ac81d9616a9c35a3246c70aed61b8a75c5feb5..261d69df338d5bd24a3853f6ef72a746eaa02149 100644 (file)
@@ -358,9 +358,8 @@ static struct list *ospf_get_opaque_funclist(uint8_t lsa_type)
                funclist = ospf_opaque_type11_funclist;
                break;
        default:
-               flog_warn(EC_OSPF_LSA_UNEXPECTED,
-                         "ospf_get_opaque_funclist: Unexpected LSA-type(%u)",
-                         lsa_type);
+               flog_warn(EC_OSPF_LSA_UNEXPECTED, "%s: Unexpected LSA-type(%u)",
+                         __func__, lsa_type);
                break;
        }
        return funclist;
@@ -396,8 +395,8 @@ int ospf_register_opaque_functab(
                if (functab->opaque_type == opaque_type) {
                        flog_warn(
                                EC_OSPF_LSA,
-                               "ospf_register_opaque_functab: Duplicated entry?: lsa_type(%u), opaque_type(%u)",
-                               lsa_type, opaque_type);
+                               "%s: Duplicated entry?: lsa_type(%u), opaque_type(%u)",
+                               __func__, lsa_type, opaque_type);
                        return -1;
                }
 
@@ -565,10 +564,8 @@ register_opaque_info_per_type(struct ospf_opaque_functab *functab,
                listnode_add(top->opaque_lsa_self, oipt);
                break;
        default:
-               flog_warn(
-                       EC_OSPF_LSA_UNEXPECTED,
-                       "register_opaque_info_per_type: Unexpected LSA-type(%u)",
-                       new->data->type);
+               flog_warn(EC_OSPF_LSA_UNEXPECTED, "%s: Unexpected LSA-type(%u)",
+                         __func__, new->data->type);
                free_opaque_info_per_type(oipt, true);
                oipt = NULL;
                goto out; /* This case may not exist. */
@@ -675,9 +672,8 @@ lookup_opaque_info_by_type(struct ospf_lsa *lsa)
                listtop = top->opaque_lsa_self;
                break;
        default:
-               flog_warn(EC_OSPF_LSA_UNEXPECTED,
-                         "lookup_opaque_info_by_type: Unexpected LSA-type(%u)",
-                         lsa->data->type);
+               flog_warn(EC_OSPF_LSA_UNEXPECTED, "%s: Unexpected LSA-type(%u)",
+                         __func__, lsa->data->type);
                break;
        }
 
@@ -1303,16 +1299,14 @@ void ospf_opaque_lsa_originate_schedule(struct ospf_interface *oi, int *delay0)
 
        if ((top = oi_to_top(oi)) == NULL || (area = oi->area) == NULL) {
                if (IS_DEBUG_OSPF_EVENT)
-                       zlog_debug(
-                               "ospf_opaque_lsa_originate_schedule: Invalid argument?");
+                       zlog_debug("%s: Invalid argument?", __func__);
                return;
        }
 
        /* It may not a right time to schedule origination now. */
        if (!CHECK_FLAG(top->opaque, OPAQUE_OPERATION_READY_BIT)) {
                if (IS_DEBUG_OSPF_EVENT)
-                       zlog_debug(
-                               "ospf_opaque_lsa_originate_schedule: Not operational.");
+                       zlog_debug("%s: Not operational.", __func__);
                return; /* This is not an error. */
        }
 
@@ -1529,10 +1523,8 @@ static void ospf_opaque_lsa_reoriginate_resume(struct list *listtop, void *arg)
                        continue;
 
                if ((*functab->lsa_originator)(arg) != 0) {
-                       flog_warn(
-                               EC_OSPF_LSA,
-                               "ospf_opaque_lsa_reoriginate_resume: Failed (opaque-type=%u)",
-                               oipt->opaque_type);
+                       flog_warn(EC_OSPF_LSA, "%s: Failed (opaque-type=%u)",
+                                 __func__, oipt->opaque_type);
                        continue;
                }
        }
@@ -1570,8 +1562,7 @@ struct ospf_lsa *ospf_opaque_lsa_install(struct ospf_lsa *lsa, int rt_recalc)
        }
        /* Register the new lsa entry */
        else if (register_opaque_lsa(lsa) == NULL) {
-               flog_warn(EC_OSPF_LSA,
-                         "ospf_opaque_lsa_install: register_opaque_lsa() ?");
+               flog_warn(EC_OSPF_LSA, "%s: register_opaque_lsa() ?", __func__);
                goto out;
        }
 
@@ -1583,16 +1574,16 @@ struct ospf_lsa *ospf_opaque_lsa_install(struct ospf_lsa *lsa, int rt_recalc)
        case OSPF_OPAQUE_LINK_LSA:
                if ((top = oi_to_top(lsa->oi)) == NULL) {
                        /* Above conditions must have passed. */
-                       flog_warn(EC_OSPF_LSA,
-                                 "ospf_opaque_lsa_install: Something wrong?");
+                       flog_warn(EC_OSPF_LSA, "%s: Something wrong?",
+                                 __func__);
                        goto out;
                }
                break;
        case OSPF_OPAQUE_AREA_LSA:
                if (lsa->area == NULL || (top = lsa->area->ospf) == NULL) {
                        /* Above conditions must have passed. */
-                       flog_warn(EC_OSPF_LSA,
-                                 "ospf_opaque_lsa_install: Something wrong?");
+                       flog_warn(EC_OSPF_LSA, "%s: Something wrong?",
+                                 __func__);
                        goto out;
                }
                break;
@@ -1600,15 +1591,14 @@ struct ospf_lsa *ospf_opaque_lsa_install(struct ospf_lsa *lsa, int rt_recalc)
                top = ospf_lookup_by_vrf_id(lsa->vrf_id);
                if (lsa->area != NULL && (top = lsa->area->ospf) == NULL) {
                        /* Above conditions must have passed. */
-                       flog_warn(EC_OSPF_LSA,
-                                 "ospf_opaque_lsa_install: Something wrong?");
+                       flog_warn(EC_OSPF_LSA, "%s: Something wrong?",
+                                 __func__);
                        goto out;
                }
                break;
        default:
-               flog_warn(EC_OSPF_LSA_UNEXPECTED,
-                         "ospf_opaque_lsa_install: Unexpected LSA-type(%u)",
-                         lsa->data->type);
+               flog_warn(EC_OSPF_LSA_UNEXPECTED, "%s: Unexpected LSA-type(%u)",
+                         __func__, lsa->data->type);
                goto out;
        }
 
@@ -1679,16 +1669,14 @@ void ospf_opaque_lsa_reoriginate_schedule(void *lsa_type_dependent,
        case OSPF_OPAQUE_LINK_LSA:
                if ((oi = (struct ospf_interface *)lsa_type_dependent)
                    == NULL) {
-                       flog_warn(
-                               EC_OSPF_LSA,
-                               "ospf_opaque_lsa_reoriginate_schedule: Type-9 Opaque-LSA: Invalid parameter?");
+                       flog_warn(EC_OSPF_LSA,
+                                 "%s: Type-9 Opaque-LSA: Invalid parameter?",
+                                 __func__);
                        goto out;
                }
                if ((top = oi_to_top(oi)) == NULL) {
-                       flog_warn(
-                               EC_OSPF_LSA,
-                               "ospf_opaque_lsa_reoriginate_schedule: OI(%s) -> TOP?",
-                               IF_NAME(oi));
+                       flog_warn(EC_OSPF_LSA, "%s: OI(%s) -> TOP?", __func__,
+                                 IF_NAME(oi));
                        goto out;
                }
                if (!list_isempty(ospf_opaque_type9_funclist)
@@ -1704,16 +1692,14 @@ void ospf_opaque_lsa_reoriginate_schedule(void *lsa_type_dependent,
                break;
        case OSPF_OPAQUE_AREA_LSA:
                if ((area = (struct ospf_area *)lsa_type_dependent) == NULL) {
-                       flog_warn(
-                               EC_OSPF_LSA,
-                               "ospf_opaque_lsa_reoriginate_schedule: Type-10 Opaque-LSA: Invalid parameter?");
+                       flog_warn(EC_OSPF_LSA,
+                                 "%s: Type-10 Opaque-LSA: Invalid parameter?",
+                                 __func__);
                        goto out;
                }
                if ((top = area->ospf) == NULL) {
-                       flog_warn(
-                               EC_OSPF_LSA,
-                               "ospf_opaque_lsa_reoriginate_schedule: AREA(%pI4) -> TOP?",
-                               &area->area_id);
+                       flog_warn(EC_OSPF_LSA, "%s: AREA(%pI4) -> TOP?",
+                                 __func__, &area->area_id);
                        goto out;
                }
                if (!list_isempty(ospf_opaque_type10_funclist)
@@ -1729,9 +1715,9 @@ void ospf_opaque_lsa_reoriginate_schedule(void *lsa_type_dependent,
                break;
        case OSPF_OPAQUE_AS_LSA:
                if ((top = (struct ospf *)lsa_type_dependent) == NULL) {
-                       flog_warn(
-                               EC_OSPF_LSA,
-                               "ospf_opaque_lsa_reoriginate_schedule: Type-11 Opaque-LSA: Invalid parameter?");
+                       flog_warn(EC_OSPF_LSA,
+                                 "%s: Type-11 Opaque-LSA: Invalid parameter?",
+                                 __func__);
                        goto out;
                }
                if (!list_isempty(ospf_opaque_type11_funclist)
@@ -1751,18 +1737,15 @@ void ospf_opaque_lsa_reoriginate_schedule(void *lsa_type_dependent,
                func = ospf_opaque_type11_lsa_reoriginate_timer;
                break;
        default:
-               flog_warn(
-                       EC_OSPF_LSA_UNEXPECTED,
-                       "ospf_opaque_lsa_reoriginate_schedule: Unexpected LSA-type(%u)",
-                       lsa_type);
+               flog_warn(EC_OSPF_LSA_UNEXPECTED, "%s: Unexpected LSA-type(%u)",
+                         __func__, lsa_type);
                goto out;
        }
 
        /* It may not a right time to schedule reorigination now. */
        if (!CHECK_FLAG(top->opaque, OPAQUE_OPERATION_READY_BIT)) {
                if (IS_DEBUG_OSPF_EVENT)
-                       zlog_debug(
-                               "ospf_opaque_lsa_reoriginate_schedule: Not operational.");
+                       zlog_debug("%s: Not operational.", __func__);
                goto out; /* This is not an error. */
        }
 
@@ -1775,16 +1758,16 @@ void ospf_opaque_lsa_reoriginate_schedule(void *lsa_type_dependent,
                if ((functab = ospf_opaque_functab_lookup(lsa)) == NULL) {
                        flog_warn(
                                EC_OSPF_LSA,
-                               "ospf_opaque_lsa_reoriginate_schedule: No associated function?: lsa_type(%u), opaque_type(%u)",
-                               lsa_type, opaque_type);
+                               "%s: No associated function?: lsa_type(%u), opaque_type(%u)",
+                               __func__, lsa_type, opaque_type);
                        goto out;
                }
                if ((oipt = register_opaque_info_per_type(functab, lsa))
                    == NULL) {
                        flog_warn(
                                EC_OSPF_LSA,
-                               "ospf_opaque_lsa_reoriginate_schedule: Cannot get a control info?: lsa_type(%u), opaque_type(%u)",
-                               lsa_type, opaque_type);
+                               "%s: Cannot get a control info?: lsa_type(%u), opaque_type(%u)",
+                               __func__, lsa_type, opaque_type);
                        goto out;
                }
        }
@@ -1850,17 +1833,13 @@ static void ospf_opaque_type9_lsa_reoriginate_timer(struct thread *t)
 
        if ((functab = oipt->functab) == NULL
            || functab->lsa_originator == NULL) {
-               flog_warn(
-                       EC_OSPF_LSA,
-                       "ospf_opaque_type9_lsa_reoriginate_timer: No associated function?");
+               flog_warn(EC_OSPF_LSA, "%s: No associated function?", __func__);
                return;
        }
 
        oi = (struct ospf_interface *)oipt->owner;
        if ((top = oi_to_top(oi)) == NULL) {
-               flog_warn(
-                       EC_OSPF_LSA,
-                       "ospf_opaque_type9_lsa_reoriginate_timer: Something wrong?");
+               flog_warn(EC_OSPF_LSA, "%s: Something wrong?", __func__);
                return;
        }
 
@@ -1898,17 +1877,13 @@ static void ospf_opaque_type10_lsa_reoriginate_timer(struct thread *t)
 
        if ((functab = oipt->functab) == NULL
            || functab->lsa_originator == NULL) {
-               flog_warn(
-                       EC_OSPF_LSA,
-                       "ospf_opaque_type10_lsa_reoriginate_timer: No associated function?");
+               flog_warn(EC_OSPF_LSA, "%s: No associated function?", __func__);
                return;
        }
 
        area = (struct ospf_area *)oipt->owner;
        if (area == NULL || (top = area->ospf) == NULL) {
-               flog_warn(
-                       EC_OSPF_LSA,
-                       "ospf_opaque_type10_lsa_reoriginate_timer: Something wrong?");
+               flog_warn(EC_OSPF_LSA, "%s: Something wrong?", __func__);
                return;
        }
 
@@ -1947,16 +1922,12 @@ static void ospf_opaque_type11_lsa_reoriginate_timer(struct thread *t)
 
        if ((functab = oipt->functab) == NULL
            || functab->lsa_originator == NULL) {
-               flog_warn(
-                       EC_OSPF_LSA,
-                       "ospf_opaque_type11_lsa_reoriginate_timer: No associated function?");
+               flog_warn(EC_OSPF_LSA, "%s: No associated function?", __func__);
                return;
        }
 
        if ((top = (struct ospf *)oipt->owner) == NULL) {
-               flog_warn(
-                       EC_OSPF_LSA,
-                       "ospf_opaque_type11_lsa_reoriginate_timer: Something wrong?");
+               flog_warn(EC_OSPF_LSA, "%s: Something wrong?", __func__);
                return;
        }
 
@@ -1988,16 +1959,13 @@ void ospf_opaque_lsa_refresh_schedule(struct ospf_lsa *lsa0)
 
        if ((oipt = lookup_opaque_info_by_type(lsa0)) == NULL
            || (oipi = lookup_opaque_info_by_id(oipt, lsa0)) == NULL) {
-               flog_warn(
-                       EC_OSPF_LSA,
-                       "ospf_opaque_lsa_refresh_schedule: Invalid parameter?");
+               flog_warn(EC_OSPF_LSA, "%s: Invalid parameter?", __func__);
                goto out;
        }
 
        /* Given "lsa0" and current "oipi->lsa" may different, but harmless. */
        if ((lsa = oipi->lsa) == NULL) {
-               flog_warn(EC_OSPF_LSA,
-                         "ospf_opaque_lsa_refresh_schedule: Something wrong?");
+               flog_warn(EC_OSPF_LSA, "%s: Something wrong?", __func__);
                goto out;
        }
 
@@ -2024,10 +1992,8 @@ void ospf_opaque_lsa_refresh_schedule(struct ospf_lsa *lsa0)
                ospf_ls_retransmit_delete_nbr_as(top, lsa);
                break;
        default:
-               flog_warn(
-                       EC_OSPF_LSA_UNEXPECTED,
-                       "ospf_opaque_lsa_refresh_schedule: Unexpected LSA-type(%u)",
-                       lsa->data->type);
+               flog_warn(EC_OSPF_LSA_UNEXPECTED, "%s: Unexpected LSA-type(%u)",
+                         __func__, lsa->data->type);
                goto out;
        }
 
@@ -2074,15 +2040,13 @@ void ospf_opaque_lsa_flush_schedule(struct ospf_lsa *lsa0)
 
        if ((oipt = lookup_opaque_info_by_type(lsa0)) == NULL
            || (oipi = lookup_opaque_info_by_id(oipt, lsa0)) == NULL) {
-               flog_warn(EC_OSPF_LSA,
-                         "ospf_opaque_lsa_flush_schedule: Invalid parameter?");
+               flog_warn(EC_OSPF_LSA, "%s: Invalid parameter?", __func__);
                goto out;
        }
 
        /* Given "lsa0" and current "oipi->lsa" may different, but harmless. */
        if ((lsa = oipi->lsa) == NULL) {
-               flog_warn(EC_OSPF_LSA,
-                         "ospf_opaque_lsa_flush_schedule: Something wrong?");
+               flog_warn(EC_OSPF_LSA, "%s: Something wrong?", __func__);
                goto out;
        }
 
@@ -2098,10 +2062,8 @@ void ospf_opaque_lsa_flush_schedule(struct ospf_lsa *lsa0)
                ospf_ls_retransmit_delete_nbr_as(top, lsa);
                break;
        default:
-               flog_warn(
-                       EC_OSPF_LSA_UNEXPECTED,
-                       "ospf_opaque_lsa_flush_schedule: Unexpected LSA-type(%u)",
-                       lsa->data->type);
+               flog_warn(EC_OSPF_LSA_UNEXPECTED, "%s: Unexpected LSA-type(%u)",
+                         __func__, lsa->data->type);
                goto out;
        }
 
@@ -2154,10 +2116,8 @@ void ospf_opaque_self_originated_lsa_received(struct ospf_neighbor *nbr,
                ospf_flood_through_as(top, NULL /*inbr*/, lsa);
                break;
        default:
-               flog_warn(
-                       EC_OSPF_LSA_UNEXPECTED,
-                       "ospf_opaque_self_originated_lsa_received: Unexpected LSA-type(%u)",
-                       lsa->data->type);
+               flog_warn(EC_OSPF_LSA_UNEXPECTED, "%s: Unexpected LSA-type(%u)",
+                         __func__, lsa->data->type);
                return;
        }
        ospf_lsa_discard(lsa); /* List "lsas" will be deleted by caller. */