Corrected some unsigned int comparisons

This commit is contained in:
Ullrich kossow 2014-08-17 23:37:47 +02:00 committed by Jaroslav Kysela
parent 02bb99bb39
commit 17f7c150a8
4 changed files with 12 additions and 6 deletions

View file

@ -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

View file

@ -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;
@ -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;
@ -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;
}

View file

@ -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)

View file

@ -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);
}