From 50f2747bb4dac3d9ff7892aeb5880b7db28d3171 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 15 Apr 2016 16:11:53 -0400 Subject: [PATCH 1/5] remove the if(pages>1) so that the if > line always happens --- web/skins/classic/views/events.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/web/skins/classic/views/events.php b/web/skins/classic/views/events.php index 7d0669177..b7d707b22 100644 --- a/web/skins/classic/views/events.php +++ b/web/skins/classic/views/events.php @@ -66,13 +66,11 @@ if ( !empty($limit) && $nEvents > $limit ) $nEvents = $limit; } $pages = (int)ceil($nEvents/ZM_WEB_EVENTS_PER_PAGE); -if ( $pages > 1 ) { - if ( !empty($page) ) { - if ( $page < 0 ) - $page = 1; - if ( $page > $pages ) - $page = $pages; - } +if ( !empty($page) ) { + if ( $page < 0 ) + $page = 1; + if ( $page > $pages ) + $page = $pages; } if ( !empty($page) ) { $limitStart = (($page-1)*ZM_WEB_EVENTS_PER_PAGE); From 9aff84fbbb6759b03e20196695e73a2e75325dff Mon Sep 17 00:00:00 2001 From: abi Date: Tue, 26 Apr 2016 21:53:50 +0300 Subject: [PATCH 2/5] unbreak build under FreeBSD 32 bit II --- src/zm_event.cpp | 2 +- src/zm_event.h | 4 ++-- src/zms.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/zm_event.cpp b/src/zm_event.cpp index 89973d1e4..c52fdebcd 100644 --- a/src/zm_event.cpp +++ b/src/zm_event.cpp @@ -715,7 +715,7 @@ bool EventStream::loadInitialEventData( int monitor_id, time_t event_time ) return( true ); } -bool EventStream::loadInitialEventData( int init_event_id, int init_frame_id ) +bool EventStream::loadInitialEventData( int init_event_id, unsigned int init_frame_id ) { loadEventData( init_event_id ); diff --git a/src/zm_event.h b/src/zm_event.h index f50a5bf06..f4a87e558 100644 --- a/src/zm_event.h +++ b/src/zm_event.h @@ -230,7 +230,7 @@ protected: protected: bool loadEventData( int event_id ); - bool loadInitialEventData( int init_event_id, int init_frame_id ); + bool loadInitialEventData( int init_event_id, unsigned int init_frame_id ); bool loadInitialEventData( int monitor_id, time_t event_time ); void checkEventLoaded(); @@ -249,7 +249,7 @@ public: event_data = 0; } - void setStreamStart( int init_event_id, int init_frame_id=0 ) + void setStreamStart( int init_event_id, unsigned int init_frame_id=0 ) { loadInitialEventData( init_event_id, init_frame_id ); loadMonitor( event_data->monitor_id ); diff --git a/src/zms.cpp b/src/zms.cpp index 9a7fcc941..f80c4f9db 100644 --- a/src/zms.cpp +++ b/src/zms.cpp @@ -62,7 +62,7 @@ int main( int argc, const char *argv[] ) int monitor_id = 0; time_t event_time = 0; int event_id = 0; - int frame_id = 1; + unsigned int frame_id = 1; unsigned int scale = 100; unsigned int rate = 100; double maxfps = 10.0; From 7d7249f328786b35ee91c635c3dd75a1e2e53324 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 26 Apr 2016 15:48:21 -0400 Subject: [PATCH 3/5] use std::string instead of C strings. Mostly this will quiet build warnings on FreeBSD and removes the potential for buffer overflows --- src/zmu.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/zmu.cpp b/src/zmu.cpp index a1e8887bd..3680c468a 100644 --- a/src/zmu.cpp +++ b/src/zmu.cpp @@ -757,15 +757,14 @@ int main( int argc, char *argv[] ) if ( function & ZMU_LIST ) { - char sql[ZM_SQL_SML_BUFSIZ]; - strncpy( sql, "select Id, Function+0 from Monitors", sizeof(sql) ); + std::string sql = "select Id, Function+0 from Monitors"; if ( !verbose ) { - strncat( sql, " where Function != 'None'", sizeof(sql)-strlen(sql) ); + sql += "where Function != 'None'"; } - strncat( sql, " order by Id asc", sizeof(sql)-strlen(sql) ); + sql += " order by Id asc"; - if ( mysql_query( &dbconn, sql ) ) + if ( mysql_query( &dbconn, sql.c_str() ) ) { Error( "Can't run query: %s", mysql_error( &dbconn ) ); exit( mysql_errno( &dbconn ) ); From 5d88acb8a6dc46eca074785cd838a1332732f1f9 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 26 Apr 2016 16:03:26 -0400 Subject: [PATCH 4/5] re-arrange a few lines to remove some duplicate ifdef's. And move the cr2 def into the area that uses it to remove build warnings on freebsd --- src/zm_signal.cpp | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/src/zm_signal.cpp b/src/zm_signal.cpp index 91e1bc4ba..26cfb763a 100644 --- a/src/zm_signal.cpp +++ b/src/zm_signal.cpp @@ -47,15 +47,12 @@ RETSIGTYPE zm_die_handler(int signal, siginfo_t * info, void *context) RETSIGTYPE zm_die_handler(int signal) #endif { -#if (defined(__i386__) || defined(__x86_64__)) - void *cr2 = 0; - void *ip = 0; -#endif Error("Got signal %d (%s), crashing", signal, strsignal(signal)); - #if (defined(__i386__) || defined(__x86_64__)) + void *ip = 0; // Get more information if available -#if ( HAVE_SIGINFO_T && HAVE_UCONTEXT_T ) + #if ( HAVE_SIGINFO_T && HAVE_UCONTEXT_T ) + void *cr2 = 0; if (info && context) { Debug(1, @@ -65,19 +62,19 @@ RETSIGTYPE zm_die_handler(int signal) ucontext_t *uc = (ucontext_t *) context; cr2 = info->si_addr; -#if defined(__x86_64__) - #ifdef __FreeBSD_kernel__ + #if defined(__x86_64__) + #ifdef __FreeBSD_kernel__ ip = (void *)(uc->uc_mcontext.mc_rip); - #else + #else ip = (void *)(uc->uc_mcontext.gregs[REG_RIP]); - #endif -#else - #ifdef __FreeBSD_kernel__ + #endif + #else + #ifdef __FreeBSD_kernel__ ip = (void *)(uc->uc_mcontext.mc_eip); - #else + #else ip = (void *)(uc->uc_mcontext.gregs[REG_EIP]); - #endif -#endif // defined(__x86_64__) + #endif + #endif // defined(__x86_64__) // Print the signal address and instruction pointer if available if (ip) { @@ -86,11 +83,11 @@ RETSIGTYPE zm_die_handler(int signal) Error("Signal address is %p, no instruction pointer", cr2); } } -#endif // ( HAVE_SIGINFO_T && HAVE_UCONTEXT_T ) + #endif // ( HAVE_SIGINFO_T && HAVE_UCONTEXT_T ) // Print backtrace if enabled and available -#if ( !defined(ZM_NO_CRASHTRACE) && HAVE_DECL_BACKTRACE && HAVE_DECL_BACKTRACE_SYMBOLS ) + #if ( !defined(ZM_NO_CRASHTRACE) && HAVE_DECL_BACKTRACE && HAVE_DECL_BACKTRACE_SYMBOLS ) void *trace[TRACE_SIZE]; int trace_size = 0; trace_size = backtrace(trace, TRACE_SIZE); @@ -111,7 +108,7 @@ RETSIGTYPE zm_die_handler(int signal) Info("Backtrace complete, please execute the following command for more information"); Info(cmd); -#endif // ( !defined(ZM_NO_CRASHTRACE) && HAVE_DECL_BACKTRACE && HAVE_DECL_BACKTRACE_SYMBOLS ) + #endif // ( !defined(ZM_NO_CRASHTRACE) && HAVE_DECL_BACKTRACE && HAVE_DECL_BACKTRACE_SYMBOLS ) #endif // (defined(__i386__) || defined(__x86_64__) exit(signal); } From 69d5065ebfa0fd026aec538c722a30e0347f431d Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 26 Apr 2016 16:05:37 -0400 Subject: [PATCH 5/5] move ip down as well --- src/zm_signal.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/zm_signal.cpp b/src/zm_signal.cpp index 26cfb763a..bbc40e916 100644 --- a/src/zm_signal.cpp +++ b/src/zm_signal.cpp @@ -49,9 +49,9 @@ RETSIGTYPE zm_die_handler(int signal) { Error("Got signal %d (%s), crashing", signal, strsignal(signal)); #if (defined(__i386__) || defined(__x86_64__)) - void *ip = 0; // Get more information if available #if ( HAVE_SIGINFO_T && HAVE_UCONTEXT_T ) + void *ip = 0; void *cr2 = 0; if (info && context) {