@@ -156,21 +156,21 @@ static void decoder_free(struct srd_decoder *dec)
156
156
if (!dec )
157
157
return ;
158
158
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 );
174
174
175
175
g_free (dec );
176
176
}
@@ -215,14 +215,14 @@ static int get_channels(const struct srd_decoder *d, const char *attr,
215
215
216
216
if (py_dictitem_as_str (py_entry , "id" , & pdch -> id ) != SRD_OK )
217
217
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 )
219
219
goto err_out ;
220
220
if (py_dictitem_as_str (py_entry , "desc" , & pdch -> desc ) != SRD_OK )
221
221
goto err_out ;
222
222
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 ;
226
226
pdch -> order = offset + i ;
227
227
}
228
228
@@ -232,7 +232,7 @@ static int get_channels(const struct srd_decoder *d, const char *attr,
232
232
return SRD_OK ;
233
233
234
234
except_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" ,
236
236
attr , d -> name );
237
237
err_out :
238
238
g_slist_free_full (pdchl , & channel_free );
@@ -348,7 +348,7 @@ static int get_options(struct srd_decoder *d)
348
348
return SRD_OK ;
349
349
350
350
except_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 );
352
352
err_out :
353
353
g_slist_free_full (options , & decoder_option_free );
354
354
Py_XDECREF (py_opts );
@@ -364,8 +364,8 @@ static int get_annotations(struct srd_decoder *dec)
364
364
GSList * annotations ;
365
365
char * * annpair ;
366
366
ssize_t i ;
367
- int ann_type = 7 ;
368
- unsigned int j ;
367
+ int ann_type = 7 ;
368
+ unsigned int j ;
369
369
370
370
if (!PyObject_HasAttrString (dec -> py_dec , "annotations" ))
371
371
return SRD_OK ;
@@ -382,15 +382,15 @@ static int get_annotations(struct srd_decoder *dec)
382
382
goto err_out ;
383
383
}
384
384
385
- for (i = 0 ; i < PyTuple_Size (py_annlist ); i ++ ) {
385
+ for (i = 0 ; i < PyTuple_Size (py_annlist ); i ++ ) {
386
386
py_ann = PyTuple_GetItem (py_annlist , i );
387
387
if (!py_ann )
388
388
goto except_out ;
389
389
390
390
if (!PyTuple_Check (py_ann ) || (PyTuple_Size (py_ann ) != 3 && PyTuple_Size (py_ann ) != 2 )) {
391
391
srd_err ("Protocol decoder %s annotation %zd should "
392
392
"be a tuple with two or three elements." ,
393
- dec -> name , i );
393
+ dec -> name , i + 1 );
394
394
goto err_out ;
395
395
}
396
396
if (py_strseq_to_char (py_ann , & annpair ) != SRD_OK )
@@ -399,22 +399,22 @@ static int get_annotations(struct srd_decoder *dec)
399
399
annotations = g_slist_prepend (annotations , annpair );
400
400
401
401
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
+ }
410
410
}
411
411
dec -> annotations = annotations ;
412
412
Py_DECREF (py_annlist );
413
413
414
414
return SRD_OK ;
415
415
416
416
except_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 );
418
418
err_out :
419
419
g_slist_free_full (annotations , (GDestroyNotify )& g_strfreev );
420
420
Py_XDECREF (py_annlist );
@@ -510,7 +510,7 @@ static int get_annotation_rows(struct srd_decoder *dec)
510
510
return SRD_OK ;
511
511
512
512
except_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" ,
514
514
dec -> name );
515
515
err_out :
516
516
g_slist_free_full (annotation_rows , & annotation_row_free );
@@ -566,7 +566,7 @@ static int get_binary_classes(struct srd_decoder *dec)
566
566
return SRD_OK ;
567
567
568
568
except_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" ,
570
570
dec -> name );
571
571
err_out :
572
572
g_slist_free_full (bin_classes , (GDestroyNotify )& g_strfreev );
@@ -585,8 +585,8 @@ static int check_method(PyObject *py_dec, const char *mod_name,
585
585
586
586
py_method = PyObject_GetAttrString (py_dec , method_name );
587
587
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 );
590
590
return SRD_ERR_PYTHON ;
591
591
}
592
592
@@ -636,12 +636,12 @@ SRD_PRIV long srd_decoder_apiver(const struct srd_decoder *d)
636
636
*/
637
637
SRD_API int srd_decoder_load (const char * module_name )
638
638
{
639
- PyObject * py_basedec ;
639
+ PyObject * py_basedec ;
640
640
struct srd_decoder * d ;
641
641
long apiver ;
642
642
int is_subclass ;
643
643
const char * fail_txt ;
644
-
644
+
645
645
if (!srd_check_init ())
646
646
return SRD_ERR ;
647
647
@@ -699,8 +699,8 @@ SRD_API int srd_decoder_load(const char *module_name)
699
699
*/
700
700
apiver = srd_decoder_apiver (d );
701
701
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 );
704
704
fail_txt = "API version mismatch" ;
705
705
goto err_out ;
706
706
}
@@ -776,19 +776,19 @@ SRD_API int srd_decoder_load(const char *module_name)
776
776
fail_txt = "cannot get binary classes" ;
777
777
goto err_out ;
778
778
}
779
-
779
+
780
780
/* Append it to the list of loaded decoders. */
781
781
pd_list = g_slist_append (pd_list , d );
782
782
783
783
return SRD_OK ;
784
784
785
785
except_out :
786
786
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" ,
788
788
module_name , fail_txt );
789
789
fail_txt = NULL ;
790
790
} 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 );
792
792
}
793
793
err_out :
794
794
if (fail_txt )
@@ -823,7 +823,7 @@ SRD_API char *srd_decoder_doc_get(const struct srd_decoder *dec)
823
823
return NULL ;
824
824
825
825
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" );
827
827
return NULL ;
828
828
}
829
829
0 commit comments