GET_NUM_DIGITS(d->afsi.num_played, &num_digits);
w->num_played_width = PARA_MAX(w->num_played_width, num_digits);
/* get the number of chars to print this amount of time */
- tmp = get_duration_width(d->afhi.seconds_total);
- w->duration_width = PARA_MAX(w->duration_width, tmp);
+ num_digits = get_duration_width(d->afhi.seconds_total);
+ w->duration_width = PARA_MAX(w->duration_width, num_digits);
GET_NUM_DIGITS(d->afsi.amp, &num_digits);
w->amp_width = PARA_MAX(w->amp_width, num_digits);
if (options->flags & LS_FLAG_ADMISSIBLE_ONLY) {
aed.name = p;
aed.bitnum = bitnum;
afs_event(ATTRIBUTE_ADD, &pb, &aed);
- greatest_att_bitnum = PARA_MAX(greatest_att_bitnum, bitnum);
+ greatest_att_bitnum = PARA_MAX(greatest_att_bitnum, (int)bitnum);
}
out:
if (ret < 0 && ret2 >= 0)
struct audio_format_info *a;
init_supported_writers();
- nw = PARA_MAX(1, conf.writer_given);
+ nw = PARA_MAX(1U, conf.writer_given);
PARA_INFO_LOG("maximal number of writers: %d\n", nw);
FOR_EACH_AUDIO_FORMAT(i) {
a = &afi[i];
int i, ret, nf;
filter_init(filters);
- nf = PARA_MAX(1, conf.filter_given);
+ nf = PARA_MAX(1U, conf.filter_given);
PARA_INFO_LOG("maximal number of filters: %d\n", nf);
FOR_EACH_AUDIO_FORMAT(i) {
afi[i].filter_conf = para_malloc(nf * sizeof(void *));
/** Number of samples already seen. */
unsigned num_samples;
/** Absolute value of the maximal sample in the current block. */
- unsigned peak;
+ int peak;
};
static ssize_t compress(char *inbuf, size_t inbuf_len, struct filter_node *fn)
pcd->current_gain++;
} else
pcd->current_gain = PARA_MAX(pcd->current_gain - 2,
- 1 << pcd->conf->inertia_arg);
+ 1U << pcd->conf->inertia_arg);
pcd->peak = 0;
}
fn->loaded += length;
{
int i, ret;
struct private_mp3dec_data *pmd = fn->private_data;
- size_t copy = PARA_MIN(len, 4096);
+ size_t copy = PARA_MIN(len, (size_t)4096);
if (fn->loaded > fn->bufsize * 4 / 5)
return 0;
static size_t cb_read(void *buf, size_t size, size_t nmemb, void *datasource)
{
struct ogg_datasource *ods = datasource;
- size_t copy = PARA_MIN(ods->numbytes - ods->fpos, size * nmemb),
- ret = copy / size;
+ size_t copy, ret;
+
+ if (!size)
+ return 0;
+
+ assert(ods->numbytes >= ods->fpos);
+ ret = ods->numbytes - ods->fpos;
+ copy = PARA_MIN(ret, size * nmemb);
+ ret = copy / size;
if (!ret)
return 0;
memcpy(buf, ods->map + ods->fpos, copy);
struct afh_info *afhi)
{
int ret;
- size_t len = PARA_MIN(numbytes, CHUNK_SIZE);
+ size_t len = PARA_MIN(numbytes, (size_t)CHUNK_SIZE);
int serial;
char *buf;
/** used in various contexts */
#define MAXLINE 255
-/** compute the minimum of \a a and \a b */
-#define PARA_MIN(a,b) ((a) < (b) ? (a) : (b))
-/** compute the maximum of \a a and \a b */
-#define PARA_MAX(a,b) ((a) > (b) ? (a) : (b))
-/** compute the absolute value of \a a */
-#define PARA_ABS(a) ((a) > 0 ? (a) : -(a))
+/** Compute the minimum of \a x and \a y. */
+#define PARA_MIN(x, y) ({ \
+ typeof(x) _min1 = (x); \
+ typeof(y) _min2 = (y); \
+ (void) (&_min1 == &_min2); \
+ _min1 < _min2 ? _min1 : _min2; })
+
+/** Compute the maximum of \a x and \a y. */
+#define PARA_MAX(x, y) ({ \
+ typeof(x) _max1 = (x); \
+ typeof(y) _max2 = (y); \
+ (void) (&_max1 == &_max2); \
+ _max1 < _max2 ? _max1 : _max2; })
+
+/** Compute the absolute value of \a x. */
+#define PARA_ABS(x) ({ \
+ typeof(x) _x = (x); \
+ _x > 0? _x : -_x; })
/** debug loglevel, gets really noisy */
#define DEBUG 1
/** Array of pointers to the corresponding writer nodes. */
struct writer_node *writer_nodes;
/** The maximum of the chunk_bytes values of the writer nodes in this group. */
- size_t max_chunk_bytes;
+ int max_chunk_bytes;
/** Non-zero if an error or end of file was encountered by the feeding task. */
int *input_error;
/** Current output buffer. */