diff --git a/src/zm_analysis_thread.cpp b/src/zm_analysis_thread.cpp index 148b6571b..74d677316 100644 --- a/src/zm_analysis_thread.cpp +++ b/src/zm_analysis_thread.cpp @@ -24,7 +24,8 @@ void AnalysisThread::Start() { void AnalysisThread::Run() { Microseconds analysis_rate = Microseconds(monitor_->GetAnalysisRate()); Seconds analysis_update_delay = Seconds(monitor_->GetAnalysisUpdateDelay()); - Debug(2, "AnalysisThread::Run() have update delay %d", analysis_update_delay); + Debug(2, "AnalysisThread::Run() has an update delay of %" PRId64 "s", + static_cast(analysis_update_delay.count())); monitor_->UpdateAdaptiveSkip(); diff --git a/src/zm_curl_camera.cpp b/src/zm_curl_camera.cpp index 2c28f857c..a107d78eb 100644 --- a/src/zm_curl_camera.cpp +++ b/src/zm_curl_camera.cpp @@ -100,7 +100,7 @@ void cURLCamera::Initialise() { /* cURL initialization */ CURLcode cRet = (*curl_global_init_f)(CURL_GLOBAL_ALL); if(cRet != CURLE_OK) { - Error("libcurl initialization failed: ", (*curl_easy_strerror_f)(cRet)); + Error("libcurl initialization failed: %s", (*curl_easy_strerror_f)(cRet)); dlclose(curl_lib); return; } @@ -432,7 +432,7 @@ void* cURLCamera::thread_func() { /* Set URL */ cRet = (*curl_easy_setopt_f)(c, CURLOPT_URL, mPath.c_str()); if(cRet != CURLE_OK) { - Error("Failed setting libcurl URL: %s", *(curl_easy_strerror_f)(cRet)); + Error("Failed setting libcurl URL: %s", (*curl_easy_strerror_f)(cRet)); tRet = -52; return (void*)tRet; } @@ -468,7 +468,7 @@ void* cURLCamera::thread_func() { /* Progress callback */ cRet = (*curl_easy_setopt_f)(c, CURLOPT_NOPROGRESS, 0); if(cRet != CURLE_OK) { - Error("Failed enabling libcurl progress callback function: %s", (*curl_easy_strerror_f)(cRet)); + Error("Failed enabling libcurl progress callback function: %s", (*curl_easy_strerror_f)(cRet)); tRet = -57; return (void*)tRet; } diff --git a/src/zm_define.h b/src/zm_define.h index 6fd060dce..45ace017e 100644 --- a/src/zm_define.h +++ b/src/zm_define.h @@ -39,8 +39,6 @@ typedef std::uint32_t uint32; typedef std::uint16_t uint16; typedef std::uint8_t uint8; -#define SZFMTD "%" PRIuPTR - #ifndef FALLTHROUGH #if defined(__clang__) #define FALLTHROUGH [[clang::fallthrough]] diff --git a/src/zm_event.cpp b/src/zm_event.cpp index ab0102b5e..ba3090d4d 100644 --- a/src/zm_event.cpp +++ b/src/zm_event.cpp @@ -88,12 +88,10 @@ Event::Event( localtime_r(&now.tv_sec, &tm_info); strftime(buffer_now, 26, "%Y:%m:%d %H:%M:%S", &tm_info); - Error( - "StartDateTime in the future starttime %ld.%06ld >? now %ld.%06ld difference %d\nstarttime: %s\nnow: %s", - start_time.tv_sec, start_time.tv_usec, now.tv_sec, now.tv_usec, - (now.tv_sec-start_time.tv_sec), - buffer, buffer_now - ); + Error("StartDateTime in the future starttime %ld.%06ld >? now %ld.%06ld difference %" PRIi64 "\nstarttime: %s\nnow: %s", + start_time.tv_sec, start_time.tv_usec, now.tv_sec, now.tv_usec, + static_cast(now.tv_sec - start_time.tv_sec), + buffer, buffer_now); start_time = now; } @@ -241,7 +239,11 @@ Event::~Event() { } struct DeltaTimeval delta_time; DELTA_TIMEVAL(delta_time, end_time, start_time, DT_PREC_2); - Debug(2, "start_time:%d.%d end_time%d.%d", start_time.tv_sec, start_time.tv_usec, end_time.tv_sec, end_time.tv_usec); + Debug(2, "start_time: %" PRIi64 ".% " PRIi64 " end_time: %" PRIi64 ".%" PRIi64, + static_cast(start_time.tv_sec), + static_cast(start_time.tv_usec), + static_cast(end_time.tv_sec), + static_cast(end_time.tv_usec)); if (frame_data.size()) WriteDbFrames(); @@ -360,7 +362,7 @@ void Event::updateNotes(const StringSetMap &newNoteSetMap) { std::string notes; createNotes(notes); - Debug(2, "Updating notes for event %d, '%s'", id, notes.c_str()); + Debug(2, "Updating notes for event %" PRIu64 ", '%s'", id, notes.c_str()); #if USE_PREPARED_SQL static MYSQL_STMT *stmt = 0; @@ -447,7 +449,7 @@ void Event::WriteDbFrames() { "`Blobs`,`MinBlobSize`, `MaxBlobSize`, " "`MinX`, `MinY`, `MaxX`, `MaxY`,`Score`) VALUES "; - Debug(1, "Inserting %d frames", frame_data.size()); + Debug(1, "Inserting %zu frames", frame_data.size()); while (frame_data.size()) { Frame *frame = frame_data.front(); frame_data.pop(); @@ -460,7 +462,7 @@ void Event::WriteDbFrames() { frame->delta.fsec, frame->score); if (config.record_event_stats and frame->zone_stats.size()) { - Debug(1, "ZOne stats size for frame %d: %d", frame->frame_id, frame->zone_stats.size()); + Debug(1, "Zone stats size for frame %d: %zu", frame->frame_id, frame->zone_stats.size()); for (ZoneStats &stats : frame->zone_stats) { stats_insert_sql += stringtf("\n(%" PRIu64 ",%d,%u,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%u),", id, frame->frame_id, @@ -574,12 +576,12 @@ void Event::AddFrame( struct DeltaTimeval delta_time; DELTA_TIMEVAL(delta_time, timestamp, start_time, DT_PREC_2); - Debug(1, "Frame delta is %d.%d - %d.%d = %d.%d, score %u zone_stats.size %u", - start_time.tv_sec, start_time.tv_usec, - timestamp.tv_sec, timestamp.tv_usec, - delta_time.sec, delta_time.fsec, - score, - zone_stats.size()); + Debug(1, "Frame delta is %" PRIi64 ".%" PRIi64 " - %" PRIi64 ".%" PRIi64 " = %lu.%lu, score %u zone_stats.size %zu", + static_cast(start_time.tv_sec), static_cast(start_time.tv_usec), + static_cast(timestamp.tv_sec), static_cast(timestamp.tv_usec), + delta_time.sec, delta_time.fsec, + score, + zone_stats.size()); // The idea is to write out 1/sec frame_data.push(new Frame(id, frames, frame_type, timestamp, delta_time, score, zone_stats)); @@ -592,8 +594,8 @@ void Event::AddFrame( or ( fps and (frame_data.size() > fps) ) ) { - Debug(1, "Adding %d frames to DB because write_to_db:%d or frames > analysis fps %f or BULK(%d)", - frame_data.size(), write_to_db, fps, (frame_type==BULK)); + Debug(1, "Adding %zu frames to DB because write_to_db:%d or frames > analysis fps %f or BULK(%d)", + frame_data.size(), write_to_db, fps, (frame_type == BULK)); WriteDbFrames(); last_db_frame = frames; @@ -611,8 +613,8 @@ void Event::AddFrame( ); dbQueue.push(std::move(sql)); } else { - Debug(1, "Not Adding %d frames to DB because write_to_db:%d or frames > analysis fps %f or BULK", - frame_data.size(), write_to_db, fps); + Debug(1, "Not Adding %zu frames to DB because write_to_db:%d or frames > analysis fps %f or BULK", + frame_data.size(), write_to_db, fps); } // end if frame_type == BULK } // end if db_frame diff --git a/src/zm_eventstream.cpp b/src/zm_eventstream.cpp index 8610f2f04..7a35f6892 100644 --- a/src/zm_eventstream.cpp +++ b/src/zm_eventstream.cpp @@ -71,14 +71,14 @@ bool EventStream::loadInitialEventData(int monitor_id, time_t event_time) { //Info( "eft %d > et %d", event_data->frames[i].timestamp, event_time ); if ( event_data->frames[i].timestamp >= event_time ) { curr_frame_id = i+1; - Debug(3, "Set curr_stream_time:%.2f, curr_frame_id:%d", curr_stream_time, curr_frame_id); + Debug(3, "Set curr_stream_time:%.2f, curr_frame_id:%ld", curr_stream_time, curr_frame_id); break; } } // end foreach frame Debug(3, "Skipping %ld frames", event_data->frame_count); } else { - Warning("Requested an event time less than the start of the event. event_time %.2f < start_time %.2f", - event_time, event_data->start_time); + Warning("Requested an event time less than the start of the event. event_time %" PRIi64 " < start_time %" PRIi64, + static_cast(event_time), static_cast(event_data->start_time)); } } // end if have a start time return true; @@ -92,7 +92,7 @@ bool EventStream::loadInitialEventData( if ( init_frame_id ) { if ( init_frame_id >= event_data->frame_count ) { - Error("Invalid frame id specified. %d > %d", init_frame_id, event_data->frame_count); + Error("Invalid frame id specified. %d > %lu", init_frame_id, event_data->frame_count); curr_stream_time = event_data->start_time; curr_frame_id = 1; } else { @@ -119,7 +119,7 @@ bool EventStream::loadEventData(uint64_t event_id) { } if ( !mysql_num_rows(result) ) { - Fatal("Unable to load event %d, not found in DB", event_id); + Fatal("Unable to load event %" PRIu64 ", not found in DB", event_id); } MYSQL_ROW dbrow = mysql_fetch_row(result); @@ -334,7 +334,10 @@ void EventStream::processCommand(const CmdMsg *msg) { curr_frame_id = 1; } else { Debug(1, "mode is %s, current frame is %ld, frame count is %ld, last frame id is %ld", - StreamMode_Strings[(int)mode].c_str(), curr_frame_id, event_data->frame_count ); + StreamMode_Strings[(int) mode].c_str(), + curr_frame_id, + event_data->frame_count, + event_data->last_frame_id); } replay_rate = ZM_RATE_BASE; @@ -389,7 +392,7 @@ void EventStream::processCommand(const CmdMsg *msg) { step = 1; if ( (unsigned int)curr_frame_id < event_data->last_frame_id ) curr_frame_id += 1; - Debug(1, "Got SLOWFWD command new frame id %d", curr_frame_id); + Debug(1, "Got SLOWFWD command new frame id %ld", curr_frame_id); break; case CMD_SLOWREV : paused = true; @@ -397,7 +400,7 @@ void EventStream::processCommand(const CmdMsg *msg) { step = -1; curr_frame_id -= 1; if ( curr_frame_id < 1 ) curr_frame_id = 1; - Debug(1, "Got SLOWREV command new frame id %d", curr_frame_id); + Debug(1, "Got SLOWREV command new frame id %ld", curr_frame_id); break; case CMD_FASTREV : Debug(1, "Got FAST REV command"); @@ -526,7 +529,7 @@ void EventStream::processCommand(const CmdMsg *msg) { } curr_stream_time = event_data->frames[curr_frame_id-1].timestamp; - Debug(1, "Got SEEK command, to %f (new current frame id: %d offset %f)", + Debug(1, "Got SEEK command, to %f (new current frame id: %ld offset %f)", offset, curr_frame_id, event_data->frames[curr_frame_id-1].offset); send_frame = true; break; @@ -569,7 +572,7 @@ void EventStream::processCommand(const CmdMsg *msg) { DataMsg status_msg; status_msg.msg_type = MSG_DATA_EVENT; memcpy(&status_msg.msg_data, &status_data, sizeof(status_data)); - Debug(1, "Size of msg %d", sizeof(status_data)); + Debug(1, "Size of msg %zu", sizeof(status_data)); if ( sendto(sd, &status_msg, sizeof(status_msg), MSG_DONTWAIT, (sockaddr *)&rem_addr, sizeof(rem_addr)) < 0 ) { //if ( errno != EAGAIN ) { @@ -604,7 +607,7 @@ bool EventStream::checkEventLoaded() { event_data->monitor_id, event_data->event_id); } else { // No event change required - Debug(3, "No event change required, as curr frame %d <=> event frames %d", + Debug(3, "No event change required, as curr frame %ld <=> event frames %lu", curr_frame_id, event_data->frame_count); return false; } @@ -638,7 +641,7 @@ bool EventStream::checkEventLoaded() { curr_frame_id = event_data->last_frame_id; else curr_frame_id = 1; - Debug(2, "New frame id = %d", curr_frame_id); + Debug(2, "New frame id = %ld", curr_frame_id); return true; } else { Debug(2, "No next event loaded using %s. Pausing", sql.c_str()); @@ -666,13 +669,13 @@ Image * EventStream::getImage( ) { static char filepath[PATH_MAX]; snprintf(filepath, sizeof(filepath), staticConfig.capture_file_format, event_data->path, curr_frame_id); - Debug(2, "EventStream::getImage path(%s) from %s frame(%d) ", filepath, event_data->path, curr_frame_id); + Debug(2, "EventStream::getImage path(%s) from %s frame(%ld) ", filepath, event_data->path, curr_frame_id); Image *image = new Image(filepath); return image; } bool EventStream::sendFrame(int delta_us) { - Debug(2, "Sending frame %d", curr_frame_id); + Debug(2, "Sending frame %ld", curr_frame_id); static char filepath[PATH_MAX]; static struct stat filestat; @@ -856,7 +859,7 @@ void EventStream::runStream() { if ( !paused ) { // Figure out if we should send this frame - Debug(3, "not paused at cur_frame_id (%d-1) mod frame_mod(%d)", curr_frame_id, frame_mod); + Debug(3, "not paused at cur_frame_id (%ld-1) mod frame_mod(%d)", curr_frame_id, frame_mod); // If we are streaming and this frame is due to be sent // frame mod defaults to 1 and if we are going faster than max_fps will get multiplied by 2 // so if it is 2, then we send every other frame, if is it 4 then every fourth frame, etc. @@ -964,8 +967,8 @@ void EventStream::runStream() { // We assume that we are going forward and the next frame is in the future. delta_us = frame_data->offset * 1000000 - (now_usec-start_usec); // - (now_usec - start_usec); - Debug(2, "New delta_us now %" PRIu64 " - start %" PRIu64 " = %d offset %" PRId64 " - elapsed = %dusec", - now_usec, start_usec, now_usec-start_usec, frame_data->offset * 1000000, delta_us); + Debug(2, "New delta_us now %" PRIu64 " - start %" PRIu64 " = %" PRIu64 " offset %f - elapsed = %dusec", + now_usec, start_usec, static_cast(now_usec - start_usec), frame_data->offset * 1000000, delta_us); } else { Debug(2, "No last frame_offset, no sleep"); delta_us = 0; @@ -1054,12 +1057,12 @@ bool EventStream::send_file(const char *filepath) { } if ( !filestat.st_size ) { fclose(fdj); /* Close the file handle */ - Info("File size is zero. Unable to send raw frame %u: %s", curr_frame_id); + Info("File size is zero. Unable to send raw frame %ld: %s", curr_frame_id, strerror(errno)); return false; } if ( 0 > fprintf(stdout, "Content-Length: %d\r\n\r\n", (int)filestat.st_size) ) { fclose(fdj); /* Close the file handle */ - Info("Unable to send raw frame %u: %s", curr_frame_id, strerror(errno)); + Info("Unable to send raw frame %ld: %s", curr_frame_id, strerror(errno)); return false; } int rc = zm_sendfile(fileno(stdout), fileno(fdj), 0, (int)filestat.st_size); @@ -1068,12 +1071,12 @@ bool EventStream::send_file(const char *filepath) { fclose(fdj); /* Close the file handle */ return true; } - Warning("Unable to send raw frame %u: %s rc %d", curr_frame_id, strerror(errno), rc); + Warning("Unable to send raw frame %ld: %s rc %d", curr_frame_id, strerror(errno), rc); #endif img_buffer_size = fread(img_buffer, 1, sizeof(temp_img_buffer), fdj); fclose(fdj); /* Close the file handle */ if ( !img_buffer_size ) { - Info("Unable to read raw frame %u: %s", curr_frame_id, strerror(errno)); + Info("Unable to read raw frame %ld: %s", curr_frame_id, strerror(errno)); return false; } @@ -1082,13 +1085,13 @@ bool EventStream::send_file(const char *filepath) { bool EventStream::send_buffer(uint8_t* buffer, int size) { if ( 0 > fprintf(stdout, "Content-Length: %d\r\n\r\n", size) ) { - Info("Unable to send raw frame %u: %s", curr_frame_id, strerror(errno)); + Info("Unable to send raw frame %ld: %s", curr_frame_id, strerror(errno)); return false; } int rc = fwrite(buffer, size, 1, stdout); if ( 1 != rc ) { - Error("Unable to send raw frame %u: %s %d", curr_frame_id, strerror(errno), rc); + Error("Unable to send raw frame %ld: %s %d", curr_frame_id, strerror(errno), rc); return false; } return true; diff --git a/src/zm_ffmpeg.cpp b/src/zm_ffmpeg.cpp index 477a91388..dcb22ed82 100644 --- a/src/zm_ffmpeg.cpp +++ b/src/zm_ffmpeg.cpp @@ -66,7 +66,7 @@ void log_libav_callback(void *ptr, int level, const char *fmt, va_list vargs) { if (static_cast(length) > sizeof(logString)-1) length = sizeof(logString)-1; // ffmpeg logs have a carriage return, so replace it with terminator logString[length-1] = 0; - log->logPrint(false, __FILE__, __LINE__, log_level, logString); + log->logPrint(false, __FILE__, __LINE__, log_level, "%s", logString); } else { log->logPrint(false, __FILE__, __LINE__, AV_LOG_ERROR, "Can't encode log from av. fmt was %s", fmt); } @@ -636,8 +636,7 @@ int zm_resample_audio( av_make_error_string(ret).c_str()); return 0; } - Debug(3,"swr_get_delay %d", - swr_get_delay(resample_ctx, out_frame->sample_rate)); + Debug(3, "swr_get_delay %" PRIi64, swr_get_delay(resample_ctx, out_frame->sample_rate)); #else #if defined(HAVE_LIBAVRESAMPLE) if (!in_frame) { diff --git a/src/zm_ffmpeg.h b/src/zm_ffmpeg.h index cb6d7ca1a..b5bdd2705 100644 --- a/src/zm_ffmpeg.h +++ b/src/zm_ffmpeg.h @@ -308,15 +308,13 @@ void zm_dump_codec(const AVCodecContext *codec); #if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0) void zm_dump_codecpar(const AVCodecParameters *par); #endif -#define zm_dump_frame(frame, text) Debug(1, "%s: format %d %s sample_rate %" PRIu32 " nb_samples %d channels %d" \ - " duration %" PRId64 \ - " layout %d pts %" PRId64, \ +#define zm_dump_frame(frame, text) Debug(1, "%s: format %d %s sample_rate %" PRIu32 " nb_samples %d" \ + " layout %" PRIu64 " pts %" PRId64, \ text, \ frame->format, \ av_get_sample_fmt_name((AVSampleFormat)frame->format), \ frame->sample_rate, \ frame->nb_samples, \ - 0, 0, \ frame->channel_layout, \ frame->pts \ ); diff --git a/src/zm_ffmpeg_camera.cpp b/src/zm_ffmpeg_camera.cpp index b9b288920..b0c1401e7 100644 --- a/src/zm_ffmpeg_camera.cpp +++ b/src/zm_ffmpeg_camera.cpp @@ -623,7 +623,9 @@ int FfmpegCamera::FfmpegInterruptCallback(void *ctx) { } time_t now = time(nullptr); if (now - start_read_time > 10) { - Debug(1, "timeout in ffmpeg camera now %d - %d > 10", now, start_read_time); + Debug(1, "timeout in ffmpeg camera now %" PRIi64 " - %" PRIi64 " > 10", + static_cast(now), + static_cast(start_read_time)); return 1; } return 0; diff --git a/src/zm_image.cpp b/src/zm_image.cpp index 39cf9d55a..d42c4a1bf 100644 --- a/src/zm_image.cpp +++ b/src/zm_image.cpp @@ -647,7 +647,7 @@ void Image::AssignDirect( return; } - unsigned int new_buffer_size = p_width * p_height * p_colours; + size_t new_buffer_size = p_width * p_height * p_colours; if ( buffer_size < new_buffer_size ) { Error("Attempt to directly assign buffer from an undersized buffer of size: %zu, needed %dx%d*%d colours = %zu", diff --git a/src/zm_libvlc_camera.cpp b/src/zm_libvlc_camera.cpp index a1a552fd5..59cdc4ccf 100644 --- a/src/zm_libvlc_camera.cpp +++ b/src/zm_libvlc_camera.cpp @@ -227,11 +227,11 @@ int LibvlcCamera::PrimeCapture() { if ( opVect.size() > 0 ) { mOptArgV = new char*[opVect.size()]; - Debug(2, "Number of Options: %d",opVect.size()); + Debug(2, "Number of Options: %zu", opVect.size()); for (size_t i=0; i< opVect.size(); i++) { opVect[i] = TrimSpaces(opVect[i]); mOptArgV[i] = (char *)opVect[i].c_str(); - Debug(2, "set option %d to '%s'", i, opVect[i].c_str()); + Debug(2, "set option %zu to '%s'", i, opVect[i].c_str()); } } @@ -319,9 +319,9 @@ void LibvlcCamera::log_callback(void *ptr, int level, const libvlc_log_t *ctx, c } if ( log ) { - char logString[8192]; - vsnprintf(logString, sizeof(logString)-1, fmt, vargs); - log->logPrint(false, __FILE__, __LINE__, log_level, logString); + char logString[8192]; + vsnprintf(logString, sizeof(logString) - 1, fmt, vargs); + log->logPrint(false, __FILE__, __LINE__, log_level, "%s", logString); } } #endif // HAVE_LIBVLC diff --git a/src/zm_libvnc_camera.cpp b/src/zm_libvnc_camera.cpp index 084a6a489..faa594a7e 100644 --- a/src/zm_libvnc_camera.cpp +++ b/src/zm_libvnc_camera.cpp @@ -44,7 +44,7 @@ static void GotFrameBufferUpdateCallback(rfbClient *rfb, int x, int y, int w, in } static char* GetPasswordCallback(rfbClient* cl) { - Debug(1, "Getcredentials: %s", (*rfbClientGetClientData_f)(cl, &TAG_1)); + Debug(1, "Getcredentials: %s", static_cast((*rfbClientGetClientData_f)(cl, &TAG_1))); return strdup((const char *)(*rfbClientGetClientData_f)(cl, &TAG_1)); } @@ -55,7 +55,9 @@ static rfbCredential* GetCredentialsCallback(rfbClient* cl, int credentialType){ } rfbCredential *c = (rfbCredential *)malloc(sizeof(rfbCredential)); - Debug(1, "Getcredentials: %s:%s", (*rfbClientGetClientData_f)(cl, &TAG_1), (*rfbClientGetClientData_f)(cl, &TAG_2)); + Debug(1, "Getcredentials: %s:%s", + static_cast((*rfbClientGetClientData_f)(cl, &TAG_1)), + static_cast((*rfbClientGetClientData_f)(cl, &TAG_2))); c->userCredential.password = strdup((const char *)(*rfbClientGetClientData_f)(cl, &TAG_1)); c->userCredential.username = strdup((const char *)(*rfbClientGetClientData_f)(cl, &TAG_2)); return c; diff --git a/src/zm_local_camera.cpp b/src/zm_local_camera.cpp index c2ddf74a9..3978c08a5 100644 --- a/src/zm_local_camera.cpp +++ b/src/zm_local_camera.cpp @@ -665,7 +665,7 @@ LocalCamera::LocalCamera( unsigned int pSize = avpicture_get_size(imagePixFormat, width, height); #endif if ( pSize != imagesize ) { - Fatal("Image size mismatch. Required: %d Available: %u", pSize, imagesize); + Fatal("Image size mismatch. Required: %d Available: %llu", pSize, imagesize); } imgConversionContext = sws_getContext( diff --git a/src/zm_logger.cpp b/src/zm_logger.cpp index f8e7d7316..dd03ec9f2 100644 --- a/src/zm_logger.cpp +++ b/src/zm_logger.cpp @@ -415,7 +415,7 @@ void Logger::closeSyslog() { (void) closelog(); } -void Logger::logPrint(bool hex, const char * const filepath, const int line, const int level, const char *fstring, ...) { +void Logger::logPrint(bool hex, const char *filepath, int line, int level, const char *fstring, ...) { if (level > mEffectiveLevel) return; if (level < PANIC || level > DEBUG9) Panic("Invalid logger level %d", level); diff --git a/src/zm_logger.h b/src/zm_logger.h index b2a9bbeb0..79c3dfd7c 100644 --- a/src/zm_logger.h +++ b/src/zm_logger.h @@ -173,8 +173,13 @@ private: void closeSyslog(); void closeDatabase(); -public: - void logPrint(bool hex, const char * const filepath, const int line, const int level, const char *fstring, ...); + public: + void logPrint(bool hex, + const char *filepath, + int line, + int level, + const char *fstring, + ...) __attribute__((format(printf, 6, 7))); }; void logInit(const char *name, const Logger::Options &options=Logger::Options()); diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index b3dd38d0f..8ab6bb2d1 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -148,7 +148,7 @@ bool Monitor::MonitorLink::connect() { mem_size = sizeof(SharedData) + sizeof(TriggerData); - Debug(1, "link.mem.size=%d", mem_size); + Debug(1, "link.mem.size=%jd", mem_size); #if ZM_MEM_MAPPED map_fd = open(mem_file, O_RDWR, (mode_t)0600); if ( map_fd < 0 ) { @@ -175,14 +175,14 @@ bool Monitor::MonitorLink::connect() { disconnect(); return false; } else if ( map_stat.st_size < mem_size ) { - Error("Got unexpected memory map file size %ld, expected %d", map_stat.st_size, mem_size); + Error("Got unexpected memory map file size %ld, expected %jd", map_stat.st_size, mem_size); disconnect(); return false; } mem_ptr = (unsigned char *)mmap(nullptr, mem_size, PROT_READ|PROT_WRITE, MAP_SHARED, map_fd, 0); if ( mem_ptr == MAP_FAILED ) { - Error("Can't map file %s (%d bytes) to memory: %s", mem_file, mem_size, strerror(errno)); + Error("Can't map file %s (%jd bytes) to memory: %s", mem_file, mem_size, strerror(errno)); disconnect(); return false; } @@ -632,12 +632,17 @@ void Monitor::Load(MYSQL_ROW dbrow, bool load_zones=true, Purpose p = QUERY) { + (image_buffer_count * image_size) + 64; /* Padding used to permit aligning the images buffer to 64 byte boundary */ - Debug(1, "mem.size(%d) SharedData=%d TriggerData=%d VideoStoreData=%d timestamps=%d images=%dx%d = %" PRId64 " total=%" PRId64, - sizeof(mem_size), - sizeof(SharedData), sizeof(TriggerData), sizeof(VideoStoreData), - (image_buffer_count*sizeof(struct timeval)), - image_buffer_count, image_size, (image_buffer_count*image_size), - mem_size); + Debug(1, + "mem.size(%zu) SharedData=%zu TriggerData=%zu VideoStoreData=%zu timestamps=%zu images=%dx%" PRIi64 " = %" PRId64 " total=%jd", + sizeof(mem_size), + sizeof(SharedData), + sizeof(TriggerData), + sizeof(VideoStoreData), + (image_buffer_count * sizeof(struct timeval)), + image_buffer_count, + image_size, + (image_buffer_count * image_size), + mem_size); // Should maybe store this for later use std::string monitor_dir = stringtf("%s/%u", storage->Path(), id); @@ -675,7 +680,7 @@ void Monitor::Load(MYSQL_ROW dbrow, bool load_zones=true, Purpose p = QUERY) { } } // end if purpose - Debug(1, "Loaded monitor %d(%s), %d zones", id, name.c_str(), zones.size()); + Debug(1, "Loaded monitor %d(%s), %zu zones", id, name.c_str(), zones.size()); } // Monitor::Load(MYSQL_ROW dbrow, bool load_zones=true, Purpose p = QUERY) void Monitor::LoadCamera() { @@ -927,18 +932,18 @@ bool Monitor::connect() { if (purpose == CAPTURE) { // Allocate the size if (ftruncate(map_fd, mem_size) < 0) { - Error("Can't extend memory map file %s to %d bytes: %s", mem_file, mem_size, strerror(errno)); + Error("Can't extend memory map file %s to %jd bytes: %s", mem_file, mem_size, strerror(errno)); close(map_fd); map_fd = -1; return false; } } else if (map_stat.st_size == 0) { - Error("Got empty memory map file size %ld, is the zmc process for this monitor running?", map_stat.st_size, mem_size); + Error("Got empty memory map file size %ld, is the zmc process for this monitor running?", map_stat.st_size); close(map_fd); map_fd = -1; return false; } else { - Error("Got unexpected memory map file size %ld, expected %d", map_stat.st_size, mem_size); + Error("Got unexpected memory map file size %ld, expected %jd", map_stat.st_size, mem_size); close(map_fd); map_fd = -1; return false; @@ -950,18 +955,18 @@ bool Monitor::connect() { mem_ptr = (unsigned char *)mmap(nullptr, mem_size, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_LOCKED, map_fd, 0); if (mem_ptr == MAP_FAILED) { if (errno == EAGAIN) { - Debug(1, "Unable to map file %s (%d bytes) to locked memory, trying unlocked", mem_file, mem_size); + Debug(1, "Unable to map file %s (%jd bytes) to locked memory, trying unlocked", mem_file, mem_size); #endif mem_ptr = (unsigned char *)mmap(nullptr, mem_size, PROT_READ|PROT_WRITE, MAP_SHARED, map_fd, 0); - Debug(1, "Mapped file %s (%d bytes) to unlocked memory", mem_file, mem_size); + Debug(1, "Mapped file %s (%jd bytes) to unlocked memory", mem_file, mem_size); #ifdef MAP_LOCKED } else { - Error("Unable to map file %s (%d bytes) to locked memory (%s)", mem_file, mem_size, strerror(errno)); + Error("Unable to map file %s (%jd bytes) to locked memory (%s)", mem_file, mem_size, strerror(errno)); } } #endif if ((mem_ptr == MAP_FAILED) or (mem_ptr == nullptr)) { - Error("Can't map file %s (%d bytes) to memory: %s(%d)", mem_file, mem_size, strerror(errno), errno); + Error("Can't map file %s (%jd bytes) to memory: %s(%d)", mem_file, mem_size, strerror(errno), errno); close(map_fd); map_fd = -1; mem_ptr = nullptr; @@ -1723,10 +1728,14 @@ void Monitor::UpdateAnalysisFPS() { gettimeofday(&now, nullptr); double now_double = (double)now.tv_sec + (0.000001f * now.tv_usec); double elapsed = now_double - last_analysis_fps_time; - Debug(4, "%s: %d - now:%d.%d = %lf, last %lf, diff %lf", name.c_str(), analysis_image_count, - now.tv_sec, now.tv_usec, now_double, last_analysis_fps_time, - elapsed - ); + Debug(4, "%s: %d - now:%" PRIi64 ".%" PRIi64 " = %lf, last %lf, diff %lf", + name.c_str(), + analysis_image_count, + static_cast(now.tv_sec), + static_cast(now.tv_usec), + now_double, + last_analysis_fps_time, + elapsed); if ( elapsed > 1.0 ) { double new_analysis_fps = double(motion_frame_count - last_motion_frame_count) / elapsed; @@ -1970,12 +1979,14 @@ bool Monitor::Analyse() { || ! ( timestamp->tv_sec % section_length ) ) ) { - Info("%s: %03d - Closing event %" PRIu64 ", section end forced %d - %d = %d >= %d", - name.c_str(), image_count, event->Id(), - timestamp->tv_sec, video_store_data->recording.tv_sec, - timestamp->tv_sec - video_store_data->recording.tv_sec, - section_length - ); + Info("%s: %03d - Closing event %" PRIu64 ", section end forced %" PRIi64 " - %" PRIi64 " = %" PRIi64 " >= %d", + name.c_str(), + image_count, + event->Id(), + static_cast(timestamp->tv_sec), + static_cast(video_store_data->recording.tv_sec), + static_cast(timestamp->tv_sec - video_store_data->recording.tv_sec), + section_length); closeEvent(); } // end if section_length } // end if event @@ -2062,10 +2073,13 @@ bool Monitor::Analyse() { closeEvent(); } else if (event) { // This is so if we need more than 1 alarm frame before going into alarm, so it is basically if we have enough alarm frames - Debug(3, "pre_alarm_count in event %d, event frames %d, alarm frames %d event length %d >=? %d min", - Event::PreAlarmCount(), event->Frames(), event->AlarmFrames(), - ( timestamp->tv_sec - video_store_data->recording.tv_sec ), min_section_length - ); + Debug(3, + "pre_alarm_count in event %d, event frames %d, alarm frames %d event length %" PRIi64 " >=? %d min", + Event::PreAlarmCount(), + event->Frames(), + event->AlarmFrames(), + static_cast(timestamp->tv_sec - video_store_data->recording.tv_sec), + min_section_length); } if ((!pre_event_count) || (Event::PreAlarmCount() >= alarm_frame_count-1)) { // lets construct alarm cause. It will contain cause + names of zones alarmed @@ -2183,9 +2197,15 @@ bool Monitor::Analyse() { // Back to IDLE shared_data->state = state = ((function != MOCORD) ? IDLE : TAPE); } else { - Debug(1, "State %s because image_count(%d)-last_alarm_count(%d) > post_event_count(%d) and timestamp.tv_sec(%d) - recording.tv_src(%d) >= min_section_length(%d)", - State_Strings[state].c_str(), analysis_image_count, last_alarm_count, post_event_count, - timestamp->tv_sec, video_store_data->recording.tv_sec, min_section_length); + Debug(1, + "State %s because image_count(%d)-last_alarm_count(%d) > post_event_count(%d) and timestamp.tv_sec(%" PRIi64 ") - recording.tv_src(%" PRIi64 ") >= min_section_length(%d)", + State_Strings[state].c_str(), + analysis_image_count, + last_alarm_count, + post_event_count, + static_cast(timestamp->tv_sec), + static_cast(video_store_data->recording.tv_sec), + min_section_length); } if (Event::PreAlarmCount()) Event::EmptyPreAlarmFrames(); @@ -2226,12 +2246,11 @@ bool Monitor::Analyse() { if ( section_length && ( ( timestamp->tv_sec - video_store_data->recording.tv_sec ) >= section_length ) ) { - Warning("%s: %03d - event %" PRIu64 ", has exceeded desired section length. %d - %d = %d >= %d", - name.c_str(), analysis_image_count, event->Id(), - timestamp->tv_sec, video_store_data->recording.tv_sec, - timestamp->tv_sec - video_store_data->recording.tv_sec, - section_length - ); + Warning("%s: %03d - event %" PRIu64 ", has exceeded desired section length. %" PRIi64 " - %" PRIi64 " = %" PRIi64 " >= %d", + name.c_str(), analysis_image_count, event->Id(), + static_cast(timestamp->tv_sec), static_cast(video_store_data->recording.tv_sec), + static_cast(timestamp->tv_sec - video_store_data->recording.tv_sec), + section_length); closeEvent(); event = new Event(this, *timestamp, cause, noteSetMap); shared_data->last_event_id = event->Id(); @@ -2324,9 +2343,9 @@ void Monitor::Reload() { } // end void Monitor::Reload() void Monitor::ReloadZones() { - Debug(3, "Reloading zones for monitor %s have %u", name.c_str(), zones.size()); + Debug(3, "Reloading zones for monitor %s have %zu", name.c_str(), zones.size()); zones = Zone::Load(this); - Debug(1, "Reloading zones for monitor %s have %u", name.c_str(), zones.size()); + Debug(1, "Reloading zones for monitor %s have %zu", name.c_str(), zones.size()); this->AddPrivacyBitmask(); //DumpZoneImage(); } // end void Monitor::ReloadZones() @@ -3144,8 +3163,8 @@ void Monitor::get_ref_image() { ) and !zm_terminate) { - Debug(1, "Waiting for capture daemon lastwriteindex(%d) lastwritetime(%d)", - shared_data->last_write_index, shared_data->last_write_time); + Debug(1, "Waiting for capture daemon lastwriteindex(%d) lastwritetime(%" PRIi64 ")", + shared_data->last_write_index, static_cast(shared_data->last_write_time)); if ( snap_lock and ! snap_lock->packet_->image ) { delete snap_lock; // can't analyse it anyways, incremement diff --git a/src/zm_monitor.h b/src/zm_monitor.h index cd9d274da..29299c66b 100644 --- a/src/zm_monitor.h +++ b/src/zm_monitor.h @@ -439,10 +439,14 @@ public: inline int ShmValid() const { if ( shared_data && shared_data->valid ) { - struct timeval now; + timeval now = {}; gettimeofday(&now, nullptr); - Debug(3, "Shared data is valid, checking heartbeat %u - %u = %d < %f", - now.tv_sec, shared_data->zmc_heartbeat_time, (now.tv_sec - shared_data->zmc_heartbeat_time), config.watch_max_delay); + Debug(3, "Shared data is valid, checking heartbeat %" PRIi64 " - %" PRIi64 " = %" PRIi64" < %f", + static_cast(now.tv_sec), + static_cast(shared_data->zmc_heartbeat_time), + static_cast(now.tv_sec - shared_data->zmc_heartbeat_time), + config.watch_max_delay); + if ((now.tv_sec - shared_data->zmc_heartbeat_time) < config.watch_max_delay) return true; } diff --git a/src/zm_monitorstream.cpp b/src/zm_monitorstream.cpp index 52ccfeeb1..9d30511ee 100644 --- a/src/zm_monitorstream.cpp +++ b/src/zm_monitorstream.cpp @@ -795,14 +795,17 @@ void MonitorStream::runStream() { if ( sleep_time > MonitorStream::MAX_SLEEP_USEC ) { // Shouldn't sleep for long because we need to check command queue, etc. sleep_time = MonitorStream::MAX_SLEEP_USEC; - Debug(3, "Sleeping for MAX_SLEEP_USEC %dus", sleep_time); + Debug(3, "Sleeping for MAX_SLEEP_USEC %luus", sleep_time); } else { - Debug(3, "Sleeping for %dus", sleep_time); + Debug(3, "Sleeping for %luus", sleep_time); } usleep(sleep_time); if ( ttl ) { if ( (now.tv_sec - stream_start_time) > ttl ) { - Debug(2, "now(%d) - start(%d) > ttl(%d) break", now.tv_sec, stream_start_time, ttl); + Debug(2, "now(%" PRIi64 ") - start(%" PRIi64 " ) > ttl(%" PRIi64 ") break", + static_cast(now.tv_sec), + static_cast(stream_start_time), + static_cast(ttl)); break; } } diff --git a/src/zm_mpeg.cpp b/src/zm_mpeg.cpp index c0b60ed2a..5ab1ad5dc 100644 --- a/src/zm_mpeg.cpp +++ b/src/zm_mpeg.cpp @@ -101,7 +101,7 @@ void VideoStream::SetupFormat( ) { ofc = s; #endif if ( !ofc ) { - Fatal("avformat_alloc_..._context failed: %d", ofc); + Fatal("avformat_alloc_..._context failed"); } of = ofc->oformat; diff --git a/src/zm_packetqueue.cpp b/src/zm_packetqueue.cpp index 82a583c3e..016e94dae 100644 --- a/src/zm_packetqueue.cpp +++ b/src/zm_packetqueue.cpp @@ -121,8 +121,14 @@ bool PacketQueue::queuePacket(ZMPacket* add_packet) { pktQueue.pop_front(); packet_counts[zm_packet->packet.stream_index] -= 1; - Debug(1, "Deleting a packet with stream index:%d image_index:%d with keyframe:%d, video frames in queue:%d max: %d, queuesize:%d", - zm_packet->packet.stream_index, zm_packet->image_index, zm_packet->keyframe, packet_counts[video_stream_id], max_video_packet_count, pktQueue.size()); + Debug(1, + "Deleting a packet with stream index:%d image_index:%d with keyframe:%d, video frames in queue:%d max: %d, queuesize:%zu", + zm_packet->packet.stream_index, + zm_packet->image_index, + zm_packet->keyframe, + packet_counts[video_stream_id], + max_video_packet_count, + pktQueue.size()); delete zm_packet; } // end while } @@ -216,8 +222,14 @@ void PacketQueue::clearPackets(ZMPacket *add_packet) { pktQueue.pop_front(); packet_counts[zm_packet->packet.stream_index] -= 1; - Debug(1, "Deleting a packet with stream index:%d image_index:%d with keyframe:%d, video frames in queue:%d max: %d, queuesize:%d", - zm_packet->packet.stream_index, zm_packet->image_index, zm_packet->keyframe, packet_counts[video_stream_id], pre_event_video_packet_count, pktQueue.size()); + Debug(1, + "Deleting a packet with stream index:%d image_index:%d with keyframe:%d, video frames in queue:%d max: %d, queuesize:%zu", + zm_packet->packet.stream_index, + zm_packet->image_index, + zm_packet->keyframe, + packet_counts[video_stream_id], + pre_event_video_packet_count, + pktQueue.size()); delete zm_packet; } // end while return; @@ -276,8 +288,14 @@ void PacketQueue::clearPackets(ZMPacket *add_packet) { continue; } - Debug(1, "Deleting a packet with stream index:%d image_index:%d with keyframe:%d, video frames in queue:%d max: %d, queuesize:%d", - zm_packet->packet.stream_index, zm_packet->image_index, zm_packet->keyframe, packet_counts[video_stream_id], pre_event_video_packet_count, pktQueue.size()); + Debug(1, + "Deleting a packet with stream index:%d image_index:%d with keyframe:%d, video frames in queue:%d max: %d, queuesize:%zu", + zm_packet->packet.stream_index, + zm_packet->image_index, + zm_packet->keyframe, + packet_counts[video_stream_id], + pre_event_video_packet_count, + pktQueue.size()); pktQueue.pop_front(); packet_counts[zm_packet->packet.stream_index] -= 1; delete zm_packet; @@ -289,7 +307,7 @@ void PacketQueue::clearPackets(ZMPacket *add_packet) { } // end voidPacketQueue::clearPackets(ZMPacket* zm_packet) ZMLockedPacket* PacketQueue::popPacket( ) { - Debug(4, "pktQueue size %d", pktQueue.size()); + Debug(4, "pktQueue size %zu", pktQueue.size()); if ( pktQueue.empty() ) { return nullptr; } @@ -328,7 +346,7 @@ ZMLockedPacket* PacketQueue::popPacket( ) { */ unsigned int PacketQueue::clear(unsigned int frames_to_keep, int stream_id) { - Debug(3, "Clearing all but %d frames, queue has %d", frames_to_keep, pktQueue.size()); + Debug(3, "Clearing all but %d frames, queue has %zu", frames_to_keep, pktQueue.size()); if ( pktQueue.empty() ) { return 0; @@ -372,8 +390,8 @@ unsigned int PacketQueue::clear(unsigned int frames_to_keep, int stream_id) { // Else not at beginning, are pointing at packet before the last video packet while ( pktQueue.begin() != it ) { - Debug(4, "Deleting a packet from the front, count is (%d), queue size is %d", - delete_count, pktQueue.size()); + Debug(4, "Deleting a packet from the front, count is (%d), queue size is %zu", + delete_count, pktQueue.size()); zm_packet = pktQueue.front(); for ( std::list::iterator iterators_it = iterators.begin(); @@ -394,7 +412,7 @@ unsigned int PacketQueue::clear(unsigned int frames_to_keep, int stream_id) { delete_count += 1; } // while our iterator is not the first packet - Debug(3, "Deleted %d packets, %d remaining", delete_count, pktQueue.size()); + Debug(3, "Deleted %d packets, %zu remaining", delete_count, pktQueue.size()); return delete_count; } // end unsigned int PacketQueue::clear( unsigned int frames_to_keep, int stream_id ) @@ -446,7 +464,7 @@ unsigned int PacketQueue::clear(struct timeval *duration, int streamId) { timersub(t, duration, &keep_from); ++it; - Debug(3, "Looking for frame before queue keep time with stream id (%d), queue has %d packets", + Debug(3, "Looking for frame before queue keep time with stream id (%d), queue has %zu packets", streamId, pktQueue.size()); for ( ; it != pktQueue.rend(); ++it) { ZMPacket *zm_packet = *it; @@ -456,10 +474,10 @@ unsigned int PacketQueue::clear(struct timeval *duration, int streamId) { and timercmp(zm_packet->timestamp, &keep_from, <=) ) { - Debug(3, "Found frame before keep time with stream index %d at %d.%d", - av_packet->stream_index, - zm_packet->timestamp->tv_sec, - zm_packet->timestamp->tv_usec); + Debug(3, "Found frame before keep time with stream index %d at %" PRIi64 ".%" PRIi64, + av_packet->stream_index, + static_cast(zm_packet->timestamp->tv_sec), + static_cast(zm_packet->timestamp->tv_usec)); break; } } @@ -479,10 +497,10 @@ unsigned int PacketQueue::clear(struct timeval *duration, int streamId) { and (av_packet->stream_index == streamId) ) { - Debug(3, "Found keyframe before start with stream index %d at %d.%d", - av_packet->stream_index, - zm_packet->timestamp->tv_sec, - zm_packet->timestamp->tv_usec ); + Debug(3, "Found keyframe before start with stream index %d at %" PRIi64 ".%" PRIi64, + av_packet->stream_index, + static_cast(zm_packet->timestamp->tv_sec), + static_cast(zm_packet->timestamp->tv_usec)); break; } } @@ -535,7 +553,7 @@ ZMLockedPacket *PacketQueue::get_packet(packetqueue_iterator *it) { return nullptr; Debug(4, "Locking in get_packet using it %p queue end? %d, packet %p", - *it, (*it == pktQueue.end()), *(*it)); + std::addressof(*it), (*it == pktQueue.end()), *(*it)); std::unique_lock lck(mutex); Debug(4, "Have Lock in get_packet"); @@ -544,7 +562,7 @@ ZMLockedPacket *PacketQueue::get_packet(packetqueue_iterator *it) { while (*it == pktQueue.end()) { if (deleting or zm_terminate) return nullptr; - Debug(2, "waiting. Queue size %d it == end? %d", pktQueue.size(), (*it == pktQueue.end())); + Debug(2, "waiting. Queue size %zu it == end? %d", pktQueue.size(), (*it == pktQueue.end())); condition.wait(lck); } if (deleting or zm_terminate) @@ -556,7 +574,7 @@ ZMLockedPacket *PacketQueue::get_packet(packetqueue_iterator *it) { return nullptr; } Debug(4, "get_packet using it %p locking index %d, packet %p", - *it, p->image_index, p); + std::addressof(*it), p->image_index, p); // Packets are only deleted by packetqueue, so lock must be held. // We shouldn't have to trylock. Someone else might hold the lock but not for long @@ -579,14 +597,14 @@ void PacketQueue::unlock(ZMLockedPacket *lp) { } bool PacketQueue::increment_it(packetqueue_iterator *it) { - Debug(2, "Incrementing %p, queue size %d, end? %d", it, pktQueue.size(), ((*it) == pktQueue.end())); + Debug(2, "Incrementing %p, queue size %zu, end? %d", it, pktQueue.size(), ((*it) == pktQueue.end())); if ((*it) == pktQueue.end() or deleting) { return false; } std::unique_lock lck(mutex); ++(*it); if (*it != pktQueue.end()) { - Debug(2, "Incrementing %p, %p still not at end %p, so returning true", it, *it, pktQueue.end()); + Debug(2, "Incrementing %p, %p still not at end, so returning true", it, std::addressof(*it)); return true; } Debug(2, "At end"); @@ -595,7 +613,7 @@ bool PacketQueue::increment_it(packetqueue_iterator *it) { // Increment it only considering packets for a given stream bool PacketQueue::increment_it(packetqueue_iterator *it, int stream_id) { - Debug(2, "Incrementing %p, queue size %d, end? %d", it, pktQueue.size(), (*it == pktQueue.end())); + Debug(2, "Incrementing %p, queue size %zu, end? %d", it, pktQueue.size(), (*it == pktQueue.end())); if ( *it == pktQueue.end() ) { return false; } @@ -696,7 +714,7 @@ packetqueue_iterator * PacketQueue::get_video_it(bool wait) { if ( wait ) { while ( ((! pktQueue.size()) or (*it == pktQueue.end())) and !zm_terminate and !deleting ) { - Debug(2, "waiting for packets in queue. Queue size %d it == end? %d", pktQueue.size(), ( *it == pktQueue.end() ) ); + Debug(2, "waiting for packets in queue. Queue size %zu it == end? %d", pktQueue.size(), (*it == pktQueue.end())); condition.wait(lck); *it = pktQueue.begin(); } @@ -749,7 +767,7 @@ bool PacketQueue::is_there_an_iterator_pointing_to_packet(ZMPacket *zm_packet) { if ( *iterator_it == pktQueue.end() ) { continue; } - Debug(4, "Checking iterator %p == packet ? %d", (*iterator_it), ( *(*iterator_it) == zm_packet )); + Debug(4, "Checking iterator %p == packet ? %d", std::addressof(*iterator_it), ( *(*iterator_it) == zm_packet )); // Have to check each iterator and make sure it doesn't point to the packet we are about to delete if ( *(*iterator_it) == zm_packet ) { return true; diff --git a/src/zm_remote_camera_http.cpp b/src/zm_remote_camera_http.cpp index 7f80a49b9..6eab03fb8 100644 --- a/src/zm_remote_camera_http.cpp +++ b/src/zm_remote_camera_http.cpp @@ -211,7 +211,9 @@ int RemoteCameraHttp::ReadData(Buffer &buffer, unsigned int bytes_expected) { int n_found = select(sd+1, &rfds, nullptr, nullptr, &temp_timeout); if (n_found == 0) { - Debug(1, "Select timed out timeout was %d secs %d usecs", temp_timeout.tv_sec, temp_timeout.tv_usec); + Debug(1, "Select timed out timeout was %" PRIi64 " secs %" PRIi64" usecs", + static_cast(temp_timeout.tv_sec), + static_cast(temp_timeout.tv_usec)); int error = 0; socklen_t len = sizeof(error); int retval = getsockopt(sd, SOL_SOCKET, SO_ERROR, &error, &len); diff --git a/src/zm_remote_camera_rtsp.cpp b/src/zm_remote_camera_rtsp.cpp index 7cf59b64d..78c947faa 100644 --- a/src/zm_remote_camera_rtsp.cpp +++ b/src/zm_remote_camera_rtsp.cpp @@ -202,7 +202,7 @@ int RemoteCameraRtsp::PrimeCapture() { #endif if ( (unsigned int)pSize != imagesize ) { - Fatal("Image size mismatch. Required: %d Available: %d", pSize, imagesize); + Fatal("Image size mismatch. Required: %d Available: %llu", pSize, imagesize); } return 1; diff --git a/src/zm_rtp_ctrl.cpp b/src/zm_rtp_ctrl.cpp index 7185ef6aa..9d74359fc 100644 --- a/src/zm_rtp_ctrl.cpp +++ b/src/zm_rtp_ctrl.cpp @@ -289,15 +289,14 @@ void RtpCtrlThread::Run() { unsigned char *bufferPtr = buffer; bufferPtr += generateRr( bufferPtr, sizeof(buffer)-(bufferPtr-buffer) ); bufferPtr += generateSdes( bufferPtr, sizeof(buffer)-(bufferPtr-buffer) ); - Debug( 3, "Preventing timeout by sending %zd bytes on sd %d. Time since last receive: %d", - bufferPtr-buffer, rtpCtrlServer.getWriteDesc(), ( now-last_receive) ); + Debug(3, "Preventing timeout by sending %zd bytes on sd %d. Time since last receive: %" PRIi64, + bufferPtr - buffer, rtpCtrlServer.getWriteDesc(), static_cast(now - last_receive)); if ( (nBytes = rtpCtrlServer.send(buffer, bufferPtr-buffer)) < 0 ) Error("Unable to send: %s", strerror(errno)); timeout = true; continue; } else { - //Error( "RTCP timed out" ); - Debug(1, "RTCP timed out. Time since last receive: %d", ( now-last_receive) ); + Debug(1, "RTCP timed out. Time since last receive: %" PRIi64, static_cast(now - last_receive)); continue; //break; } diff --git a/src/zm_rtp_source.cpp b/src/zm_rtp_source.cpp index 0136dfb44..ff69a6069 100644 --- a/src/zm_rtp_source.cpp +++ b/src/zm_rtp_source.cpp @@ -165,14 +165,12 @@ void RtpSource::updateJitter( const RtpDataHeader *header ) { uint32_t localTimeRtp = mBaseTimeRtp + uint32_t(tvDiffSec(mBaseTimeReal) * mRtpFactor); uint32_t packetTransit = localTimeRtp - ntohl(header->timestampN); - Debug(5, "Delta rtp = %.6f\n" - "Local RTP time = %x", - "Packet RTP time = %x", - "Packet transit RTP time = %x", - tvDiffSec(mBaseTimeReal), - localTimeRtp, - ntohl(header->timestampN), - packetTransit); + Debug(5, + "Delta rtp = %.6f\n Local RTP time = %x Packet RTP time = %x Packet transit RTP time = %x", + tvDiffSec(mBaseTimeReal), + localTimeRtp, + ntohl(header->timestampN), + packetTransit); if ( mTransit > 0 ) { // Jitter @@ -239,19 +237,13 @@ void RtpSource::updateRtcpStats() { mLostFraction = (lostInterval << 8) / expectedInterval; Debug(5, - "Expected packets = %d\n", - "Lost packets = %d\n", - "Expected interval = %d\n", - "Received interval = %d\n", - "Lost interval = %d\n", - "Lost fraction = %d\n", - - mExpectedPackets, - mLostPackets, - expectedInterval, - receivedInterval, - lostInterval, - mLostFraction); + "Expected packets = %d\n Lost packets = %d\n Expected interval = %d\n Received interval = %d\n Lost interval = %d\n Lost fraction = %d\n", + mExpectedPackets, + mLostPackets, + expectedInterval, + receivedInterval, + lostInterval, + mLostFraction); } bool RtpSource::handlePacket(const unsigned char *packet, size_t packetLen) { diff --git a/src/zm_rtsp.cpp b/src/zm_rtsp.cpp index 0966178e9..4efe0a43b 100644 --- a/src/zm_rtsp.cpp +++ b/src/zm_rtsp.cpp @@ -173,7 +173,7 @@ RtspThread::RtspThread( mNeedAuth = false; StringVector parts = Split(auth, ":"); - Debug(2, "# of auth parts %d", parts.size()); + Debug(2, "# of auth parts %zu", parts.size()); if ( parts.size() > 1 ) mAuthenticator = new zm::Authenticator(parts[0], parts[1]); else @@ -372,7 +372,7 @@ void RtspThread::Run() { mSessDesc = new SessionDescriptor( mUrl, sdp ); mFormatContext = mSessDesc->generateFormatContext(); } catch ( const Exception &e ) { - Error(e.getMessage().c_str()); + Error("%s", e.getMessage().c_str()); return; } @@ -589,8 +589,12 @@ void RtspThread::Run() { while (!mTerminate) { now = time(nullptr); // Send a keepalive message if the server supports this feature and we are close to the timeout expiration - Debug(5, "sendkeepalive %d, timeout %d, now: %d last: %d since: %d", - sendKeepalive, timeout, now, lastKeepalive, (now-lastKeepalive) ); + Debug(5, "sendkeepalive %d, timeout %d, now: %" PRIi64 " last: %" PRIi64 " since: %" PRIi64, + sendKeepalive, + timeout, + static_cast(now), + static_cast(lastKeepalive), + static_cast(now - lastKeepalive)); if ( sendKeepalive && (timeout > 0) && ((now-lastKeepalive) > (timeout-5)) ) { if ( !sendCommand( message ) ) return; @@ -709,7 +713,12 @@ void RtspThread::Run() { // FIXME: Is this really necessary when using tcp ? now = time(nullptr); // Send a keepalive message if the server supports this feature and we are close to the timeout expiration -Debug(5, "sendkeepalive %d, timeout %d, now: %d last: %d since: %d", sendKeepalive, timeout, now, lastKeepalive, (now-lastKeepalive) ); + Debug(5, "sendkeepalive %d, timeout %d, now: %" PRIi64 " last: %" PRIi64 " since: %" PRIi64, + sendKeepalive, + timeout, + static_cast(now), + static_cast(lastKeepalive), + static_cast(now - lastKeepalive)); if ( sendKeepalive && (timeout > 0) && ((now-lastKeepalive) > (timeout-5)) ) { if ( !sendCommand( message ) ) diff --git a/src/zm_rtsp_auth.cpp b/src/zm_rtsp_auth.cpp index 28ebd6a6c..4a1c6b2e2 100644 --- a/src/zm_rtsp_auth.cpp +++ b/src/zm_rtsp_auth.cpp @@ -205,7 +205,7 @@ void Authenticator::checkAuthResponse(const std::string &response) { if ( strncasecmp(lines[i].c_str(), authenticate_match, authenticate_match_len) == 0 ) { authLine = lines[i]; - Debug(2, "Found auth line at %d:", i); + Debug(2, "Found auth line at %zu:", i); //break; } } diff --git a/src/zm_rtsp_server_fifo_h264_source.cpp b/src/zm_rtsp_server_fifo_h264_source.cpp index 39bf22cf7..9963ea26c 100644 --- a/src/zm_rtsp_server_fifo_h264_source.cpp +++ b/src/zm_rtsp_server_fifo_h264_source.cpp @@ -196,7 +196,7 @@ unsigned char * H26X_ZoneMinderFifoSource::findMarker( // extract a frame unsigned char* H26X_ZoneMinderFifoSource::extractFrame(unsigned char* frame, size_t& size, size_t& outsize) { unsigned char *outFrame = nullptr; - Debug(4, "ExtractFrame: %p %d", frame, size); + Debug(4, "ExtractFrame: %p %zu", frame, size); outsize = 0; size_t markerLength = 0; size_t endMarkerLength = 0; @@ -205,7 +205,7 @@ unsigned char* H26X_ZoneMinderFifoSource::extractFrame(unsigned char* frame, si if ( size >= 3 ) startFrame = this->findMarker(frame, size, markerLength); if ( startFrame != nullptr ) { - Debug(4, "startFrame: %p marker Length %d", startFrame, markerLength); + Debug(4, "startFrame: %p marker Length %zu", startFrame, markerLength); m_frameType = startFrame[markerLength]; int remainingSize = size-(startFrame-frame+markerLength); @@ -213,7 +213,7 @@ unsigned char* H26X_ZoneMinderFifoSource::extractFrame(unsigned char* frame, si if ( remainingSize > 3 ) { endFrame = this->findMarker(startFrame+markerLength, remainingSize, endMarkerLength); } - Debug(4, "endFrame: %p marker Length %d, remaining size %d", endFrame, endMarkerLength, remainingSize); + Debug(4, "endFrame: %p marker Length %zu, remaining size %d", endFrame, endMarkerLength, remainingSize); if ( m_keepMarker ) { size -= startFrame-frame; @@ -229,9 +229,9 @@ unsigned char* H26X_ZoneMinderFifoSource::extractFrame(unsigned char* frame, si outsize = size; } size -= outsize; - Debug(4, "Have frame type: %d size %d, keepmarker %d", m_frameType, outsize, m_keepMarker); + Debug(4, "Have frame type: %d size %zu, keepmarker %d", m_frameType, outsize, m_keepMarker); } else if ( size >= sizeof(H264shortmarker) ) { - Info("No marker found size %d", size); + Info("No marker found size %zu", size); } return outFrame; diff --git a/src/zm_rtsp_server_fifo_source.cpp b/src/zm_rtsp_server_fifo_source.cpp index 397f0ee42..6a6066bcf 100644 --- a/src/zm_rtsp_server_fifo_source.cpp +++ b/src/zm_rtsp_server_fifo_source.cpp @@ -78,7 +78,7 @@ void ZoneMinderFifoSource::WriteRun() { if (nal) { if (1 and (nal->size() > maxNalSize)) { - Debug(1, "SPlitting NAL %d", nal->size()); + Debug(1, "Splitting NAL %zu", nal->size()); size_t nalRemaining = nal->size(); u_int8_t *nalSrc = nal->buffer(); @@ -123,9 +123,9 @@ void ZoneMinderFifoSource::WriteRun() { nalSrc += fuNalSize; nal_count += 1; } - Debug(1, "Sending %d NALs @ %d and 1 @ %d", nal_count, maxNalSize, fuNal.size()); + Debug(1, "Sending %d NALs @ %zu and 1 @ %zu", nal_count, maxNalSize, fuNal.size()); } else { - Debug(3, "Pushing nal of size %d at %" PRId64, nal->size(), nal->pts()); + Debug(3, "Pushing nal of size %zu at %" PRId64, nal->size(), nal->pts()); PushFrame(nal->buffer(), nal->size(), nal->pts()); } delete nal; @@ -214,8 +214,8 @@ int ZoneMinderFifoSource::getNextFrame() { return 0; } if (header_start != m_buffer) { - Debug(4, "ZM Packet didn't start at beginning of buffer %u. %c%c", - header_start-m_buffer.head(), m_buffer[0], m_buffer[1]); + Debug(4, "ZM Packet didn't start at beginning of buffer %ld. %c%c", + header_start - m_buffer.head(), m_buffer[0], m_buffer[1]); } // read_into may invalidate packet_start @@ -244,7 +244,10 @@ int ZoneMinderFifoSource::getNextFrame() { size_t bytes_remaining = data_size; std::list< std::pair > framesList = this->splitFrames(packet_start, bytes_remaining); m_buffer.consume(data_size+header_size); - Debug(3, "Got %d frames, consuming %d bytes, remaining %d", framesList.size(), data_size+header_size, bytes_remaining); + Debug(3, "Got %zu frames, consuming %d bytes, remaining %zu", + framesList.size(), + data_size + header_size, + bytes_remaining); { std::unique_lock lck(mutex_); diff --git a/src/zm_rtsp_server_frame.h b/src/zm_rtsp_server_frame.h index e4745a731..363ac7995 100644 --- a/src/zm_rtsp_server_frame.h +++ b/src/zm_rtsp_server_frame.h @@ -53,15 +53,16 @@ class NAL_Frame { } return false; } + void debug() { - if ( m_size <= 4 ) { - Debug(1, "NAL: %d: %.2x %.2x %.2x %.2x", m_size, - m_buffer[0], m_buffer[1], m_buffer[2], m_buffer[3]); + if (m_size <= 4) { + Debug(1, "NAL: %zu: %.2x %.2x %.2x %.2x", m_size, + m_buffer[0], m_buffer[1], m_buffer[2], m_buffer[3]); } else { - Debug(1, "NAL: %d: %.2x %.2x %.2x %.2x %.2x %.2x %.2x %.2x ", m_size, - m_buffer[0], m_buffer[1], m_buffer[2], m_buffer[3], - m_buffer[4], m_buffer[5], m_buffer[6], m_buffer[7] - ); + Debug(1, "NAL: %zu: %.2x %.2x %.2x %.2x %.2x %.2x %.2x %.2x ", m_size, + m_buffer[0], m_buffer[1], m_buffer[2], m_buffer[3], + m_buffer[4], m_buffer[5], m_buffer[6], m_buffer[7] + ); } } diff --git a/src/zm_signal.cpp b/src/zm_signal.cpp index 2d1315049..9a92b5eac 100644 --- a/src/zm_signal.cpp +++ b/src/zm_signal.cpp @@ -104,8 +104,7 @@ RETSIGTYPE zm_die_handler(int signal) } free(messages); - Info("Backtrace complete, please execute the following command for more information"); - Info(cmd); + Info("Backtrace complete, please execute the following command for more information: %s", cmd); #endif // ( !defined(ZM_NO_CRASHTRACE) && HAVE_DECL_BACKTRACE && HAVE_DECL_BACKTRACE_SYMBOLS ) #endif // (defined(__i386__) || defined(__x86_64__) exit(signal); diff --git a/src/zm_stream.cpp b/src/zm_stream.cpp index 30f8e40d3..0968c9514 100644 --- a/src/zm_stream.cpp +++ b/src/zm_stream.cpp @@ -359,7 +359,7 @@ void StreamBase::openComms() { // Unlink before bind, in case it already exists unlink(loc_sock_path); if ( sizeof(loc_addr.sun_path) < length ) { - Error("Not enough space %d in loc_addr.sun_path for socket file %s", sizeof(loc_addr.sun_path), loc_sock_path); + Error("Not enough space %zu in loc_addr.sun_path for socket file %s", sizeof(loc_addr.sun_path), loc_sock_path); } strncpy(loc_addr.sun_path, loc_sock_path, sizeof(loc_addr.sun_path)); diff --git a/src/zm_swscale.cpp b/src/zm_swscale.cpp index 2390155c2..b5cf6eded 100644 --- a/src/zm_swscale.cpp +++ b/src/zm_swscale.cpp @@ -124,7 +124,7 @@ int SWScale::Convert( unsigned int new_width, unsigned int new_height ) { - Debug(1, "Convert: in_buffer %p in_buffer_size %d out_buffer %p size %d width %d height %d width %d height %d %d %d", + Debug(1, "Convert: in_buffer %p in_buffer_size %zu out_buffer %p size %zu width %d height %d width %d height %d %d %d", in_buffer, in_buffer_size, out_buffer, out_buffer_size, width, height, new_width, new_height, in_pf, out_pf); /* Parameter checking */ @@ -163,12 +163,19 @@ int SWScale::Convert( /* Check the buffer sizes */ size_t needed_insize = GetBufferSize(in_pf, width, height); if ( needed_insize > in_buffer_size ) { - Debug(1, "The input buffer size does not match the expected size for the input format. Required: %d for %dx%d %d Available: %d", - needed_insize, width, height, in_pf, in_buffer_size); + Debug(1, + "The input buffer size does not match the expected size for the input format. Required: %zu for %dx%d %d Available: %zu", + needed_insize, + width, + height, + in_pf, + in_buffer_size); } size_t needed_outsize = GetBufferSize(out_pf, new_width, new_height); if ( needed_outsize > out_buffer_size ) { - Error("The output buffer is undersized for the output format. Required: %d Available: %d", needed_outsize, out_buffer_size); + Error("The output buffer is undersized for the output format. Required: %zu Available: %zu", + needed_outsize, + out_buffer_size); return -5; } diff --git a/src/zm_user.cpp b/src/zm_user.cpp index e35cb7e5c..254663a04 100644 --- a/src/zm_user.cpp +++ b/src/zm_user.cpp @@ -232,7 +232,7 @@ User *zmLoadAuthUser(const char *auth, bool use_remote_addr) { Warning("No value set for ZM_AUTH_HASH_TTL. Defaulting to 2."); hours = 2; } else { - Debug(1, "AUTH_HASH_TTL is %d, time is %d", hours, now); + Debug(1, "AUTH_HASH_TTL is %d, time is %" PRIi64, hours, static_cast(now)); } char auth_key[512] = ""; char auth_md5[32+1] = ""; diff --git a/src/zm_videostore.cpp b/src/zm_videostore.cpp index c2d7a20d5..4e33f234e 100644 --- a/src/zm_videostore.cpp +++ b/src/zm_videostore.cpp @@ -670,9 +670,7 @@ VideoStore::~VideoStore() { bool VideoStore::setup_resampler() { #if !defined(HAVE_LIBSWRESAMPLE) && !defined(HAVE_LIBAVRESAMPLE) - Error( - "Not built with resample library. " - "Cannot do audio conversion to AAC"); + Error("%s", "Not built with resample library. Cannot do audio conversion to AAC"); return false; #else int ret; @@ -727,7 +725,7 @@ bool VideoStore::setup_resampler() { audio_out_ctx->sample_fmt = audio_in_ctx->sample_fmt; #if LIBAVCODEC_VERSION_CHECK(56, 8, 0, 60, 100) if ( !audio_out_ctx->channel_layout ) { - Debug(3, "Correcting channel layout from (%d) to (%d)", + Debug(3, "Correcting channel layout from (%" PRIi64 ") to (%" PRIi64 ")", audio_out_ctx->channel_layout, av_get_default_channel_layout(audio_out_ctx->channels) ); @@ -800,29 +798,26 @@ bool VideoStore::setup_resampler() { audio_out_ctx->time_base.num, audio_out_ctx->time_base.den); Debug(1, - "Audio in bit_rate (%d) sample_rate(%d) channels(%d) fmt(%d) " - "layout(%d) frame_size(%d)", + "Audio in bit_rate (%" AV_PACKET_DURATION_FMT ") sample_rate(%d) channels(%d) fmt(%d) layout(%" PRIi64 ") frame_size(%d)", audio_in_ctx->bit_rate, audio_in_ctx->sample_rate, audio_in_ctx->channels, audio_in_ctx->sample_fmt, audio_in_ctx->channel_layout, audio_in_ctx->frame_size); Debug(1, - "Audio out context bit_rate (%d) sample_rate(%d) channels(%d) fmt(%d) " - "layout(%d) frame_size(%d)", - audio_out_ctx->bit_rate, audio_out_ctx->sample_rate, - audio_out_ctx->channels, audio_out_ctx->sample_fmt, - audio_out_ctx->channel_layout, audio_out_ctx->frame_size); + "Audio out context bit_rate (%" AV_PACKET_DURATION_FMT ") sample_rate(%d) channels(%d) fmt(%d) layout(% " PRIi64 ") frame_size(%d)", + audio_out_ctx->bit_rate, audio_out_ctx->sample_rate, + audio_out_ctx->channels, audio_out_ctx->sample_fmt, + audio_out_ctx->channel_layout, audio_out_ctx->frame_size); #if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0) Debug(1, - "Audio out stream bit_rate (%d) sample_rate(%d) channels(%d) fmt(%d) " - "layout(%d) frame_size(%d)", - audio_out_stream->codecpar->bit_rate, audio_out_stream->codecpar->sample_rate, - audio_out_stream->codecpar->channels, audio_out_stream->codecpar->format, - audio_out_stream->codecpar->channel_layout, audio_out_stream->codecpar->frame_size); + "Audio out stream bit_rate (%" PRIi64 ") sample_rate(%d) channels(%d) fmt(%d) layout(%" PRIi64 ") frame_size(%d)", + audio_out_stream->codecpar->bit_rate, audio_out_stream->codecpar->sample_rate, + audio_out_stream->codecpar->channels, audio_out_stream->codecpar->format, + audio_out_stream->codecpar->channel_layout, audio_out_stream->codecpar->frame_size); #else Debug(1, "Audio out bit_rate (%d) sample_rate(%d) channels(%d) fmt(%d) " - "layout(%d) frame_size(%d)", + "layout(%" PRIi64 ") frame_size(%d)", audio_out_stream->codec->bit_rate, audio_out_stream->codec->sample_rate, audio_out_stream->codec->channels, audio_out_stream->codec->sample_fmt, audio_out_stream->codec->channel_layout, audio_out_stream->codec->frame_size); @@ -1021,17 +1016,24 @@ int VideoStore::writeVideoFramePacket(ZMPacket *zm_packet) { int64_t in_pts = zm_packet->timestamp->tv_sec * (uint64_t)1000000 + zm_packet->timestamp->tv_usec; if ( !video_first_pts ) { video_first_pts = in_pts; - Debug(2, "No video_first_pts, set to (%" PRId64 ") secs(%d) usecs(%d)", - video_first_pts, zm_packet->timestamp->tv_sec, zm_packet->timestamp->tv_usec); + Debug(2, "No video_first_pts, set to (%" PRId64 ") secs(%" PRIi64 ") usecs(%" PRIi64 ")", + video_first_pts, + static_cast(zm_packet->timestamp->tv_sec), + static_cast(zm_packet->timestamp->tv_usec)); zm_packet->out_frame->pts = 0; } else { uint64_t useconds = in_pts - video_first_pts; zm_packet->out_frame->pts = av_rescale_q(useconds, AV_TIME_BASE_Q, video_out_ctx->time_base); - Debug(2, " Setting pts for frame(%d) to (%" PRId64 ") from (start %" PRIu64 " - %" PRIu64 " - secs(%d) usecs(%d) @ %d/%d", - frame_count, zm_packet->out_frame->pts, video_first_pts, useconds, zm_packet->timestamp->tv_sec, zm_packet->timestamp->tv_usec, - video_out_ctx->time_base.num, - video_out_ctx->time_base.den - ); + Debug(2, + "Setting pts for frame(%d) to (%" PRId64 ") from (start %" PRIu64 " - %" PRIu64 " - secs(%" PRIi64 ") usecs(%" PRIi64 ") @ %d/%d", + frame_count, + zm_packet->out_frame->pts, + video_first_pts, + useconds, + static_cast(zm_packet->timestamp->tv_sec), + static_cast(zm_packet->timestamp->tv_usec), + video_out_ctx->time_base.num, + video_out_ctx->time_base.den); } av_init_packet(&opkt); diff --git a/src/zmc.cpp b/src/zmc.cpp index 670316791..a08afb76d 100644 --- a/src/zmc.cpp +++ b/src/zmc.cpp @@ -214,7 +214,7 @@ int main(int argc, char *argv[]) { Error("No monitors found"); exit(-1); } else { - Debug(2, "%d monitors loaded", monitors.size()); + Debug(2, "%zu monitors loaded", monitors.size()); } Info("Starting Capture version %s", ZM_VERSION); @@ -294,20 +294,20 @@ int main(int argc, char *argv[]) { monitors[i]->CheckAction(); if (monitors[i]->PreCapture() < 0) { - Error("Failed to pre-capture monitor %d %d (%d/" SZFMTD ")", - monitors[i]->Id(), monitors[i]->Name(), i+1, monitors.size()); + Error("Failed to pre-capture monitor %d %s (%zu/%zu)", + monitors[i]->Id(), monitors[i]->Name(), i + 1, monitors.size()); result = -1; break; } if (monitors[i]->Capture() < 0) { - Error("Failed to capture image from monitor %d %s (%d/" SZFMTD ")", - monitors[i]->Id(), monitors[i]->Name(), i+1, monitors.size()); + Error("Failed to capture image from monitor %d %s (%zu/%zu)", + monitors[i]->Id(), monitors[i]->Name(), i + 1, monitors.size()); result = -1; break; } if (monitors[i]->PostCapture() < 0) { - Error("Failed to post-capture monitor %d %s (%d/" SZFMTD ")", - monitors[i]->Id(), monitors[i]->Name(), i+1, monitors.size()); + Error("Failed to post-capture monitor %d %s (%zu/%zu)", + monitors[i]->Id(), monitors[i]->Name(), i + 1, monitors.size()); result = -1; break; } @@ -322,13 +322,15 @@ int main(int argc, char *argv[]) { // You have to add back in the previous sleep time sleep_time = delay - (delta_time.delta - sleep_time); - Debug(4, "Sleep time is %d from now:%d.%d last:%d.%d delta %d delay: %d", - sleep_time, - now.tv_sec, now.tv_usec, - last_capture_times[i].tv_sec, last_capture_times[i].tv_usec, - delta_time.delta, - delay - ); + Debug(4, + "Sleep time is %d from now: %" PRIi64 ".%" PRIi64" last: %" PRIi64 ".% " PRIi64 " delta %lu delay: %d", + sleep_time, + static_cast(now.tv_sec), + static_cast(now.tv_usec), + static_cast(last_capture_times[i].tv_sec), + static_cast(last_capture_times[i].tv_usec), + delta_time.delta, + delay); if (sleep_time > 0) { Debug(4, "usleeping (%d)", sleep_time); diff --git a/src/zmu.cpp b/src/zmu.cpp index b4ef32083..acc4b21dc 100644 --- a/src/zmu.cpp +++ b/src/zmu.cpp @@ -734,7 +734,7 @@ int main(int argc, char *argv[]) { if (!result) { exit_zmu(-1); } - Debug(1, "Got %d monitors", mysql_num_rows(result)); + Debug(1, "Got %" PRIu64 " monitors", static_cast(mysql_num_rows(result))); printf("%4s%5s%6s%9s%14s%6s%6s%8s%8s\n", "Id", "Func", "State", "TrgState", "LastImgTim", "RdIdx", "WrIdx", "LastEvt", "FrmRate"); for ( int i = 0; MYSQL_ROW dbrow = mysql_fetch_row(result); i++ ) { diff --git a/tests/zm_font.cpp b/tests/zm_font.cpp index 84300469a..d862c3291 100644 --- a/tests/zm_font.cpp +++ b/tests/zm_font.cpp @@ -147,7 +147,7 @@ TEST_CASE("ZmFont: load font file") { SECTION("valid file") { REQUIRE(font.LoadFontFile("data/fonts/04_valid.zmfnt") == FontLoadError::kOk); - uint8 var_idx = GENERATE(range(static_cast(0), kNumFontSizes)); + uint8 var_idx = GENERATE(range(static_cast::type>(0), kNumFontSizes)); FontVariant variant = font.GetFontVariant(var_idx); REQUIRE(variant.GetCharHeight() == 10 + var_idx); REQUIRE(variant.GetCharWidth() == 10 + var_idx);