@@ -30,9 +30,9 @@ struct dcp_parse_tag {
3030 bool last : 1 ;
3131} __packed ;
3232
33- static void * parse_bytes (struct dcp_parse_ctx * ctx , size_t count )
33+ static const void * parse_bytes (struct dcp_parse_ctx * ctx , size_t count )
3434{
35- void * ptr = ctx -> blob + ctx -> pos ;
35+ const void * ptr = ctx -> blob + ctx -> pos ;
3636
3737 if (ctx -> pos + count > ctx -> len )
3838 return ERR_PTR (- EINVAL );
@@ -41,14 +41,14 @@ static void *parse_bytes(struct dcp_parse_ctx *ctx, size_t count)
4141 return ptr ;
4242}
4343
44- static u32 * parse_u32 (struct dcp_parse_ctx * ctx )
44+ static const u32 * parse_u32 (struct dcp_parse_ctx * ctx )
4545{
4646 return parse_bytes (ctx , sizeof (u32 ));
4747}
4848
49- static struct dcp_parse_tag * parse_tag (struct dcp_parse_ctx * ctx )
49+ static const struct dcp_parse_tag * parse_tag (struct dcp_parse_ctx * ctx )
5050{
51- struct dcp_parse_tag * tag ;
51+ const struct dcp_parse_tag * tag ;
5252
5353 /* Align to 32-bits */
5454 ctx -> pos = round_up (ctx -> pos , 4 );
@@ -64,10 +64,10 @@ static struct dcp_parse_tag *parse_tag(struct dcp_parse_ctx *ctx)
6464 return tag ;
6565}
6666
67- static struct dcp_parse_tag * parse_tag_of_type (struct dcp_parse_ctx * ctx ,
67+ static const struct dcp_parse_tag * parse_tag_of_type (struct dcp_parse_ctx * ctx ,
6868 enum dcp_parse_type type )
6969{
70- struct dcp_parse_tag * tag = parse_tag (ctx );
70+ const struct dcp_parse_tag * tag = parse_tag (ctx );
7171
7272 if (IS_ERR (tag ))
7373 return tag ;
@@ -80,7 +80,7 @@ static struct dcp_parse_tag *parse_tag_of_type(struct dcp_parse_ctx *ctx,
8080
8181static int skip (struct dcp_parse_ctx * handle )
8282{
83- struct dcp_parse_tag * tag = parse_tag (handle );
83+ const struct dcp_parse_tag * tag = parse_tag (handle );
8484 int ret = 0 ;
8585 int i ;
8686
@@ -132,7 +132,7 @@ static int skip_pair(struct dcp_parse_ctx *handle)
132132
133133static bool consume_string (struct dcp_parse_ctx * ctx , const char * specimen )
134134{
135- struct dcp_parse_tag * tag ;
135+ const struct dcp_parse_tag * tag ;
136136 const char * key ;
137137 ctx -> pos = round_up (ctx -> pos , 4 );
138138
@@ -155,7 +155,7 @@ static bool consume_string(struct dcp_parse_ctx *ctx, const char *specimen)
155155/* Caller must free the result */
156156static char * parse_string (struct dcp_parse_ctx * handle )
157157{
158- struct dcp_parse_tag * tag = parse_tag_of_type (handle , DCP_TYPE_STRING );
158+ const struct dcp_parse_tag * tag = parse_tag_of_type (handle , DCP_TYPE_STRING );
159159 const char * in ;
160160 char * out ;
161161
@@ -175,8 +175,8 @@ static char *parse_string(struct dcp_parse_ctx *handle)
175175
176176static int parse_int (struct dcp_parse_ctx * handle , s64 * value )
177177{
178- void * tag = parse_tag_of_type (handle , DCP_TYPE_INT64 );
179- s64 * in ;
178+ const void * tag = parse_tag_of_type (handle , DCP_TYPE_INT64 );
179+ const s64 * in ;
180180
181181 if (IS_ERR (tag ))
182182 return PTR_ERR (tag );
@@ -192,7 +192,7 @@ static int parse_int(struct dcp_parse_ctx *handle, s64 *value)
192192
193193static int parse_bool (struct dcp_parse_ctx * handle , bool * b )
194194{
195- struct dcp_parse_tag * tag = parse_tag_of_type (handle , DCP_TYPE_BOOL );
195+ const struct dcp_parse_tag * tag = parse_tag_of_type (handle , DCP_TYPE_BOOL );
196196
197197 if (IS_ERR (tag ))
198198 return PTR_ERR (tag );
@@ -201,10 +201,10 @@ static int parse_bool(struct dcp_parse_ctx *handle, bool *b)
201201 return 0 ;
202202}
203203
204- static int parse_blob (struct dcp_parse_ctx * handle , size_t size , u8 * * blob )
204+ static int parse_blob (struct dcp_parse_ctx * handle , size_t size , u8 const * * blob )
205205{
206- struct dcp_parse_tag * tag = parse_tag_of_type (handle , DCP_TYPE_BLOB );
207- u8 * out ;
206+ const struct dcp_parse_tag * tag = parse_tag_of_type (handle , DCP_TYPE_BLOB );
207+ const u8 * out ;
208208
209209 if (IS_ERR (tag ))
210210 return PTR_ERR (tag );
@@ -229,7 +229,7 @@ struct iterator {
229229static int iterator_begin (struct dcp_parse_ctx * handle , struct iterator * it ,
230230 bool dict )
231231{
232- struct dcp_parse_tag * tag ;
232+ const struct dcp_parse_tag * tag ;
233233 enum dcp_parse_type type = dict ? DCP_TYPE_DICTIONARY : DCP_TYPE_ARRAY ;
234234
235235 * it = (struct iterator ) {
@@ -250,9 +250,9 @@ static int iterator_begin(struct dcp_parse_ctx *handle, struct iterator *it,
250250#define dcp_parse_foreach_in_dict (handle , it ) \
251251 for (iterator_begin(handle, &it, true); it.idx < it.len; ++it.idx)
252252
253- int parse (void * blob , size_t size , struct dcp_parse_ctx * ctx )
253+ int parse (const void * blob , size_t size , struct dcp_parse_ctx * ctx )
254254{
255- u32 * header ;
255+ const u32 * header ;
256256
257257 * ctx = (struct dcp_parse_ctx ) {
258258 .blob = blob ,
@@ -926,7 +926,7 @@ static int parse_mode_in_avep_element(struct dcp_parse_ctx *handle,
926926 return ret ;
927927 }
928928 } else if (consume_string (it .handle , "ElementData" )) {
929- u8 * blob ;
929+ const u8 * blob ;
930930
931931 ret = parse_blob (it .handle , sizeof (* cookie ), & blob );
932932 if (ret )
0 commit comments