From 0f5df0c739eaed0558515cea472a3e05751bb8d3 Mon Sep 17 00:00:00 2001 From: Peter Keresztes Schmidt Date: Tue, 2 Feb 2021 17:51:22 +0100 Subject: [PATCH 1/3] zm: Typedef C++11 int types to make them easier to use In order to clearly state the intended length of an integer variable all usages of other integer types (short int, int, long int, ...) should be converted. --- src/zm.h | 6 +++--- src/zm_define.h | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 src/zm_define.h diff --git a/src/zm.h b/src/zm.h index 60fa67711..f22bc5b2e 100644 --- a/src/zm.h +++ b/src/zm.h @@ -21,6 +21,8 @@ #ifndef ZM_H #define ZM_H +#include "zm_define.h" + #include "zm_config.h" #include "zm_signal.h" #ifdef SOLARIS @@ -29,10 +31,8 @@ #endif #include "zm_logger.h" -#include - #include -extern const char* self; +extern const char *self; #endif // ZM_H diff --git a/src/zm_define.h b/src/zm_define.h new file mode 100644 index 000000000..a3372ddba --- /dev/null +++ b/src/zm_define.h @@ -0,0 +1,33 @@ +/* + * This file is part of the ZoneMinder Project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#ifndef ZONEMINDER_SRC_ZM_DEFINE_H_ +#define ZONEMINDER_SRC_ZM_DEFINE_H_ + +#include + +typedef std::int64_t int64; +typedef std::int32_t int32; +typedef std::int16_t int16; +typedef std::int8_t int8; +typedef std::uint64_t uint64; +typedef std::uint32_t uint32; +typedef std::uint16_t uint16; +typedef std::uint8_t uint8; + +#endif // ZONEMINDER_SRC_ZM_DEFINE_H_ From e09fa1bebf6451af0b1e0c2cb3889340cc779a32 Mon Sep 17 00:00:00 2001 From: Peter Keresztes Schmidt Date: Tue, 2 Feb 2021 19:56:11 +0100 Subject: [PATCH 2/3] Remove includes of Instead of including directly, zm_define.h should be used to get the typedef'ed types as well. --- src/zm_event.cpp | 5 ++--- src/zm_ffmpeg.cpp | 1 - src/zm_font.h | 3 ++- src/zm_monitor.cpp | 1 - src/zm_videostore.cpp | 1 - src/zm_zone.cpp | 1 - src/zms.cpp | 1 - src/zmu.cpp | 1 - 8 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/zm_event.cpp b/src/zm_event.cpp index 23d810e78..248cffdaa 100644 --- a/src/zm_event.cpp +++ b/src/zm_event.cpp @@ -27,7 +27,6 @@ #include #include #include -#include #include "zm.h" #include "zm_db.h" @@ -692,8 +691,8 @@ void Event::AddFrame(Image *image, struct timeval timestamp, int score, Image *a // The idea is to write out 1/sec frame_data.push(new Frame(id, frames, frame_type, timestamp, delta_time, score)); double fps = monitor->get_capture_fps(); - if ( write_to_db - or + if ( write_to_db + or (frame_data.size() >= MAX_DB_FRAMES) or (frame_type == BULK) diff --git a/src/zm_ffmpeg.cpp b/src/zm_ffmpeg.cpp index 005e8cdd6..a3cf383ca 100644 --- a/src/zm_ffmpeg.cpp +++ b/src/zm_ffmpeg.cpp @@ -16,7 +16,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include #include "zm_ffmpeg.h" #include "zm_image.h" diff --git a/src/zm_font.h b/src/zm_font.h index 4753129ff..2790ea4e1 100644 --- a/src/zm_font.h +++ b/src/zm_font.h @@ -1,7 +1,8 @@ #ifndef ZM_FONT_H #define ZM_FONT_H -#include +#include "zm_define.h" + #include #define NUM_FONT_SIZES 4 diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 5b448424e..224145ed8 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -21,7 +21,6 @@ #include #include #include -#include #include "zm.h" #include "zm_db.h" diff --git a/src/zm_videostore.cpp b/src/zm_videostore.cpp index ea85af8d1..fc49ed60a 100644 --- a/src/zm_videostore.cpp +++ b/src/zm_videostore.cpp @@ -26,7 +26,6 @@ #include #include -#include extern "C" { #include "libavutil/time.h" diff --git a/src/zm_zone.cpp b/src/zm_zone.cpp index 047432f4e..a057684ae 100644 --- a/src/zm_zone.cpp +++ b/src/zm_zone.cpp @@ -18,7 +18,6 @@ // #define __STDC_FORMAT_MACROS 1 -#include #include "zm.h" #include "zm_db.h" #include "zm_zone.h" diff --git a/src/zms.cpp b/src/zms.cpp index 5f970cd1a..652b87350 100644 --- a/src/zms.cpp +++ b/src/zms.cpp @@ -19,7 +19,6 @@ #include #include -#include #include #include "zm.h" diff --git a/src/zmu.cpp b/src/zmu.cpp index 6fce000b3..dd14aacb8 100644 --- a/src/zmu.cpp +++ b/src/zmu.cpp @@ -87,7 +87,6 @@ Options for use with monitors: */ #include -#include #include "zm.h" #include "zm_db.h" From 0c5c720e4be5c7ca3f9cdd6d7edf965570548409 Mon Sep 17 00:00:00 2001 From: Peter Keresztes Schmidt Date: Tue, 2 Feb 2021 20:04:06 +0100 Subject: [PATCH 3/3] Remove includes of Instead of including the deprecated header , zm_define.h should be used. --- src/zm_ffmpeg.h | 5 +++-- src/zm_logger.h | 6 +++--- src/zm_monitor.h | 1 - src/zm_rtp_data.h | 5 ++--- src/zm_rtp_source.h | 2 +- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/zm_ffmpeg.h b/src/zm_ffmpeg.h index b017380b6..aae8710da 100644 --- a/src/zm_ffmpeg.h +++ b/src/zm_ffmpeg.h @@ -19,8 +19,9 @@ #ifndef ZM_FFMPEG_H #define ZM_FFMPEG_H -#include -#include "zm.h" + +#include "zm_config.h" +#include "zm_define.h" extern "C" { diff --git a/src/zm_logger.h b/src/zm_logger.h index ad1ac398b..647de1f1a 100644 --- a/src/zm_logger.h +++ b/src/zm_logger.h @@ -21,7 +21,9 @@ #define ZM_LOGGER_H #include "zm_config.h" -#include +#include "zm_define.h" +#include "zm_thread.h" + #include #include #include @@ -30,8 +32,6 @@ #endif // HAVE_SYS_SYSCALL_H #include -#include "zm_thread.h" - class Logger { public: enum { diff --git a/src/zm_monitor.h b/src/zm_monitor.h index 26646b0de..219e9437a 100644 --- a/src/zm_monitor.h +++ b/src/zm_monitor.h @@ -44,7 +44,6 @@ class Monitor; #include "zm_image_analyser.h" #include -#include #define SIGNAL_CAUSE "Signal" #define MOTION_CAUSE "Motion" diff --git a/src/zm_rtp_data.h b/src/zm_rtp_data.h index dae449ea5..0e05df84b 100644 --- a/src/zm_rtp_data.h +++ b/src/zm_rtp_data.h @@ -20,10 +20,9 @@ #ifndef ZM_RTP_DATA_H #define ZM_RTP_DATA_H -#include "zm_thread.h" #include "zm_buffer.h" - -#include +#include "zm_define.h" +#include "zm_thread.h" class RtspThread; class RtpSource; diff --git a/src/zm_rtp_source.h b/src/zm_rtp_source.h index f91ba20f7..4869d405c 100644 --- a/src/zm_rtp_source.h +++ b/src/zm_rtp_source.h @@ -21,11 +21,11 @@ #define ZM_RTP_SOURCE_H #include "zm_buffer.h" +#include "zm_define.h" #include "zm_ffmpeg.h" #include "zm_thread.h" #include -#include #include #if HAVE_LIBAVCODEC