11/*
2- * Copyright (C) Huawei Technologies Co., Ltd. 2025. All rights reserved .
2+ * Copyright (C) 2025 Huawei Technologies Co., Ltd.
33 * SPDX-License-Identifier: 0BSD
44 */
55#include <assert.h>
@@ -33,7 +33,7 @@ struct chain {
3333 struct type types [MAX_TYPES ];
3434};
3535
36- static struct chain _chains [MAX_CHAINS ];
36+ static struct chain chains_ [MAX_CHAINS ];
3737
3838// -----------------------------------------------------------------------------
3939// initializer
@@ -46,23 +46,23 @@ ps_initd_(void)
4646 NONE ,
4747 START ,
4848 BLOCK ,
49- } _state = NONE ;
49+ } state_ = NONE ;
5050 static bool ready = false;
5151
5252 if (likely (ready )) {
5353 return true;
5454 }
5555
56- switch (_state ) {
56+ switch (state_ ) {
5757 case NONE :
5858 // This must be the main thread, at latest the thread creation.
59- _state = START ;
59+ state_ = START ;
6060 PS_PUBLISH (CHAIN_CONTROL , EVENT_DICE_INIT , 0 , 0 );
6161 ready = true;
6262 PS_PUBLISH (CHAIN_CONTROL , EVENT_DICE_READY , 0 , 0 );
6363 return true;
6464 case START :
65- _state = BLOCK ;
65+ state_ = BLOCK ;
6666 return true;
6767 case BLOCK :
6868 // The publication above is still running, drop nested publications.
@@ -87,7 +87,7 @@ DICE_MODULE_INIT()
8787// -----------------------------------------------------------------------------
8888
8989static void
90- _ps_subscribe_sorted (struct sub * * cur , chain_id chain , type_id type ,
90+ ps_subscribe_sorted_ (struct sub * * cur , chain_id chain , type_id type ,
9191 ps_callback_f cb , int prio , bool any_type )
9292{
9393 // any_type is set if this subscription was from ANY_TYPE
@@ -101,7 +101,7 @@ _ps_subscribe_sorted(struct sub **cur, chain_id chain, type_id type,
101101 next = * cur ;
102102 goto insert ;
103103 } else {
104- _ps_subscribe_sorted (& (* cur )-> next , chain , type , cb , prio , any_type );
104+ ps_subscribe_sorted_ (& (* cur )-> next , chain , type , cb , prio , any_type );
105105 return ;
106106 }
107107
@@ -117,20 +117,20 @@ _ps_subscribe_sorted(struct sub **cur, chain_id chain, type_id type,
117117}
118118
119119static int
120- _ps_subscribe_type (chain_id chain , type_id type , ps_callback_f cb , int prio ,
120+ ps_subscribe_type_ (chain_id chain , type_id type , ps_callback_f cb , int prio ,
121121 bool any_type )
122122{
123123 (void )prio ;
124124 if (type > MAX_TYPES )
125125 return PS_INVALID ;
126126
127- struct type * ev = & _chains [chain ].types [type ];
127+ struct type * ev = & chains_ [chain ].types [type ];
128128
129129 // increment the idx of next subscription
130130 ev -> count ++ ;
131131
132132 // register subscription
133- _ps_subscribe_sorted (& ev -> head , chain , type , cb , prio , any_type );
133+ ps_subscribe_sorted_ (& ev -> head , chain , type , cb , prio , any_type );
134134
135135 return PS_OK ;
136136}
@@ -150,11 +150,11 @@ ps_subscribe(chain_id chain, type_id type, ps_callback_f cb, int prio)
150150 if (chain > MAX_CHAINS )
151151 return PS_INVALID ;
152152 if (type != ANY_TYPE )
153- return _ps_subscribe_type (chain , type , cb , prio , false);
153+ return ps_subscribe_type_ (chain , type , cb , prio , false);
154154
155155 int err ;
156156 for (size_t i = 1 ; i < MAX_TYPES ; i ++ )
157- if ((err = _ps_subscribe_type (chain , i , cb , prio , true)) != 0 )
157+ if ((err = ps_subscribe_type_ (chain , i , cb , prio , true)) != 0 )
158158 return err ;
159159
160160 return PS_OK ;
@@ -165,15 +165,15 @@ ps_subscribe(chain_id chain, type_id type, ps_callback_f cb, int prio)
165165// -----------------------------------------------------------------------------
166166
167167static enum ps_err
168- _ps_publish (const chain_id chain , const type_id type , void * event ,
168+ ps_publish_ (const chain_id chain , const type_id type , void * event ,
169169 metadata_t * md )
170170{
171171 if (unlikely (chain >= MAX_CHAINS ))
172172 return PS_INVALID ;
173173 if (unlikely (type == ANY_TYPE || type >= MAX_TYPES ))
174174 return PS_INVALID ;
175175
176- struct type * ev = & _chains [chain ].types [type ];
176+ struct type * ev = & chains_ [chain ].types [type ];
177177 struct sub * cur = ev -> head ;
178178 while (cur ) {
179179 // now we call the callback and abort the chain if the subscriber
@@ -215,5 +215,5 @@ ps_publish(const chain_id chain, const type_id type, void *event,
215215 if (likely (err == PS_DROP_EVENT ))
216216 return PS_DROP_EVENT ;
217217
218- return _ps_publish (chain , type , event , md );
218+ return ps_publish_ (chain , type , event , md );
219219}
0 commit comments