From: Jaroslav Kysela Date: Mon, 11 Feb 2019 07:38:08 +0000 (+0100) Subject: channel: get number - select the lowest service number, fixes #5441 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=419b0a143c439b50f7d2d979945f5e8d2f6769d1;p=thirdparty%2Ftvheadend.git channel: get number - select the lowest service number, fixes #5441 --- diff --git a/src/channels.c b/src/channels.c index cff8fe242..aa811d76a 100644 --- a/src/channels.c +++ b/src/channels.c @@ -904,21 +904,23 @@ channel_rename_and_save ( const char *from, const char *to ) int64_t channel_get_number ( const channel_t *ch ) { - int64_t n = 0; + int64_t n = 0, v; idnode_list_mapping_t *ilm; if (ch->ch_number) { n = ch->ch_number; } else { if (ch->ch_bouquet) { LIST_FOREACH(ilm, &ch->ch_services, ilm_in2_link) { - if ((n = bouquet_get_channel_number(ch->ch_bouquet, (service_t *)ilm->ilm_in1))) - break; + v = bouquet_get_channel_number(ch->ch_bouquet, (service_t *)ilm->ilm_in1); + if (v > 0 && (n == 0 || v < n)) + n = v; } } if (n == 0) { LIST_FOREACH(ilm, &ch->ch_services, ilm_in2_link) { - if ((n = service_get_channel_number((service_t *)ilm->ilm_in1))) - break; + v = service_get_channel_number((service_t *)ilm->ilm_in1); + if (v > 0 && (n == 0 || v < n)) + n = v; } } }