Skip to content

Commit

Permalink
Enable -Werror and fix all warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
orgads committed Jan 13, 2024
1 parent b745169 commit cfaacbf
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_EXTENSIONS False)
# specify the C++ standard on older CMake (<3.8)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -pedantic -Wno-error=format-truncation -Wno-error=deprecated-declarations")
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -pedantic -Wno-multichar -Wno-deprecated-copy")
endif()

# Include binary dir first, where we add generated config.h and
# version.h. If nothing is found there (release tar) use the version.h
Expand Down
16 changes: 10 additions & 6 deletions src/rtpstream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ static void debugprint(const char* format, ...)
#endif
}

static unsigned long tid_self() {
return reinterpret_cast<unsigned long>(pthread_self());
}

struct free_delete {
void operator()(void* x) { free(x); }
};
Expand Down Expand Up @@ -202,7 +206,7 @@ void printAudioHexUS(char const* note, unsigned char const* string, unsigned int
rtpcheck_debug)
{
pthread_mutex_lock(&debugamutex);
fprintf(debugafile, "TID: %lu %s %u 0x%llx %d [", pthread_self(), note, size, extrainfo, moreinfo);
fprintf(debugafile, "TID: %lu %s %u 0x%llx %d [", tid_self(), note, size, extrainfo, moreinfo);
for (unsigned int i = 0; i < size; i++)
{
fprintf(debugafile, "%02X", 0x000000FF & string[i]);
Expand All @@ -220,7 +224,7 @@ void printVideoHexUS(char const* note, unsigned char const* string, unsigned int
rtpcheck_debug)
{
pthread_mutex_lock(&debugvmutex);
fprintf(debugvfile, "TID: %lu %s %u 0x%llx %d [", pthread_self(), note, size, extrainfo, moreinfo);
fprintf(debugvfile, "TID: %lu %s %u 0x%llx %d [", tid_self(), note, size, extrainfo, moreinfo);
for (unsigned int i = 0; i < size; i++)
{
fprintf(debugvfile, "%02X", 0x000000FF & string[i]);
Expand All @@ -238,7 +242,7 @@ void printAudioHex(char const* note, char const* string, unsigned int size, unsi
rtpcheck_debug)
{
pthread_mutex_lock(&debugamutex);
fprintf(debugafile, "TID: %lu %s %u 0x%llx %d [", pthread_self(), note, size, extrainfo, moreinfo);
fprintf(debugafile, "TID: %lu %s %u 0x%llx %d [", tid_self(), note, size, extrainfo, moreinfo);
for (unsigned int i = 0; i < size; i++)
{
fprintf(debugafile, "%02X", 0x000000FF & string[i]);
Expand All @@ -255,7 +259,7 @@ void printAudioVector(char const* note, std::vector<unsigned long> const &v)
rtpcheck_debug)
{
pthread_mutex_lock(&debugamutex);
fprintf(debugafile, "TID: %lu %s\n", pthread_self(), note);
fprintf(debugafile, "TID: %lu %s\n", tid_self(), note);
for (unsigned int i = 0; i < v.size(); i++)
{
fprintf(debugafile, "%lu\n", v[i]);
Expand All @@ -272,7 +276,7 @@ void printVideoHex(char const* note, char const* string, unsigned int size, unsi
rtpcheck_debug)
{
pthread_mutex_lock(&debugvmutex);
fprintf(debugvfile, "TID: %lu %s %u 0x%llx %d [", pthread_self(), note, size, extrainfo, moreinfo);
fprintf(debugvfile, "TID: %lu %s %u 0x%llx %d [", tid_self(), note, size, extrainfo, moreinfo);
for (unsigned int i = 0; i < size; i++)
{
fprintf(debugvfile, "%02X", 0x000000FF & string[i]);
Expand All @@ -289,7 +293,7 @@ void printVideoVector(char const* note, std::vector<unsigned long> const &v)
rtpcheck_debug)
{
pthread_mutex_lock(&debugvmutex);
fprintf(debugvfile, "TID: %lu %s\n", pthread_self(), note);
fprintf(debugvfile, "TID: %lu %s\n", tid_self(), note);
for (unsigned int i = 0; i < v.size(); i++)
{
fprintf(debugvfile, "%lu\n", v[i]);
Expand Down
19 changes: 8 additions & 11 deletions src/screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,7 @@ void ScreenPrinter::get_lines()
while (isspace(*errstart)) {
errstart++;
}
if (strlen(errstart) > 60) {
snprintf(buf, bufsiz, "Last Error: %.60s...", errstart);
} else {
snprintf(buf, bufsiz, "Last Error: %s", errstart);
}
snprintf(buf, bufsiz, "Last Error: %.60s...", errstart);
lines.push_back(buf);
}

Expand Down Expand Up @@ -264,9 +260,10 @@ bool do_hide = true;

void ScreenPrinter::draw_scenario_screen()
{
unsigned const bufsiz = 80;
unsigned const bufsiz = 100;
char buf[bufsiz];
char left_buf[40];
char left_buf_long[60];
char right_buf[bufsiz];
extern int pollnfds;

Expand Down Expand Up @@ -306,20 +303,20 @@ void ScreenPrinter::draw_scenario_screen()
/* 1st line */
unsigned long ms_since_last_tick = clock_tick - last_report_time;
if (total_calls < stop_after) {
snprintf(left_buf, 40, "%llu new calls during %lu.%03lu s period",
snprintf(left_buf_long, 60, "%llu new calls during %lu.%03lu s period",
display_scenario->stats->GetStat(
CStat::CPT_PD_IncomingCallCreated) +
display_scenario->stats->GetStat(
CStat::CPT_PD_OutgoingCallCreated),
ms_since_last_tick / 1000, ms_since_last_tick % 1000);
} else {
snprintf(left_buf, 40,
snprintf(left_buf_long, 60,
"Call limit %lu hit, %0.1f s period ", stop_after,
(double)ms_since_last_tick / 100.0);
}
snprintf(right_buf, 40, "%lu ms scheduler resolution",
ms_since_last_tick / std::max(scheduling_loops, 1ul));
snprintf(buf, bufsiz, " %-38.38s %-37.37s", left_buf, right_buf);
snprintf(buf, bufsiz, " %-38.38s %-37.37s", left_buf_long, right_buf);
lines.push_back(buf);

/* 2nd line */
Expand Down Expand Up @@ -641,8 +638,8 @@ void ScreenPrinter::draw_scenario_screen()
ERROR("Scenario command %d not implemented in display", curmsg->M_type);
}

char buf_with_index[80] = {0};
snprintf(buf_with_index, 80, "%-2lu:%s", index, buf);
char buf_with_index[121];
snprintf(buf_with_index, 121, "%-2lu:%s", index, buf);
lines.push_back(buf_with_index);
if (curmsg->crlf) {
lines.push_back("");
Expand Down

0 comments on commit cfaacbf

Please sign in to comment.