@@ -43,20 +43,22 @@ void nghttp2_frame_pack_frame_hd(uint8_t *buf, const nghttp2_frame_hd *hd) {
4343}
4444
4545void nghttp2_frame_unpack_frame_hd (nghttp2_frame_hd * hd , const uint8_t * buf ) {
46- hd -> length = nghttp2_get_uint32 (& buf [0 ]) >> 8 ;
47- hd -> type = buf [3 ];
48- hd -> flags = buf [4 ];
49- hd -> stream_id = nghttp2_get_uint32 (& buf [5 ]) & NGHTTP2_STREAM_ID_MASK ;
50- hd -> reserved = 0 ;
46+ * hd = (nghttp2_frame_hd ){
47+ .length = nghttp2_get_uint32 (& buf [0 ]) >> 8 ,
48+ .stream_id = nghttp2_get_uint32 (& buf [5 ]) & NGHTTP2_STREAM_ID_MASK ,
49+ .type = buf [3 ],
50+ .flags = buf [4 ],
51+ };
5152}
5253
5354void nghttp2_frame_hd_init (nghttp2_frame_hd * hd , size_t length , uint8_t type ,
5455 uint8_t flags , int32_t stream_id ) {
55- hd -> length = length ;
56- hd -> type = type ;
57- hd -> flags = flags ;
58- hd -> stream_id = stream_id ;
59- hd -> reserved = 0 ;
56+ * hd = (nghttp2_frame_hd ){
57+ .length = length ,
58+ .stream_id = stream_id ,
59+ .type = type ,
60+ .flags = flags ,
61+ };
6062}
6163
6264void nghttp2_frame_headers_init (nghttp2_headers * frame , uint8_t flags ,
@@ -199,16 +201,15 @@ void nghttp2_frame_extension_free(nghttp2_extension *frame) { (void)frame; }
199201void nghttp2_frame_altsvc_init (nghttp2_extension * frame , int32_t stream_id ,
200202 uint8_t * origin , size_t origin_len ,
201203 uint8_t * field_value , size_t field_value_len ) {
202- nghttp2_ext_altsvc * altsvc ;
203-
204204 nghttp2_frame_hd_init (& frame -> hd , 2 + origin_len + field_value_len ,
205205 NGHTTP2_ALTSVC , NGHTTP2_FLAG_NONE , stream_id );
206206
207- altsvc = frame -> payload ;
208- altsvc -> origin = origin ;
209- altsvc -> origin_len = origin_len ;
210- altsvc -> field_value = field_value ;
211- altsvc -> field_value_len = field_value_len ;
207+ * (nghttp2_ext_altsvc * )frame -> payload = (nghttp2_ext_altsvc ){
208+ .origin = origin ,
209+ .origin_len = origin_len ,
210+ .field_value = field_value ,
211+ .field_value_len = field_value_len ,
212+ };
212213}
213214
214215void nghttp2_frame_altsvc_free (nghttp2_extension * frame , nghttp2_mem * mem ) {
@@ -225,7 +226,6 @@ void nghttp2_frame_altsvc_free(nghttp2_extension *frame, nghttp2_mem *mem) {
225226
226227void nghttp2_frame_origin_init (nghttp2_extension * frame ,
227228 nghttp2_origin_entry * ov , size_t nov ) {
228- nghttp2_ext_origin * origin ;
229229 size_t payloadlen = 0 ;
230230 size_t i ;
231231
@@ -236,9 +236,10 @@ void nghttp2_frame_origin_init(nghttp2_extension *frame,
236236 nghttp2_frame_hd_init (& frame -> hd , payloadlen , NGHTTP2_ORIGIN ,
237237 NGHTTP2_FLAG_NONE , 0 );
238238
239- origin = frame -> payload ;
240- origin -> ov = ov ;
241- origin -> nov = nov ;
239+ * (nghttp2_ext_origin * )frame -> payload = (nghttp2_ext_origin ){
240+ .ov = ov ,
241+ .nov = nov ,
242+ };
242243}
243244
244245void nghttp2_frame_origin_free (nghttp2_extension * frame , nghttp2_mem * mem ) {
@@ -256,15 +257,15 @@ void nghttp2_frame_origin_free(nghttp2_extension *frame, nghttp2_mem *mem) {
256257void nghttp2_frame_priority_update_init (nghttp2_extension * frame ,
257258 int32_t stream_id , uint8_t * field_value ,
258259 size_t field_value_len ) {
259- nghttp2_ext_priority_update * priority_update ;
260-
261260 nghttp2_frame_hd_init (& frame -> hd , 4 + field_value_len ,
262261 NGHTTP2_PRIORITY_UPDATE , NGHTTP2_FLAG_NONE , 0 );
263262
264- priority_update = frame -> payload ;
265- priority_update -> stream_id = stream_id ;
266- priority_update -> field_value = field_value ;
267- priority_update -> field_value_len = field_value_len ;
263+ * (nghttp2_ext_priority_update * )frame -> payload =
264+ (nghttp2_ext_priority_update ){
265+ .stream_id = stream_id ,
266+ .field_value = field_value ,
267+ .field_value_len = field_value_len ,
268+ };
268269}
269270
270271void nghttp2_frame_priority_update_free (nghttp2_extension * frame ,
@@ -517,8 +518,10 @@ void nghttp2_frame_unpack_settings_payload(nghttp2_settings *frame,
517518
518519void nghttp2_frame_unpack_settings_entry (nghttp2_settings_entry * iv ,
519520 const uint8_t * payload ) {
520- iv -> settings_id = nghttp2_get_uint16 (& payload [0 ]);
521- iv -> value = nghttp2_get_uint32 (& payload [2 ]);
521+ * iv = (nghttp2_settings_entry ){
522+ .settings_id = nghttp2_get_uint16 (& payload [0 ]),
523+ .value = nghttp2_get_uint32 (& payload [2 ]),
524+ };
522525}
523526
524527int nghttp2_frame_unpack_settings_payload2 (nghttp2_settings_entry * * iv_ptr ,
@@ -752,10 +755,7 @@ void nghttp2_frame_unpack_altsvc_payload(nghttp2_extension *frame,
752755 altsvc = frame -> payload ;
753756
754757 if (payloadlen == 0 ) {
755- altsvc -> origin = NULL ;
756- altsvc -> origin_len = 0 ;
757- altsvc -> field_value = NULL ;
758- altsvc -> field_value_len = 0 ;
758+ * altsvc = (nghttp2_ext_altsvc ){0 };
759759
760760 return ;
761761 }
@@ -862,8 +862,7 @@ int nghttp2_frame_unpack_origin_payload(nghttp2_extension *frame,
862862 }
863863
864864 if (nov == 0 ) {
865- origin -> ov = NULL ;
866- origin -> nov = 0 ;
865+ * origin = (nghttp2_ext_origin ){0 };
867866
868867 return 0 ;
869868 }
@@ -875,8 +874,10 @@ int nghttp2_frame_unpack_origin_payload(nghttp2_extension *frame,
875874 return NGHTTP2_ERR_NOMEM ;
876875 }
877876
878- origin -> ov = ov ;
879- origin -> nov = nov ;
877+ * origin = (nghttp2_ext_origin ){
878+ .nov = nov ,
879+ .ov = ov ,
880+ };
880881
881882 dst = (uint8_t * )ov + nov * sizeof (nghttp2_origin_entry );
882883 p = payload ;
@@ -887,8 +888,10 @@ int nghttp2_frame_unpack_origin_payload(nghttp2_extension *frame,
887888 if (originlen == 0 ) {
888889 continue ;
889890 }
890- ov -> origin = dst ;
891- ov -> origin_len = originlen ;
891+ * ov = (nghttp2_origin_entry ){
892+ .origin = dst ,
893+ .origin_len = originlen ,
894+ };
892895 dst = nghttp2_cpymem (dst , p , originlen );
893896 * dst ++ = '\0' ;
894897 p += originlen ;
0 commit comments