signalapp / libsignal-protocol-c

GNU General Public License v3.0
1.4k stars 294 forks source link

Compilation warning with DEBUG_REFCOUNT #36

Open drizt opened 7 years ago

drizt commented 7 years ago
[ 48%] Building C object libsignal-protocol-c/src/CMakeFiles/signal-protocol-c.dir/signal_protocol.c.o
/home/taurus/develop/libsignal-protocol-qt/libsignal-protocol-c/src/signal_protocol.c: In function 'signal_type_ref_count':
/home/taurus/develop/libsignal-protocol-qt/libsignal-protocol-c/src/signal_protocol.c:75:12: warning: conversion to 'int' from 'unsigned int' may change the sign of the result [-Wsign-conversion]
     return instance->ref_count;
            ^

signal_type_ref_count returns int here but signal_type_base::ref_count is unsigned int here.

freeboson commented 7 years ago

Seems like ref_count should be defined as an int not an unsigned int in struct signal_type_base as we actually do assert(instance->ref_count > 0);. That's a better way to ensure that ref_count is positive definite.