@@ -156,21 +156,21 @@ static void decoder_free(struct srd_decoder *dec)
156156 if (!dec )
157157 return ;
158158
159- Py_XDECREF (dec -> py_dec );
160- Py_XDECREF (dec -> py_mod );
161-
162- g_slist_free_full (dec -> options , & decoder_option_free );
163- g_slist_free_full (dec -> binary , (GDestroyNotify )& g_strfreev );
164- g_slist_free_full (dec -> annotation_rows , & annotation_row_free );
165- g_slist_free_full (dec -> annotations , (GDestroyNotify )& g_strfreev );
166- g_slist_free_full (dec -> opt_channels , & channel_free );
167- g_slist_free_full (dec -> channels , & channel_free );
168-
169- g_free (dec -> license );
170- g_free (dec -> desc );
171- g_free (dec -> longname );
172- g_free (dec -> name );
173- g_free (dec -> id );
159+ Py_XDECREF (dec -> py_dec );
160+ Py_XDECREF (dec -> py_mod );
161+
162+ g_slist_free_full (dec -> options , & decoder_option_free );
163+ g_slist_free_full (dec -> binary , (GDestroyNotify )& g_strfreev );
164+ g_slist_free_full (dec -> annotation_rows , & annotation_row_free );
165+ g_slist_free_full (dec -> annotations , (GDestroyNotify )& g_strfreev );
166+ g_slist_free_full (dec -> opt_channels , & channel_free );
167+ g_slist_free_full (dec -> channels , & channel_free );
168+
169+ g_free (dec -> license );
170+ g_free (dec -> desc );
171+ g_free (dec -> longname );
172+ g_free (dec -> name );
173+ g_free (dec -> id );
174174
175175 g_free (dec );
176176}
@@ -215,14 +215,14 @@ static int get_channels(const struct srd_decoder *d, const char *attr,
215215
216216 if (py_dictitem_as_str (py_entry , "id" , & pdch -> id ) != SRD_OK )
217217 goto err_out ;
218- if (py_dictitem_as_str (py_entry , "name" , & pdch -> name ) != SRD_OK )
218+ if (py_dictitem_as_str (py_entry , "name" , & pdch -> name ) != SRD_OK )
219219 goto err_out ;
220220 if (py_dictitem_as_str (py_entry , "desc" , & pdch -> desc ) != SRD_OK )
221221 goto err_out ;
222222
223- pdch -> type = py_dictitem_to_int (py_entry , "type" );
224- if (pdch -> type < 0 )
225- pdch -> type = SRD_CHANNEL_COMMON ;
223+ pdch -> type = py_dictitem_to_int (py_entry , "type" );
224+ if (pdch -> type < 0 )
225+ pdch -> type = SRD_CHANNEL_COMMON ;
226226 pdch -> order = offset + i ;
227227 }
228228
@@ -232,7 +232,7 @@ static int get_channels(const struct srd_decoder *d, const char *attr,
232232 return SRD_OK ;
233233
234234except_out :
235- srd_exception_catch (NULL , "Failed to get %s list of %s decoder" ,
235+ srd_exception_catch (NULL , "Failed to get %s list of %s decoder" ,
236236 attr , d -> name );
237237err_out :
238238 g_slist_free_full (pdchl , & channel_free );
@@ -348,7 +348,7 @@ static int get_options(struct srd_decoder *d)
348348 return SRD_OK ;
349349
350350except_out :
351- srd_exception_catch (NULL , "Failed to get %s decoder options" , d -> name );
351+ srd_exception_catch (NULL , "Failed to get %s decoder options" , d -> name );
352352err_out :
353353 g_slist_free_full (options , & decoder_option_free );
354354 Py_XDECREF (py_opts );
@@ -364,8 +364,8 @@ static int get_annotations(struct srd_decoder *dec)
364364 GSList * annotations ;
365365 char * * annpair ;
366366 ssize_t i ;
367- int ann_type = 7 ;
368- unsigned int j ;
367+ int ann_type = 7 ;
368+ unsigned int j ;
369369
370370 if (!PyObject_HasAttrString (dec -> py_dec , "annotations" ))
371371 return SRD_OK ;
@@ -382,15 +382,15 @@ static int get_annotations(struct srd_decoder *dec)
382382 goto err_out ;
383383 }
384384
385- for (i = 0 ; i < PyTuple_Size (py_annlist ); i ++ ) {
385+ for (i = 0 ; i < PyTuple_Size (py_annlist ); i ++ ) {
386386 py_ann = PyTuple_GetItem (py_annlist , i );
387387 if (!py_ann )
388388 goto except_out ;
389389
390390 if (!PyTuple_Check (py_ann ) || (PyTuple_Size (py_ann ) != 3 && PyTuple_Size (py_ann ) != 2 )) {
391391 srd_err ("Protocol decoder %s annotation %zd should "
392392 "be a tuple with two or three elements." ,
393- dec -> name , i );
393+ dec -> name , i + 1 );
394394 goto err_out ;
395395 }
396396 if (py_strseq_to_char (py_ann , & annpair ) != SRD_OK )
@@ -399,22 +399,22 @@ static int get_annotations(struct srd_decoder *dec)
399399 annotations = g_slist_prepend (annotations , annpair );
400400
401401 if (PyTuple_Size (py_ann ) == 3 ) {
402- ann_type = 0 ;
403- for (j = 0 ; j < strlen (annpair [0 ]); j ++ )
404- ann_type = ann_type * 10 + (annpair [0 ][j ] - '0' );
405- dec -> ann_types = g_slist_append (dec -> ann_types , GINT_TO_POINTER (ann_type ));
406- } else if (PyTuple_Size (py_ann ) == 2 ) {
407- dec -> ann_types = g_slist_append (dec -> ann_types , GINT_TO_POINTER (ann_type ));
408- ann_type ++ ;
409- }
402+ ann_type = 0 ;
403+ for (j = 0 ; j < strlen (annpair [0 ]); j ++ )
404+ ann_type = ann_type * 10 + (annpair [0 ][j ] - '0' );
405+ dec -> ann_types = g_slist_append (dec -> ann_types , GINT_TO_POINTER (ann_type ));
406+ } else if (PyTuple_Size (py_ann ) == 2 ) {
407+ dec -> ann_types = g_slist_append (dec -> ann_types , GINT_TO_POINTER (ann_type ));
408+ ann_type ++ ;
409+ }
410410 }
411411 dec -> annotations = annotations ;
412412 Py_DECREF (py_annlist );
413413
414414 return SRD_OK ;
415415
416416except_out :
417- srd_exception_catch (NULL , "Failed to get %s decoder annotations" , dec -> name );
417+ srd_exception_catch (NULL , "Failed to get %s decoder annotations" , dec -> name );
418418err_out :
419419 g_slist_free_full (annotations , (GDestroyNotify )& g_strfreev );
420420 Py_XDECREF (py_annlist );
@@ -510,7 +510,7 @@ static int get_annotation_rows(struct srd_decoder *dec)
510510 return SRD_OK ;
511511
512512except_out :
513- srd_exception_catch (NULL , "Failed to get %s decoder annotation rows" ,
513+ srd_exception_catch (NULL , "Failed to get %s decoder annotation rows" ,
514514 dec -> name );
515515err_out :
516516 g_slist_free_full (annotation_rows , & annotation_row_free );
@@ -566,7 +566,7 @@ static int get_binary_classes(struct srd_decoder *dec)
566566 return SRD_OK ;
567567
568568except_out :
569- srd_exception_catch (NULL , "Failed to get %s decoder binary classes" ,
569+ srd_exception_catch (NULL , "Failed to get %s decoder binary classes" ,
570570 dec -> name );
571571err_out :
572572 g_slist_free_full (bin_classes , (GDestroyNotify )& g_strfreev );
@@ -585,8 +585,8 @@ static int check_method(PyObject *py_dec, const char *mod_name,
585585
586586 py_method = PyObject_GetAttrString (py_dec , method_name );
587587 if (!py_method ) {
588- srd_exception_catch (NULL , "Protocol decoder %s Decoder class "
589- "has no %s() method" , mod_name , method_name );
588+ srd_exception_catch (NULL , "Protocol decoder %s Decoder class "
589+ "has no %s() method" , mod_name , method_name );
590590 return SRD_ERR_PYTHON ;
591591 }
592592
@@ -636,12 +636,12 @@ SRD_PRIV long srd_decoder_apiver(const struct srd_decoder *d)
636636 */
637637SRD_API int srd_decoder_load (const char * module_name )
638638{
639- PyObject * py_basedec ;
639+ PyObject * py_basedec ;
640640 struct srd_decoder * d ;
641641 long apiver ;
642642 int is_subclass ;
643643 const char * fail_txt ;
644-
644+
645645 if (!srd_check_init ())
646646 return SRD_ERR ;
647647
@@ -699,8 +699,8 @@ SRD_API int srd_decoder_load(const char *module_name)
699699 */
700700 apiver = srd_decoder_apiver (d );
701701 if (apiver != 2 ) {
702- srd_exception_catch (NULL , "Only PD API version 2 is supported, "
703- "decoder %s has version %ld" , module_name , apiver );
702+ srd_exception_catch (NULL , "Only PD API version 2 is supported, "
703+ "decoder %s has version %ld" , module_name , apiver );
704704 fail_txt = "API version mismatch" ;
705705 goto err_out ;
706706 }
@@ -776,19 +776,19 @@ SRD_API int srd_decoder_load(const char *module_name)
776776 fail_txt = "cannot get binary classes" ;
777777 goto err_out ;
778778 }
779-
779+
780780 /* Append it to the list of loaded decoders. */
781781 pd_list = g_slist_append (pd_list , d );
782782
783783 return SRD_OK ;
784784
785785except_out :
786786 if (fail_txt ) {
787- srd_exception_catch (NULL , "Failed to load decoder %s: %s" ,
787+ srd_exception_catch (NULL , "Failed to load decoder %s: %s" ,
788788 module_name , fail_txt );
789789 fail_txt = NULL ;
790790 } else {
791- srd_exception_catch (NULL , "Failed to load decoder %s" , module_name );
791+ srd_exception_catch (NULL , "Failed to load decoder %s" , module_name );
792792 }
793793err_out :
794794 if (fail_txt )
@@ -823,7 +823,7 @@ SRD_API char *srd_decoder_doc_get(const struct srd_decoder *dec)
823823 return NULL ;
824824
825825 if (!(py_str = PyObject_GetAttrString (dec -> py_mod , "__doc__" ))) {
826- srd_exception_catch (NULL , "Failed to get docstring" );
826+ srd_exception_catch (NULL , "Failed to get docstring" );
827827 return NULL ;
828828 }
829829
0 commit comments