Browse Source

Simplify xxx_is_same() functions.

Georgi Chorbadzhiyski 4 years ago
parent
commit
45e7e999a1
8 changed files with 34 additions and 17 deletions
  1. 4 2
      cat.c
  2. 4 2
      eit.c
  3. 4 2
      nit.c
  4. 4 2
      pat.c
  5. 4 2
      pmt.c
  6. 6 3
      privsec.c
  7. 4 2
      sdt.c
  8. 4 2
      tdt.c

+ 4 - 2
cat.c View File

@@ -185,8 +185,10 @@ void ts_cat_dump(struct ts_cat *cat) {
185 185
 
186 186
 int ts_cat_is_same(struct ts_cat *cat1, struct ts_cat *cat2) {
187 187
 	if (cat1 == cat2) return 1; // Same
188
-	if ((!cat1 && cat2) || (cat1 && !cat2)) return 0; // Not same (one is NULL)
189
-	return ts_section_is_same(cat1->section_header, cat2->section_header);
188
+	if (cat1 && cat2)
189
+		return ts_section_is_same(cat1->section_header, cat2->section_header);
190
+	else
191
+		return 0;
190 192
 }
191 193
 
192 194
 enum CA_system ts_get_CA_sys(uint16_t CA_id) {

+ 4 - 2
eit.c View File

@@ -310,6 +310,8 @@ void ts_eit_dump(struct ts_eit *eit) {
310 310
 
311 311
 int ts_eit_is_same(struct ts_eit *eit1, struct ts_eit *eit2) {
312 312
 	if (eit1 == eit2) return 1; // Same
313
-	if ((!eit1 && eit2) || (eit1 && !eit2)) return 0; // Not same (one is NULL)
314
-	return ts_section_is_same(eit1->section_header, eit2->section_header);
313
+	if (eit1 && eit2)
314
+		return ts_section_is_same(eit1->section_header, eit2->section_header);
315
+	else
316
+		return 0;
315 317
 }

+ 4 - 2
nit.c View File

@@ -294,6 +294,8 @@ void ts_nit_dump(struct ts_nit *nit) {
294 294
 
295 295
 int ts_nit_is_same(struct ts_nit *nit1, struct ts_nit *nit2) {
296 296
 	if (nit1 == nit2) return 1; // Same
297
-	if ((!nit1 && nit2) || (nit1 && !nit2)) return 0; // Not same (one is NULL)
298
-	return ts_section_is_same(nit1->section_header, nit2->section_header);
297
+	if (nit1 && nit2)
298
+		return ts_section_is_same(nit1->section_header, nit2->section_header);
299
+	else
300
+		return 0;
299 301
 }

+ 4 - 2
pat.c View File

@@ -231,6 +231,8 @@ void ts_pat_dump(struct ts_pat *pat) {
231 231
 
232 232
 int ts_pat_is_same(struct ts_pat *pat1, struct ts_pat *pat2) {
233 233
 	if (pat1 == pat2) return 1; // Same
234
-	if ((!pat1 && pat2) || (pat1 && !pat2)) return 0; // Not same (one is NULL)
235
-	return ts_section_is_same(pat1->section_header, pat2->section_header);
234
+	if (pat1 && pat2)
235
+		return ts_section_is_same(pat1->section_header, pat2->section_header);
236
+	else
237
+		return 0;
236 238
 }

+ 4 - 2
pmt.c View File

@@ -295,6 +295,8 @@ void ts_pmt_dump(struct ts_pmt *pmt) {
295 295
 
296 296
 int ts_pmt_is_same(struct ts_pmt *pmt1, struct ts_pmt *pmt2) {
297 297
 	if (pmt1 == pmt2) return 1; // Same
298
-	if ((!pmt1 && pmt2) || (pmt1 && !pmt2)) return 0; // Not same (one is NULL)
299
-	return ts_section_is_same(pmt1->section_header, pmt2->section_header);
298
+	if (pmt1 && pmt2)
299
+		return ts_section_is_same(pmt1->section_header, pmt2->section_header);
300
+	else
301
+		return 0;
300 302
 }

+ 6 - 3
privsec.c View File

@@ -87,9 +87,12 @@ OUT:
87 87
 
88 88
 int ts_privsec_is_same(struct ts_privsec *p1, struct ts_privsec *p2) {
89 89
 	if (p1 == p2) return 1; // Same
90
-	if ((!p1 && p2) || (p1 && !p2)) return 0; // Not same (one is NULL)
91
-	if (p1->section_header->section_length != p1->section_header->section_length) return 0; // Not same
92
-	return memcmp(p1->section_header->section_data, p2->section_header->section_data, p1->section_header->section_length) == 0;
90
+	if (p1 && p2) {
91
+		if (p1->section_header->section_length != p2->section_header->section_length) return 0; // Not same
92
+		return memcmp(p1->section_header->section_data, p2->section_header->section_data, p1->section_header->section_length) == 0;
93
+	} else {
94
+		return 0;
95
+	}
93 96
 }
94 97
 
95 98
 void ts_privsec_dump(struct ts_privsec *privsec) {

+ 4 - 2
sdt.c View File

@@ -267,6 +267,8 @@ void ts_sdt_dump(struct ts_sdt *sdt) {
267 267
 
268 268
 int ts_sdt_is_same(struct ts_sdt *sdt1, struct ts_sdt *sdt2) {
269 269
 	if (sdt1 == sdt2) return 1; // Same
270
-	if ((!sdt1 && sdt2) || (sdt1 && !sdt2)) return 0; // Not same (one is NULL)
271
-	return ts_section_is_same(sdt1->section_header, sdt2->section_header);
270
+	if (sdt1 && sdt2)
271
+		return ts_section_is_same(sdt1->section_header, sdt2->section_header);
272
+	else
273
+		return 0;
272 274
 }

+ 4 - 2
tdt.c View File

@@ -234,6 +234,8 @@ void ts_tdt_dump(struct ts_tdt *tdt) {
234 234
 
235 235
 int ts_tdt_is_same(struct ts_tdt *tdt1, struct ts_tdt *tdt2) {
236 236
 	if (tdt1 == tdt2) return 1; // Same
237
-	if ((!tdt1 && tdt2) || (tdt1 && !tdt2)) return 0; // Not same (one is NULL)
238
-	return ts_section_is_same(tdt1->section_header, tdt2->section_header);
237
+	if (tdt1 && tdt2)
238
+		return ts_section_is_same(tdt1->section_header, tdt2->section_header);
239
+	else
240
+		return 0;
239 241
 }