Skip to content

Commit

Permalink
Merge pull request #39 from lars18th/fix-some-warnings
Browse files Browse the repository at this point in the history
Fix some warnings
  • Loading branch information
gfto authored Mar 14, 2024
2 parents d0cf073 + 01d863b commit 307a2bb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions data.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@ INPUT * input_new(const char *name, CHANNEL *channel) {
r->channel = channel;

if (config->write_input_file) {
asprintf(&tmp, "mptsd-input-%s.ts", channel->id);
r->ifd = open(tmp, O_CREAT | O_WRONLY | O_TRUNC, 0644);
if (asprintf(&tmp, "mptsd-input-%s.ts", channel->id) > 0)
r->ifd = open(tmp, O_CREAT | O_WRONLY | O_TRUNC, 0644);
FREE(tmp);
}

Expand Down
5 changes: 3 additions & 2 deletions input.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ void input_buffer_add(INPUT *r, uint8_t *data, int datasize) {
if (r->dienow)
return;
if (r->ifd)
write(r->ifd, data, datasize);
if(write(r->ifd, data, datasize) < 0) {;}
if (r->disabled) {
unsigned long bufsize = r->buf->input - r->buf->output;
double buffull = ((double)bufsize / r->buf->size) * 100;
Expand Down Expand Up @@ -235,7 +235,7 @@ int process_pat(INPUT *r, uint16_t pid, uint8_t *ts_packet) {
}
P->ts_header.continuity = s->pid_pat_cont;
s->pid_pat_cont += P->section_header->num_packets;
write(r->ifd, P->section_header->packet_data, P->section_header->num_packets * TS_PACKET_SIZE);
if (write(r->ifd, P->section_header->packet_data, P->section_header->num_packets * TS_PACKET_SIZE) <0) {;}
}
}
// Stuff packet with NULL data
Expand Down Expand Up @@ -347,6 +347,7 @@ int process_eit(INPUT *r, uint8_t *ts_packet) {
return 1;
}
return -3;
table_id++; // disable warning unused, this code is not reached
}
return 0;
}
Expand Down
6 changes: 4 additions & 2 deletions output_mix.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <string.h>
#include <signal.h>
#include <errno.h>
#include <limits.h>

#include "libfuncs/libfuncs.h"

Expand Down Expand Up @@ -158,8 +159,9 @@ void * output_handle_mix(void *_config) {
// Calculate the required number of packets betweem this PCR and the last one
r->output_pcr_packets_needed = round((double)(conf->output_bitrate / 8 / 27000000 / 188) * (ts_packet_get_pcr(data) - r->output_last_pcr)) - 1;
// Check the boundaries
if (r->output_pcr_packets_needed > o_maxpackets)
r->output_pcr_packets_needed = o_maxpackets;
int bound = (o_maxpackets < (INT_MAX/2))? (unsigned int)o_maxpackets : (INT_MAX/2) ;
if (r->output_pcr_packets_needed > bound)
r->output_pcr_packets_needed = bound;
else if (r->output_pcr_packets_needed < 0)
r->output_pcr_packets_needed = 0;
}
Expand Down

0 comments on commit 307a2bb

Please sign in to comment.