Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Corrected some unsigned int comparisons
  • Loading branch information
UllrichKossow authored and perexg committed Aug 18, 2014
1 parent 02bb99b commit 17f7c15
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/input/mpegts/linuxdvb/linuxdvb_rotor.c
Expand Up @@ -143,7 +143,7 @@ linuxdvb_rotor_grace
if (ld->ld_satconf->lse_parent->ls_orbital_dir == 'W')
curpos = -(curpos);

return (lr->lr_rate*(abs(curpos - lr->lr_position))+999)/1000;
return (lr->lr_rate*(deltaU32(curpos, lr->lr_position))+999)/1000;
}

static int
Expand Down
8 changes: 4 additions & 4 deletions src/input/mpegts/mpegts_network_dvb.c
Expand Up @@ -242,10 +242,10 @@ dvb_network_check_symbol_rate( dvb_mux_t *lm, dvb_mux_conf_t *dmc, int deltar )
return dvb_network_check_bandwidth(lm->lm_tuning.u.dmc_fe_ofdm.bandwidth,
dmc->u.dmc_fe_ofdm.bandwidth);
case DVB_TYPE_C:
return abs(lm->lm_tuning.u.dmc_fe_qam.symbol_rate -
return deltaU32(lm->lm_tuning.u.dmc_fe_qam.symbol_rate,
dmc->u.dmc_fe_qam.symbol_rate) > deltar;
case DVB_TYPE_S:
return abs(lm->lm_tuning.u.dmc_fe_qpsk.symbol_rate -
return deltaU32(lm->lm_tuning.u.dmc_fe_qpsk.symbol_rate,
dmc->u.dmc_fe_qpsk.symbol_rate) > deltar;
case DVB_TYPE_ATSC:
return 0;
Expand Down Expand Up @@ -296,7 +296,7 @@ dvb_network_find_mux
}

/* Reject if not same frequency (some tolerance due to changes and diff in NIT) */
if (abs(lm->lm_tuning.dmc_fe_freq - dmc->dmc_fe_freq) > deltaf) continue;
if (deltaU32(lm->lm_tuning.dmc_fe_freq, dmc->dmc_fe_freq) > deltaf) continue;

/* Reject if not same symbol rate (some tolerance due to changes and diff in NIT) */
if (dvb_network_check_symbol_rate(lm, dmc, deltar)) continue;
Expand Down Expand Up @@ -430,7 +430,7 @@ dvb_network_create_mux
tuning_old = lm->lm_tuning;
#endif
/* Handle big diffs that have been allowed through for DVB-S */
if (abs(dmc->dmc_fe_freq - lm->lm_tuning.dmc_fe_freq) > 4000) {
if (deltaU32(dmc->dmc_fe_freq, lm->lm_tuning.dmc_fe_freq) > 4000) {
lm->lm_tuning.dmc_fe_freq = dmc->dmc_fe_freq;
save = 1;
}
Expand Down
3 changes: 2 additions & 1 deletion src/tvheadend.h
Expand Up @@ -718,7 +718,8 @@ int makedirs ( const char *path, int mode );
int rmtree ( const char *path );

char *regexp_escape ( const char *str );

uint32_t deltaU32(uint32_t a, uint32_t b);

#define SKEL_DECLARE(name, type) type *name;
#define SKEL_ALLOC(name) do { if (!name) name = calloc(1, sizeof(*name)); } while (0)
#define SKEL_USED(name) do { name = NULL; } while (0)
Expand Down
5 changes: 5 additions & 0 deletions src/utils.c
Expand Up @@ -585,3 +585,8 @@ regexp_escape(const char* str)
*b = 0;
return tmp;
}

uint32_t deltaU32(uint32_t a, uint32_t b)
{
return (a > b) ? (a - b) : (b - a);
}

0 comments on commit 17f7c15

Please sign in to comment.