catalinii / minisatip

minisatip is an SATIP server for linux using local DVB-S2, DVB-C, DVB-T or ATSC cards
https://minisatip.org
324 stars 78 forks source link

Pending warnings to fix #1113

Open lars18th opened 1 year ago

lars18th commented 1 year ago

FYI,

Compiling with zig cc and EMBEDDED=1 :

[...]

utils.c:241:11: warning: unused variable 'array' [-Wunused-variable]
    void *array[10];
          ^
utils.c:242:12: warning: unused variable 'size' [-Wunused-variable]
    size_t size;
           ^
utils.c:243:12: warning: unused variable 'i' [-Wunused-variable]
    size_t i;
           ^
utils.c:860:32: warning: unknown warning group '-Wstringop-truncation', ignored [-Wunknown-warning-option]
#pragma GCC diagnostic ignored "-Wstringop-truncation"
                               ^
4 warnings generated.

[...]

pmt.c:644:12: warning: variable 'dcw' set but not used [-Wunused-but-set-variable]
    int i, dcw = 0;
           ^
pmt.c:72:20: warning: unused function 'get_cw' [-Wunused-function]
static inline SCW *get_cw(int id) {
                   ^
pmt.c:131:19: warning: unused function 'get_streamid' [-Wunused-function]
static inline int get_streamid(uint8_t *b) {
                  ^
pmt.c:139:24: warning: unused function 'get_pts_dts' [-Wunused-function]
static inline uint64_t get_pts_dts(uint8_t *b) {
                       ^
4 warnings generated.

[...]

tables.c:390:34: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
            ca[i].op->ca_close_ca(&ca[i]);
                                 ^
1 warning generated.
Jalle19 commented 1 year ago

We should consider turning warnings into errors and fix everything

lars18th commented 1 year ago

We should consider turning warnings into errors and fix everything

This could have sense in the testing phase of the workflow build.yml, right? So, we can add more compilers to check them.

Anyway, you want to fix these small warnings?

Jalle19 commented 1 year ago

This could have sense in the testing phase of the workflow build.yml, right? So, we can add more compilers to check them. Basically, yes. Anyway, you want to fix these small warnings? Sure why not

lars18th commented 1 year ago

More warnings,

In this case with GCC 12.2 running inside the Docker image builder for ARM target

In file included from utils.h:5,
                 from utils.c:24:
utils.c: In function 'myrealloc':
utils/logging/logging.h:38:13: warning: pointer 'p' may be used after 'realloc' [-Wuse-after-free]
   38 |             _log(__FILE__, __LINE__, a, ##__VA_ARGS__);                        \
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
utils/logging/logging.h:41:22: note: in expansion of macro 'LOGL'
   41 | #define LOGM(a, ...) LOGL(DEFAULT_LOG, a, ##__VA_ARGS__)
      |                      ^~~~
utils.c:388:5: note: in expansion of macro 'LOGM'
  388 |     LOGM("%s:%d allocation_wrapper realloc allocated %d bytes from %p -> %p", f,
      |     ^~~~
utils.c:385:15: note: call to 'realloc' here
  385 |     void *x = realloc(p, a);
      |               ^~~~~~~~~~~~~
lars18th commented 1 year ago

These detected compiling with GCC 12.2 for MIPS:

utils.c: In function 'print_trace':
utils.c:246:5: warning: implicit declaration of function 'backtrace' [-Wimplicit-function-declaration]
     size = backtrace(array, 10);
     ^
utils.c: In function '_strncpy':
utils.c:860:9: warning: unknown option after '#pragma GCC diagnostic' kind [-Wpragmas]
 #pragma GCC diagnostic ignored "-Wstringop-truncation"
         ^

[...]

satipc.c: In function 'satipc_read':
satipc.c:688:12: warning: missing braces around initializer [-Wmissing-braces]
     struct mmsghdr messages[MAX_RTP_MSG] = {0};
            ^
satipc.c:688:12: warning: (near initialization for 'messages[0]') [-Wmissing-braces]
satipc.c:690:9: warning: missing braces around initializer [-Wmissing-braces]
         0}; // RTP Header + Payload (up to 1316 bytes) for each UDP datagram
         ^
satipc.c:690:9: warning: (near initialization for 'iovs[0]') [-Wmissing-braces]
lars18th commented 1 year ago

I feel some of the warnings doesn't have sense to fix, because it complicates the code and they aren't errors. However, if someone wants to update the code then no problem. I've fixed some in the PR #1115

lars18th commented 1 year ago

Hi @catalinii ,

Please, review your change of https://github.com/catalinii/minisatip/commit/8d33e939b820fef824c84a92dd6affcd455bbf55 becuase it has broken the automatic checking of patches, like this https://github.com/catalinii/minisatip/actions/runs/5242026172/jobs/9464892586?pr=1119 .

Thank you.

catalinii commented 1 year ago

I hope to fix the binaries generation with zig in max 1 werk