]> git.proxmox.com Git - mirror_frr.git/blobdiff - lib/ptm_lib.c
Merge pull request #7220 from idryzhov/fix-clear-isis
[mirror_frr.git] / lib / ptm_lib.c
index 54f027deebc33800874162dad0b91a85aceeffa7..e00dd54290571b05f77b0192de2ff44fe1cb6189 100644 (file)
@@ -65,10 +65,10 @@ static csv_record_t *_ptm_lib_encode_header(csv_t *csv, csv_record_t *rec,
        char client_buf[32];
        csv_record_t *rec1;
 
-       sprintf(msglen_buf, "%4d", msglen);
-       sprintf(vers_buf, "%4d", version);
-       sprintf(type_buf, "%4d", type);
-       sprintf(cmdid_buf, "%4d", cmd_id);
+       snprintf(msglen_buf, sizeof(msglen_buf), "%4d", msglen);
+       snprintf(vers_buf, sizeof(vers_buf), "%4d", version);
+       snprintf(type_buf, sizeof(type_buf), "%4d", type);
+       snprintf(cmdid_buf, sizeof(cmdid_buf), "%4d", cmd_id);
        snprintf(client_buf, 17, "%16.16s", client_name);
        if (rec) {
                rec1 = csv_encode_record(csv, rec, 5, msglen_buf, vers_buf,
@@ -143,7 +143,7 @@ int ptm_lib_append_msg(ptm_lib_handle_t *hdl, void *ctxt, const char *key,
        csv_record_t *mh_rec, *rec;
 
        if (!p_ctxt) {
-               ERRLOG("%s: no context \n", __FUNCTION__);
+               ERRLOG("%s: no context \n", __func__);
                return -1;
        }
 
@@ -154,7 +154,7 @@ int ptm_lib_append_msg(ptm_lib_handle_t *hdl, void *ctxt, const char *key,
        /* append to the hdr record */
        rec = csv_append_record(csv, rec, 1, key);
        if (!rec) {
-               ERRLOG("%s: Could not append key \n", __FUNCTION__);
+               ERRLOG("%s: Could not append key \n", __func__);
                return -1;
        }
 
@@ -162,7 +162,7 @@ int ptm_lib_append_msg(ptm_lib_handle_t *hdl, void *ctxt, const char *key,
        /* append to the data record */
        rec = csv_append_record(csv, rec, 1, val);
        if (!rec) {
-               ERRLOG("%s: Could not append val \n", __FUNCTION__);
+               ERRLOG("%s: Could not append val \n", __func__);
                return -1;
        }
 
@@ -186,7 +186,7 @@ int ptm_lib_init_msg(ptm_lib_handle_t *hdl, int cmd_id, int type, void *in_ctxt,
        csv = csv_init(NULL, NULL, PTMLIB_MSG_SZ);
 
        if (!csv) {
-               ERRLOG("%s: Could not allocate csv \n", __FUNCTION__);
+               ERRLOG("%s: Could not allocate csv \n", __func__);
                return -1;
        }
 
@@ -194,7 +194,7 @@ int ptm_lib_init_msg(ptm_lib_handle_t *hdl, int cmd_id, int type, void *in_ctxt,
                                     cmd_id, hdl->client_name);
 
        if (!rec) {
-               ERRLOG("%s: Could not allocate record \n", __FUNCTION__);
+               ERRLOG("%s: Could not allocate record \n", __func__);
                csv_clean(csv);
                csv_free(csv);
                return -1;
@@ -202,7 +202,7 @@ int ptm_lib_init_msg(ptm_lib_handle_t *hdl, int cmd_id, int type, void *in_ctxt,
 
        p_ctxt = calloc(1, sizeof(*p_ctxt));
        if (!p_ctxt) {
-               ERRLOG("%s: Could not allocate context \n", __FUNCTION__);
+               ERRLOG("%s: Could not allocate context \n", __func__);
                csv_clean(csv);
                csv_free(csv);
                return -1;
@@ -234,7 +234,7 @@ int ptm_lib_cleanup_msg(ptm_lib_handle_t *hdl, void *ctxt)
        csv_t *csv;
 
        if (!p_ctxt) {
-               ERRLOG("%s: no context \n", __FUNCTION__);
+               ERRLOG("%s: no context \n", __func__);
                return -1;
        }
 
@@ -254,7 +254,7 @@ int ptm_lib_complete_msg(ptm_lib_handle_t *hdl, void *ctxt, char *buf, int *len)
        csv_record_t *rec;
 
        if (!p_ctxt) {
-               ERRLOG("%s: no context \n", __FUNCTION__);
+               ERRLOG("%s: no context \n", __func__);
                return -1;
        }
 
@@ -268,7 +268,7 @@ int ptm_lib_complete_msg(ptm_lib_handle_t *hdl, void *ctxt, char *buf, int *len)
        /* parse csv contents into string */
        if (buf && len) {
                if (csv_serialize(csv, buf, *len)) {
-                       ERRLOG("%s: cannot serialize\n", __FUNCTION__);
+                       ERRLOG("%s: cannot serialize\n", __func__);
                        return -1;
                }
                *len = csvlen(csv);
@@ -425,8 +425,7 @@ int ptm_lib_process_msg(ptm_lib_handle_t *hdl, int fd, char *inbuf, int inlen,
                csv_decode(csv, inbuf);
                p_ctxt = calloc(1, sizeof(*p_ctxt));
                if (!p_ctxt) {
-                       ERRLOG("%s: Could not allocate context \n",
-                              __FUNCTION__);
+                       ERRLOG("%s: Could not allocate context \n", __func__);
                        csv_clean(csv);
                        csv_free(csv);
                        return -1;