Skip to content

Commit a5a3950

Browse files
authored
Merge pull request FRRouting#18790 from LabNConsulting/chopps/format-symbol-cleanup
Replace use of `__` as identifier prefix
2 parents 6c274eb + 7531f42 commit a5a3950

14 files changed

Lines changed: 717 additions & 835 deletions

lib/darr.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ static size_t darr_size(uint count, size_t esize)
5454
return count * esize + sizeof(struct darr_metadata);
5555
}
5656

57-
char *__darr_in_vsprintf(char **sp, bool concat, const char *fmt, va_list ap)
57+
char *_darr__in_vsprintf(char **sp, bool concat, const char *fmt, va_list ap)
5858
{
5959
size_t inlen = concat ? darr_strlen(*sp) : 0;
6060
size_t capcount = strlen(fmt) + MIN(inlen + 64, 128);
@@ -84,18 +84,18 @@ char *__darr_in_vsprintf(char **sp, bool concat, const char *fmt, va_list ap)
8484
return *sp;
8585
}
8686

87-
char *__darr_in_sprintf(char **sp, bool concat, const char *fmt, ...)
87+
char *_darr__in_sprintf(char **sp, bool concat, const char *fmt, ...)
8888
{
8989
va_list ap;
9090

9191
va_start(ap, fmt);
92-
(void)__darr_in_vsprintf(sp, concat, fmt, ap);
92+
(void)_darr__in_vsprintf(sp, concat, fmt, ap);
9393
va_end(ap);
9494
return *sp;
9595
}
9696

9797

98-
void *__darr_resize(void *a, uint count, size_t esize, struct memtype *mtype)
98+
void *_darr__resize(void *a, uint count, size_t esize, struct memtype *mtype)
9999
{
100100
uint ncount = darr_next_count(count, esize);
101101
size_t osz = (a == NULL) ? 0 : darr_size(darr_cap(a), esize);
@@ -115,14 +115,13 @@ void *__darr_resize(void *a, uint count, size_t esize, struct memtype *mtype)
115115
}
116116

117117

118-
void *__darr_insert_n(void *a, uint at, uint count, size_t esize, bool zero,
119-
struct memtype *mtype)
118+
void *_darr__insert_n(void *a, uint at, uint count, size_t esize, bool zero, struct memtype *mtype)
120119
{
121120
struct darr_metadata *dm;
122121
uint olen, nlen;
123122

124123
if (!a)
125-
a = __darr_resize(NULL, at + count, esize, mtype);
124+
a = _darr__resize(NULL, at + count, esize, mtype);
126125
dm = (struct darr_metadata *)a - 1;
127126
olen = dm->len;
128127

@@ -137,7 +136,7 @@ void *__darr_insert_n(void *a, uint at, uint count, size_t esize, bool zero,
137136
nlen = olen + count;
138137

139138
if (nlen > dm->cap) {
140-
a = __darr_resize(a, nlen, esize, mtype);
139+
a = _darr__resize(a, nlen, esize, mtype);
141140
dm = (struct darr_metadata *)a - 1;
142141
}
143142

lib/darr.h

Lines changed: 140 additions & 153 deletions
Large diffs are not rendered by default.

lib/mgmt_msg_native.h

Lines changed: 42 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -576,12 +576,10 @@ extern int vmgmt_msg_native_send_error(struct msg_conn *conn,
576576
*
577577
* Return: A `msg_type` object created using a dynamic_array.
578578
*/
579-
#define mgmt_msg_native_alloc_msg(msg_type, var_len, mem_type) \
580-
({ \
581-
uint8_t *__nam_buf = NULL; \
582-
(msg_type *)darr_append_nz_mt(__nam_buf, \
583-
sizeof(msg_type) + (var_len), \
584-
mem_type); \
579+
#define mgmt_msg_native_alloc_msg(msg_type, var_len, mem_type) \
580+
({ \
581+
uint8_t *_nam_buf = NULL; \
582+
(msg_type *)darr_append_nz_mt(_nam_buf, sizeof(msg_type) + (var_len), mem_type); \
585583
})
586584

587585
/**
@@ -612,12 +610,12 @@ extern int vmgmt_msg_native_send_error(struct msg_conn *conn,
612610
*
613611
* Return: a pointer to the newly appended data.
614612
*/
615-
#define mgmt_msg_native_append(msg, data, len) \
616-
({ \
617-
uint8_t **__na_darrp = mgmt_msg_native_get_darrp(msg); \
618-
uint8_t *__na_p = darr_append_n(*__na_darrp, len); \
619-
memcpy(__na_p, data, len); \
620-
__na_p; \
613+
#define mgmt_msg_native_append(msg, data, len) \
614+
({ \
615+
uint8_t **_na_darrp = mgmt_msg_native_get_darrp(msg); \
616+
uint8_t *_na_p = darr_append_n(*_na_darrp, len); \
617+
memcpy(_na_p, data, len); \
618+
_na_p; \
621619
})
622620

623621
/**
@@ -633,10 +631,10 @@ extern int vmgmt_msg_native_send_error(struct msg_conn *conn,
633631
* message to fit the new data. Any other pointers into the old message should
634632
* be discarded.
635633
*/
636-
#define mgmt_msg_native_add_str(msg, s) \
637-
do { \
638-
int __nas_len = strlen(s) + 1; \
639-
mgmt_msg_native_append(msg, s, __nas_len); \
634+
#define mgmt_msg_native_add_str(msg, s) \
635+
do { \
636+
int _nas_len = strlen(s) + 1; \
637+
mgmt_msg_native_append(msg, s, _nas_len); \
640638
} while (0)
641639

642640
/**
@@ -706,11 +704,11 @@ extern int vmgmt_msg_native_send_error(struct msg_conn *conn,
706704
* the first half of the encoding, after which one can simply append the
707705
* secondary data to the message.
708706
*/
709-
#define mgmt_msg_native_xpath_encode(msg, xpath) \
710-
do { \
711-
size_t __slen = strlen(xpath) + 1; \
712-
mgmt_msg_native_append(msg, xpath, __slen); \
713-
(msg)->vsplit = __slen; \
707+
#define mgmt_msg_native_xpath_encode(msg, xpath) \
708+
do { \
709+
size_t _m__slen = strlen(xpath) + 1; \
710+
mgmt_msg_native_append(msg, xpath, _m__slen); \
711+
(msg)->vsplit = _m__slen; \
714712
} while (0)
715713

716714
/**
@@ -727,17 +725,17 @@ extern int vmgmt_msg_native_send_error(struct msg_conn *conn,
727725
* The xpath string or NULL if there was an error decoding (i.e., the
728726
* message is corrupt).
729727
*/
730-
#define mgmt_msg_native_xpath_data_decode(msg, msglen, __data) \
728+
#define mgmt_msg_native_xpath_data_decode(msg, msglen, _data) \
731729
({ \
732-
size_t __len = (msglen) - sizeof(*msg); \
733-
const char *__s = NULL; \
734-
(__data) = NULL; \
735-
if (msg->vsplit && msg->vsplit <= __len && msg->data[msg->vsplit - 1] == 0) { \
736-
if (msg->vsplit < __len) \
737-
(__data) = msg->data + msg->vsplit; \
738-
__s = msg->data; \
730+
size_t _m__len = (msglen) - sizeof(*msg); \
731+
const char *_m__s = NULL; \
732+
(_data) = NULL; \
733+
if (msg->vsplit && msg->vsplit <= _m__len && msg->data[msg->vsplit - 1] == 0) { \
734+
if (msg->vsplit < _m__len) \
735+
(_data) = msg->data + msg->vsplit; \
736+
_m__s = msg->data; \
739737
} \
740-
__s; \
738+
_m__s; \
741739
})
742740

743741
/**
@@ -753,14 +751,13 @@ extern int vmgmt_msg_native_send_error(struct msg_conn *conn,
753751
* The xpath string or NULL if there was an error decoding (i.e., the
754752
* message is corrupt).
755753
*/
756-
#define mgmt_msg_native_xpath_decode(msg, msglen) \
757-
({ \
758-
size_t __len = (msglen) - sizeof(*msg); \
759-
const char *__s = msg->data; \
760-
if (!msg->vsplit || msg->vsplit > __len || \
761-
__s[msg->vsplit - 1] != 0) \
762-
__s = NULL; \
763-
__s; \
754+
#define mgmt_msg_native_xpath_decode(msg, msglen) \
755+
({ \
756+
size_t _m__len = (msglen) - sizeof(*msg); \
757+
const char *_m__s = msg->data; \
758+
if (!msg->vsplit || msg->vsplit > _m__len || _m__s[msg->vsplit - 1] != 0) \
759+
_m__s = NULL; \
760+
_m__s; \
764761
})
765762

766763
/**
@@ -776,13 +773,13 @@ extern int vmgmt_msg_native_send_error(struct msg_conn *conn,
776773
* The secondary data or NULL if there was an error decoding (i.e., the
777774
* message is corrupt).
778775
*/
779-
#define mgmt_msg_native_data_decode(msg, msglen) \
780-
({ \
781-
size_t __len = (msglen) - sizeof(*msg); \
782-
const char *__data = msg->data + msg->vsplit; \
783-
if (!msg->vsplit || msg->vsplit > __len || __data[-1] != 0) \
784-
__data = NULL; \
785-
__data; \
776+
#define mgmt_msg_native_data_decode(msg, msglen) \
777+
({ \
778+
size_t _m__len = (msglen) - sizeof(*msg); \
779+
const char *_m__data = msg->data + msg->vsplit; \
780+
if (!msg->vsplit || msg->vsplit > _m__len || _m__data[-1] != 0) \
781+
_m__data = NULL; \
782+
_m__data; \
786783
})
787784

788785
/**

lib/northbound.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,9 @@ struct nb_yang_xpath {
5050
} tags[NB_MAX_NUM_XPATH_TAGS];
5151
};
5252

53-
#define NB_YANG_XPATH_KEY(__xpath, __indx1, __indx2) \
54-
((__xpath->num_tags > __indx1) && \
55-
(__xpath->tags[__indx1].num_keys > __indx2) \
56-
? &__xpath->tags[__indx1].keys[__indx2] \
53+
#define NB_YANG_XPATH_KEY(_xpath, _indx1, _indx2) \
54+
(((_xpath)->num_tags > (_indx1)) && ((_xpath)->tags[(_indx1)].num_keys > (_indx2)) \
55+
? &(_xpath)->tags[(_indx1)].keys[(_indx2)] \
5756
: NULL)
5857

5958
/* Northbound events. */

0 commit comments

Comments
 (0)