Skip to content

Commit 1dbd039

Browse files
authored
Merge pull request contiki-ng#2321 from arurke/const-in-right-place
Correct const placement in remaining lists
2 parents 3fc041a + 371f426 commit 1dbd039

6 files changed

+45
-27
lines changed

os/lib/circular-list.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ circular_list_init(circular_list_t cl)
5656
}
5757
/*---------------------------------------------------------------------------*/
5858
void *
59-
circular_list_head(const circular_list_t cl)
59+
circular_list_head(const_circular_list_t cl)
6060
{
6161
return *cl;
6262
}
6363
/*---------------------------------------------------------------------------*/
6464
void *
65-
circular_list_tail(const circular_list_t cl)
65+
circular_list_tail(const_circular_list_t cl)
6666
{
6767
struct cl *this;
6868

@@ -132,7 +132,7 @@ circular_list_add(circular_list_t cl, void *element)
132132
}
133133
/*---------------------------------------------------------------------------*/
134134
unsigned long
135-
circular_list_length(const circular_list_t cl)
135+
circular_list_length(const_circular_list_t cl)
136136
{
137137
unsigned long len = 1;
138138
struct cl *this;
@@ -149,7 +149,7 @@ circular_list_length(const circular_list_t cl)
149149
}
150150
/*---------------------------------------------------------------------------*/
151151
bool
152-
circular_list_is_empty(const circular_list_t cl)
152+
circular_list_is_empty(const_circular_list_t cl)
153153
{
154154
return *cl == NULL ? true : false;
155155
}

os/lib/circular-list.h

+11-5
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,15 @@
7979
static circular_list_t name = (circular_list_t)&name##_circular_list
8080
/*---------------------------------------------------------------------------*/
8181
/**
82-
* \brief The circular, singly-linked list datatype
82+
* The circular, singly-linked list datatype.
8383
*/
8484
typedef void **circular_list_t;
85+
86+
/**
87+
* The non-modifiable circular, singly-linked list datatype.
88+
*/
89+
typedef void *const *const_circular_list_t;
90+
8591
/*---------------------------------------------------------------------------*/
8692
/**
8793
* \brief Initialise a circular, singly-linked list.
@@ -94,14 +100,14 @@ void circular_list_init(circular_list_t cl);
94100
* \param cl The circular, singly-linked list.
95101
* \return A pointer to the list's head, or NULL if the list is empty
96102
*/
97-
void *circular_list_head(const circular_list_t cl);
103+
void *circular_list_head(const_circular_list_t cl);
98104

99105
/**
100106
* \brief Return the tail of a circular, singly-linked list.
101107
* \param cl The circular, singly-linked list.
102108
* \return A pointer to the list's tail, or NULL if the list is empty
103109
*/
104-
void *circular_list_tail(const circular_list_t cl);
110+
void *circular_list_tail(const_circular_list_t cl);
105111

106112
/**
107113
* \brief Add an element to a circular, singly-linked list.
@@ -139,15 +145,15 @@ void circular_list_remove(circular_list_t cl, const void *element);
139145
* \param cl The circular, singly-linked list.
140146
* \return The number of elements in the list
141147
*/
142-
unsigned long circular_list_length(const circular_list_t cl);
148+
unsigned long circular_list_length(const_circular_list_t cl);
143149

144150
/**
145151
* \brief Determine whether a circular, singly-linked list is empty.
146152
* \param cl The circular, singly-linked list.
147153
* \retval true The list is empty
148154
* \retval false The list is not empty
149155
*/
150-
bool circular_list_is_empty(const circular_list_t cl);
156+
bool circular_list_is_empty(const_circular_list_t cl);
151157
/*---------------------------------------------------------------------------*/
152158
#endif /* CIRCULAR_LIST_H_ */
153159
/*---------------------------------------------------------------------------*/

os/lib/dbl-circ-list.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ dbl_circ_list_init(dbl_circ_list_t dblcl)
5757
}
5858
/*---------------------------------------------------------------------------*/
5959
void *
60-
dbl_circ_list_head(const dbl_circ_list_t dblcl)
60+
dbl_circ_list_head(const_dbl_circ_list_t dblcl)
6161
{
6262
return *dblcl;
6363
}
6464
/*---------------------------------------------------------------------------*/
6565
void *
66-
dbl_circ_list_tail(const dbl_circ_list_t dblcl)
66+
dbl_circ_list_tail(const_dbl_circ_list_t dblcl)
6767
{
6868
struct dblcl *this;
6969

@@ -202,7 +202,7 @@ dbl_circ_list_add_before(dbl_circ_list_t dblcl, void *existing, void *element)
202202
}
203203
/*---------------------------------------------------------------------------*/
204204
unsigned long
205-
dbl_circ_list_length(const dbl_circ_list_t dblcl)
205+
dbl_circ_list_length(const_dbl_circ_list_t dblcl)
206206
{
207207
unsigned long len = 1;
208208
struct dblcl *this;
@@ -219,7 +219,7 @@ dbl_circ_list_length(const dbl_circ_list_t dblcl)
219219
}
220220
/*---------------------------------------------------------------------------*/
221221
bool
222-
dbl_circ_list_is_empty(const dbl_circ_list_t dblcl)
222+
dbl_circ_list_is_empty(const_dbl_circ_list_t dblcl)
223223
{
224224
return *dblcl == NULL ? true : false;
225225
}

os/lib/dbl-circ-list.h

+11-5
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,15 @@
8181
static dbl_list_t name = (dbl_circ_list_t)&name##_dbl_circ_list
8282
/*---------------------------------------------------------------------------*/
8383
/**
84-
* \brief The doubly-linked list datatype
84+
* The doubly-linked circular list datatype
8585
*/
8686
typedef void **dbl_circ_list_t;
87+
88+
/**
89+
* The non-modifiable doubly-linked circular list type.
90+
*/
91+
typedef void *const *const_dbl_circ_list_t;
92+
8793
/*---------------------------------------------------------------------------*/
8894
/**
8995
* \brief Initialise a circular, doubly-linked list.
@@ -96,14 +102,14 @@ void dbl_circ_list_init(dbl_circ_list_t dblcl);
96102
* \param dblcl The circular, doubly-linked list.
97103
* \return A pointer to the list's head, or NULL if the list is empty
98104
*/
99-
void *dbl_circ_list_head(const dbl_circ_list_t dblcl);
105+
void *dbl_circ_list_head(const_dbl_circ_list_t dblcl);
100106

101107
/**
102108
* \brief Return the tail of a circular, doubly-linked list.
103109
* \param dblcl The circular, doubly-linked list.
104110
* \return A pointer to the list's tail, or NULL if the list is empty
105111
*/
106-
void *dbl_circ_list_tail(const dbl_circ_list_t dblcl);
112+
void *dbl_circ_list_tail(const_dbl_circ_list_t dblcl);
107113

108114
/**
109115
* \brief Add an element to the head of a circular, doubly-linked list.
@@ -177,15 +183,15 @@ void dbl_circ_list_remove(dbl_circ_list_t dblcl, const void *element);
177183
* \param dblcl The circular, doubly-linked list.
178184
* \return The number of elements in the list
179185
*/
180-
unsigned long dbl_circ_list_length(const dbl_circ_list_t dblcl);
186+
unsigned long dbl_circ_list_length(const_dbl_circ_list_t dblcl);
181187

182188
/**
183189
* \brief Determine whether a circular, doubly-linked list is empty.
184190
* \param dblcl The circular, doubly-linked list.
185191
* \retval true The list is empty
186192
* \retval false The list is not empty
187193
*/
188-
bool dbl_circ_list_is_empty(const dbl_circ_list_t dblcl);
194+
bool dbl_circ_list_is_empty(const_dbl_circ_list_t dblcl);
189195
/*---------------------------------------------------------------------------*/
190196
#endif /* DBL_CIRC_LIST_H_ */
191197
/*---------------------------------------------------------------------------*/

os/lib/dbl-list.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ dbl_list_init(dbl_list_t dll)
5757
}
5858
/*---------------------------------------------------------------------------*/
5959
void *
60-
dbl_list_head(const dbl_list_t dll)
60+
dbl_list_head(const_dbl_list_t dll)
6161
{
6262
return *dll;
6363
}
6464
/*---------------------------------------------------------------------------*/
6565
void *
66-
dbl_list_tail(const dbl_list_t dll)
66+
dbl_list_tail(const_dbl_list_t dll)
6767
{
6868
struct dll *this;
6969

@@ -201,7 +201,7 @@ dbl_list_add_before(dbl_list_t dll, void *existing, void *element)
201201
}
202202
/*---------------------------------------------------------------------------*/
203203
unsigned long
204-
dbl_list_length(const dbl_list_t dll)
204+
dbl_list_length(const_dbl_list_t dll)
205205
{
206206
unsigned long len = 0;
207207
struct dll *this;
@@ -218,7 +218,7 @@ dbl_list_length(const dbl_list_t dll)
218218
}
219219
/*---------------------------------------------------------------------------*/
220220
bool
221-
dbl_list_is_empty(const dbl_list_t dll)
221+
dbl_list_is_empty(const_dbl_list_t dll)
222222
{
223223
return *dll == NULL ? true : false;
224224
}

os/lib/dbl-list.h

+11-5
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,15 @@
8181
static dbl_list_t name = (dbl_list_t)&name##_dbl_list
8282
/*---------------------------------------------------------------------------*/
8383
/**
84-
* \brief The doubly-linked list datatype
84+
* The doubly-linked list datatype.
8585
*/
8686
typedef void **dbl_list_t;
87+
88+
/**
89+
* The non-modifiable doubly-linked list type.
90+
*/
91+
typedef void *const *const_dbl_list_t;
92+
8793
/*---------------------------------------------------------------------------*/
8894
/**
8995
* \brief Initialise a doubly-linked list.
@@ -96,14 +102,14 @@ void dbl_list_init(dbl_list_t dll);
96102
* \param dll The doubly-linked list.
97103
* \return A pointer to the list's head, or NULL if the list is empty
98104
*/
99-
void *dbl_list_head(const dbl_list_t dll);
105+
void *dbl_list_head(const_dbl_list_t dll);
100106

101107
/**
102108
* \brief Return the tail of a doubly-linked list.
103109
* \param dll The doubly-linked list.
104110
* \return A pointer to the list's tail, or NULL if the list is empty
105111
*/
106-
void *dbl_list_tail(const dbl_list_t dll);
112+
void *dbl_list_tail(const_dbl_list_t dll);
107113

108114
/**
109115
* \brief Add an element to the head of a doubly-linked list.
@@ -175,15 +181,15 @@ void dbl_list_remove(dbl_list_t dll, const void *element);
175181
* \param dll The doubly-linked list.
176182
* \return The number of elements in the list
177183
*/
178-
unsigned long dbl_list_length(const dbl_list_t dll);
184+
unsigned long dbl_list_length(const_dbl_list_t dll);
179185

180186
/**
181187
* \brief Determine whether a doubly-linked list is empty.
182188
* \param dll The doubly-linked list.
183189
* \retval true The list is empty
184190
* \retval false The list is not empty
185191
*/
186-
bool dbl_list_is_empty(const dbl_list_t dll);
192+
bool dbl_list_is_empty(const_dbl_list_t dll);
187193
/*---------------------------------------------------------------------------*/
188194
#endif /* DBL_LIST_H_ */
189195
/*---------------------------------------------------------------------------*/

0 commit comments

Comments
 (0)