From: Michael Altizer (mialtize) Date: Sun, 12 Jul 2020 06:06:52 +0000 (+0000) Subject: Merge pull request #2326 in SNORT/snort3 from ~MIALTIZE/snort3:clang10 to master X-Git-Tag: 3.0.2-2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a2c1473c96dd50d595e598b401076fd90a2feaaf;p=thirdparty%2Fsnort3.git Merge pull request #2326 in SNORT/snort3 from ~MIALTIZE/snort3:clang10 to master Squashed commit of the following: commit fe095538b0db54f13f12c7f1e75b84e950aa0972 Author: Michael Altizer Date: Sat Jul 11 15:57:21 2020 -0400 build: Fix static analyzer complaints about unused stored values --- diff --git a/src/decompress/file_decomp_pdf.cc b/src/decompress/file_decomp_pdf.cc index e5258ec5c..e240f0411 100644 --- a/src/decompress/file_decomp_pdf.cc +++ b/src/decompress/file_decomp_pdf.cc @@ -145,11 +145,11 @@ static inline uint8_t Get_Decomp_Type(uint8_t* Token, uint8_t Length) { if ( (Filter_Map[Index].Length == Length) && (strncmp( (const char*)Token, Filter_Map[Index].Token, Length) == 0 ) ) - return( Filter_Map[Index].Type ); + return Filter_Map[Index].Type; else Index += 1; } - return( FILE_COMPRESSION_TYPE_NONE ); + return FILE_COMPRESSION_TYPE_NONE; } static inline void Process_One_Filter(fd_session_t* SessionPtr, uint8_t* Token, uint8_t Length) @@ -274,7 +274,7 @@ static fd_status_t Process_Filter_Spec(fd_session_t* SessionPtr) else if ( (Filter != nullptr) && (Length > 0) ) Process_One_Filter(SessionPtr, Filter, Length); - return( Ret_Code ); + return Ret_Code; } static inline void Init_Parser(fd_session_t* SessionPtr) @@ -293,14 +293,14 @@ static inline fd_status_t Push_State(fd_PDF_Parse_p_t p) fd_PDF_Parse_Stack_p_t StckPtr; if ( p->Parse_Stack_Index >= (PARSE_STACK_LEN-1) ) - return( File_Decomp_Error ); + return File_Decomp_Error; StckPtr = &(p->Parse_Stack[(p->Parse_Stack_Index)++]); StckPtr->State = p->State; StckPtr->Sub_State = p->Sub_State; - return( File_Decomp_OK ); + return File_Decomp_OK; } static inline fd_status_t Pop_State(fd_PDF_Parse_p_t p) @@ -308,7 +308,7 @@ static inline fd_status_t Pop_State(fd_PDF_Parse_p_t p) fd_PDF_Parse_Stack_p_t StckPtr; if ( p->Parse_Stack_Index == 0 ) - return( File_Decomp_Error ); + return File_Decomp_Error; StckPtr = &(p->Parse_Stack[--(p->Parse_Stack_Index)]); @@ -316,16 +316,16 @@ static inline fd_status_t Pop_State(fd_PDF_Parse_p_t p) p->State = StckPtr->State; p->Sub_State = StckPtr->Sub_State; - return( File_Decomp_OK ); + return File_Decomp_OK; } /* If there's a previous state on the stack, return a pointer to it, else return NULL */ static inline fd_PDF_Parse_Stack_p_t Get_Previous_State(fd_PDF_Parse_p_t p) { if ( p->Parse_Stack_Index == 0 ) - return( (fd_PDF_Parse_Stack_p_t)nullptr ); + return nullptr; - return( &(p->Parse_Stack[(p->Parse_Stack_Index)-1]) ); + return &(p->Parse_Stack[(p->Parse_Stack_Index)-1]); } /* Objects are the heart and soul of the PDF. In particular, we need to concentrate on Dictionary @@ -345,7 +345,7 @@ static inline fd_status_t Handle_State_DICT_OBJECT(fd_session_t* SessionPtr, uin p->State = P_DICT_OBJECT; p->Filter_Spec_Index = 0; SessionPtr->Decomp_Type = FILE_COMPRESSION_TYPE_NONE; - return( File_Decomp_OK ); + return File_Decomp_OK; } switch ( p->Sub_State ) @@ -362,7 +362,7 @@ static inline fd_status_t Handle_State_DICT_OBJECT(fd_session_t* SessionPtr, uin /* for other objects, just skip and wait for the close of the indirect object as we don't parse objects other than Dict's. */ if ( Pop_State(p) == File_Decomp_Error ) - return( File_Decomp_Error ); + return File_Decomp_Error; } break; } @@ -387,7 +387,7 @@ static inline fd_status_t Handle_State_DICT_OBJECT(fd_session_t* SessionPtr, uin /* for other objects, just skip and wait for the close of the indirect object as we don't parse objects other than Dict's. */ if ( Pop_State(p) == File_Decomp_Error ) - return( File_Decomp_Error ); + return File_Decomp_Error; } break; } @@ -419,13 +419,13 @@ static inline fd_status_t Handle_State_DICT_OBJECT(fd_session_t* SessionPtr, uin { /* Save where we are, and process the Dict */ if ( Push_State(p) != File_Decomp_OK ) - return( File_Decomp_Error ); + return File_Decomp_Error; p->Sub_State = P_DICT_OPEN_TOK; } else if ( c == CHR_ANGLE_CLOSE ) { if ( Push_State(p) != File_Decomp_OK ) - return( File_Decomp_Error ); + return File_Decomp_Error; p->Sub_State = P_DICT_CLOSE_TOK; } } @@ -441,7 +441,7 @@ static inline fd_status_t Handle_State_DICT_OBJECT(fd_session_t* SessionPtr, uin if ( c == CHR_ANGLE_CLOSE ) { if ( Push_State(p) != File_Decomp_OK ) - return( File_Decomp_Error ); + return File_Decomp_Error; p->Sub_State = P_DICT_CLOSE_TOK; } else @@ -449,7 +449,7 @@ static inline fd_status_t Handle_State_DICT_OBJECT(fd_session_t* SessionPtr, uin p->Sub_State = P_DICT_SKIP; } if ( (Process_Filter_Spec(SessionPtr) == File_Decomp_Error) ) - return( File_Decomp_Error ); + return File_Decomp_Error; } else { @@ -471,7 +471,7 @@ static inline fd_status_t Handle_State_DICT_OBJECT(fd_session_t* SessionPtr, uin p->Filter_Spec_Buf[p->Filter_Spec_Index++] = c; } else - return( File_Decomp_Error ); + return File_Decomp_Error; } break; } @@ -482,7 +482,7 @@ static inline fd_status_t Handle_State_DICT_OBJECT(fd_session_t* SessionPtr, uin { /* Pop the temp state just prior to the first > */ if ( Pop_State(p) == File_Decomp_Error ) - return( File_Decomp_Error ); + return File_Decomp_Error; /* Pop back to the state before the <<. */ /* But not so fast... Look at what state/sub-state we are popping @@ -496,7 +496,7 @@ static inline fd_status_t Handle_State_DICT_OBJECT(fd_session_t* SessionPtr, uin if ( (StckPtr = Get_Previous_State(p)) == nullptr ) { /* There MUST be a previous state that got us here. */ - return( File_Decomp_Error ); + return File_Decomp_Error; } else { @@ -508,20 +508,20 @@ static inline fd_status_t Handle_State_DICT_OBJECT(fd_session_t* SessionPtr, uin } } if ( Pop_State(p) == File_Decomp_Error ) - return( File_Decomp_Error ); + return File_Decomp_Error; } else /* Return to where we looking (didn't get >>) */ if ( Pop_State(p) == File_Decomp_Error ) - return( File_Decomp_Error ); + return File_Decomp_Error; break; } default: - return( File_Decomp_Error ); + return File_Decomp_Error; } - return( File_Decomp_OK ); + return File_Decomp_OK; } static inline fd_status_t Process_Stream(fd_PDF_Parse_p_t p) @@ -530,13 +530,13 @@ static inline fd_status_t Process_Stream(fd_PDF_Parse_p_t p) p->State = P_IND_OBJ; if ( Push_State(p) == File_Decomp_Error ) - return( File_Decomp_Error ); + return File_Decomp_Error; else { p->State = P_STREAM; p->Sub_State = 0; } - return( File_Decomp_OK ); + return File_Decomp_OK; } /* Indirect Objects occur only at the top level of the file and comprise the @@ -552,7 +552,7 @@ static inline fd_status_t Handle_State_IND_OBJ(fd_session_t* SessionPtr, uint8_t p->Sub_State = P_OBJ_NUMBER; p->Elem_Index = 1; p->Elem_Buf[0] = c; - return( File_Decomp_OK ); + return File_Decomp_OK; } switch ( p->Sub_State ) @@ -562,12 +562,12 @@ static inline fd_status_t Handle_State_IND_OBJ(fd_session_t* SessionPtr, uint8_t { if ( isdigit(c) ) { - if ( p->Elem_Index < (sizeof(p->Elem_Buf)-1)) + if ( p->Elem_Index < (sizeof(p->Elem_Buf)-1) ) { p->Elem_Buf[p->Elem_Index++] = c; } else - return( File_Decomp_Error ); + return File_Decomp_Error; } else if ( c == CHR_SPACE ) { @@ -602,7 +602,7 @@ static inline fd_status_t Handle_State_IND_OBJ(fd_session_t* SessionPtr, uint8_t } else { - return( File_Decomp_Error ); + return File_Decomp_Error; } } // fallthrough @@ -614,8 +614,8 @@ static inline fd_status_t Handle_State_IND_OBJ(fd_session_t* SessionPtr, uint8_t p->Sub_State = P_ENDOBJ_TOKEN; /* Save our place in the IND_OBJ and go process an OBJECT */ if ( Push_State(p) != File_Decomp_OK ) - return( File_Decomp_Error ); - return( Handle_State_DICT_OBJECT(SessionPtr, c) ); + return File_Decomp_Error; + return Handle_State_DICT_OBJECT(SessionPtr, c); } break; @@ -637,7 +637,7 @@ static inline fd_status_t Handle_State_IND_OBJ(fd_session_t* SessionPtr, uint8_t p->Elem_Index = 0; // reset and keep looking } else - return( File_Decomp_Error ); + return File_Decomp_Error; break; } @@ -652,10 +652,10 @@ static inline fd_status_t Handle_State_IND_OBJ(fd_session_t* SessionPtr, uint8_t else if ( c == CHR_LF ) { if ( Process_Stream(p) != File_Decomp_OK ) - return( File_Decomp_Error ); + return File_Decomp_Error; } else - return( File_Decomp_Error ); + return File_Decomp_Error; break; } @@ -665,10 +665,10 @@ static inline fd_status_t Handle_State_IND_OBJ(fd_session_t* SessionPtr, uint8_t if ( c == CHR_LF ) { if ( Process_Stream(p) != File_Decomp_OK ) - return( File_Decomp_Error ); + return File_Decomp_Error; } else - return( File_Decomp_Error ); + return File_Decomp_Error; break; } @@ -698,7 +698,7 @@ static inline fd_status_t Handle_State_IND_OBJ(fd_session_t* SessionPtr, uint8_t { /* we found the end of the indirect object, return back to the parent state (always START in this case) */ - return( Pop_State(p) ); + return Pop_State(p); } } else @@ -713,10 +713,10 @@ static inline fd_status_t Handle_State_IND_OBJ(fd_session_t* SessionPtr, uint8_t } default: - return( File_Decomp_Error ); + return File_Decomp_Error; } - return( File_Decomp_OK ); + return File_Decomp_OK; } /* A simple state machine to process the xref/trailer/startxref file segments. No @@ -732,7 +732,7 @@ static inline fd_status_t Handle_State_XREF(fd_session_t* SessionPtr, uint8_t c) p->Elem_Index = 1; // already matched the first char in START state p->State = P_XREF; p->xref_tok = (const uint8_t*)((c == TOK_XRF_XREF[0]) ? TOK_XRF_XREF : TOK_XRF_STARTXREF); - return( File_Decomp_OK ); + return File_Decomp_OK; } switch ( p->Sub_State ) @@ -749,7 +749,7 @@ static inline fd_status_t Handle_State_XREF(fd_session_t* SessionPtr, uint8_t c) } else { - return( File_Decomp_Error ); + return File_Decomp_Error; } break; } @@ -775,10 +775,10 @@ static inline fd_status_t Handle_State_XREF(fd_session_t* SessionPtr, uint8_t c) } default: - return( File_Decomp_Error ); + return File_Decomp_Error; } - return( File_Decomp_OK ); + return File_Decomp_OK; } static inline fd_status_t Handle_State_START(fd_session_t* SessionPtr, uint8_t c) @@ -788,7 +788,7 @@ static inline fd_status_t Handle_State_START(fd_session_t* SessionPtr, uint8_t c the LF as part of a EOL token. */ if ( IS_WHITESPACE(c) ) { - return( File_Decomp_OK ); + return File_Decomp_OK; } if ( c == CHR_COMMENT ) { @@ -798,24 +798,24 @@ static inline fd_status_t Handle_State_START(fd_session_t* SessionPtr, uint8_t c { /* Save state and process an indirect object */ if ( Push_State(p) != File_Decomp_OK ) - return( File_Decomp_Error ); - return( Handle_State_IND_OBJ(SessionPtr, c) ); + return File_Decomp_Error; + return Handle_State_IND_OBJ(SessionPtr, c); } else if ( (c == TOK_XRF_XREF[0]) || (c == TOK_XRF_STARTXREF[0]) ) { /* Save state and process the xref block */ if ( Push_State(p) != File_Decomp_OK ) - return( File_Decomp_Error ); - return( Handle_State_XREF(SessionPtr, c) ); + return File_Decomp_Error; + return Handle_State_XREF(SessionPtr, c); } else if ( !(IS_WHITESPACE(c)) ) { /* If is not an ind_obj started, or a comment starting, then we don't know what it is, so return an error. */ - return( File_Decomp_Error ); + return File_Decomp_Error; } - return( File_Decomp_OK ); + return File_Decomp_OK; } /* Incrementally search the incoming data for a PDF compressed stream @@ -834,9 +834,9 @@ static fd_status_t Locate_Stream_Beginning(fd_session_t* SessionPtr) /* No reason to parse if there's no input or room for output. */ if ( SessionPtr->Avail_In == 0 ) - return( File_Decomp_BlockIn ); + return File_Decomp_BlockIn; if ( SessionPtr->Avail_Out == 0 ) - return( File_Decomp_BlockOut ); + return File_Decomp_BlockOut; /* Get next byte in input queue */ uint8_t c = *SessionPtr->Next_In; @@ -848,7 +848,7 @@ static fd_status_t Locate_Stream_Beginning(fd_session_t* SessionPtr) case ( P_START ): { if ( (Ret_Code = Handle_State_START(SessionPtr, c)) != File_Decomp_OK ) - return( Ret_Code ); + return Ret_Code; break; } @@ -865,31 +865,31 @@ static fd_status_t Locate_Stream_Beginning(fd_session_t* SessionPtr) case ( P_IND_OBJ ): { if ( (Ret_Code = Handle_State_IND_OBJ(SessionPtr, c)) != File_Decomp_OK ) - return( Ret_Code ); + return Ret_Code; break; } case ( P_DICT_OBJECT ): { if ( (Ret_Code = Handle_State_DICT_OBJECT(SessionPtr, c)) != File_Decomp_OK ) - return( Ret_Code ); + return Ret_Code; break; } case ( P_XREF ): { if ( (Ret_Code = Handle_State_XREF(SessionPtr, c)) != File_Decomp_OK ) - return( Ret_Code ); + return Ret_Code; break; } case ( P_STREAM ): { - return( File_Decomp_Complete ); + return File_Decomp_Complete; } default: - return( File_Decomp_Error ); + return File_Decomp_Error; } /* After parsing, move the byte from the input to the output stream. We can only be here if there's input @@ -921,16 +921,16 @@ static fd_status_t Init_Stream(fd_session_t* SessionPtr) if ( z_ret != Z_OK ) { File_Decomp_Alert(SessionPtr, FILE_DECOMP_ERR_PDF_DEFL_FAILURE); - return( File_Decomp_Error ); + return File_Decomp_Error; } break; } default: - return( File_Decomp_Error ); + return File_Decomp_Error; } - return( File_Decomp_OK ); + return File_Decomp_OK; } static fd_status_t Decomp_Stream(fd_session_t* SessionPtr) @@ -940,9 +940,9 @@ static fd_status_t Decomp_Stream(fd_session_t* SessionPtr) /* No reason to decompress if there's no input or room for output. */ if ( SessionPtr->Avail_In == 0 ) - return( File_Decomp_BlockIn ); + return File_Decomp_BlockIn; if ( SessionPtr->Avail_Out == 0 ) - return( File_Decomp_BlockOut ); + return File_Decomp_BlockOut; switch ( StPtr->Decomp_Type ) { @@ -959,22 +959,22 @@ static fd_status_t Decomp_Stream(fd_session_t* SessionPtr) if ( z_ret == Z_STREAM_END ) { - return( File_Decomp_Complete ); + return File_Decomp_Complete; } if ( z_ret != Z_OK ) { File_Decomp_Alert(SessionPtr, FILE_DECOMP_ERR_PDF_DEFL_FAILURE); - return( File_Decomp_Error ); + return File_Decomp_Error; } break; } default: - return( File_Decomp_Error ); + return File_Decomp_Error; } - return( File_Decomp_OK ); + return File_Decomp_OK; } /* After processing a stream, close the decompression engine @@ -983,11 +983,11 @@ static fd_status_t Close_Stream(fd_session_t* SessionPtr) { /* Put the parser state back where it was interrupted */ if ( Pop_State(&(SessionPtr->PDF->Parse) ) == File_Decomp_Error ) - return( File_Decomp_Error ); + return File_Decomp_Error; SessionPtr->PDF->State = PDF_STATE_LOCATE_STREAM; - return( File_Decomp_OK ); + return File_Decomp_OK; } /* Abort the decompression session upon command from caller. */ @@ -996,13 +996,13 @@ fd_status_t File_Decomp_End_PDF(fd_session_t* SessionPtr) fd_PDF_p_t StPtr; if ( SessionPtr == nullptr ) - return( File_Decomp_Error ); + return File_Decomp_Error; StPtr = SessionPtr->PDF; if ( (StPtr->State != PDF_STATE_INIT_STREAM) && (StPtr->State != PDF_STATE_PROCESS_STREAM) ) - return( File_Decomp_OK ); + return File_Decomp_OK; switch ( StPtr->Decomp_Type ) { @@ -1016,23 +1016,23 @@ fd_status_t File_Decomp_End_PDF(fd_session_t* SessionPtr) if ( z_ret != Z_OK ) { File_Decomp_Alert(SessionPtr, FILE_DECOMP_ERR_PDF_DEFL_FAILURE); - return( File_Decomp_Error ); + return File_Decomp_Error; } break; } default: - return( File_Decomp_Error ); + return File_Decomp_Error; } - return( File_Decomp_OK ); + return File_Decomp_OK; } /* From caller, initialize PDF state machine. */ fd_status_t File_Decomp_Init_PDF(fd_session_t* SessionPtr) { if ( SessionPtr == nullptr ) - return( File_Decomp_Error ); + return File_Decomp_Error; SessionPtr->PDF = (fd_PDF_t*)snort_calloc(sizeof(fd_PDF_t)); @@ -1045,16 +1045,14 @@ fd_status_t File_Decomp_Init_PDF(fd_session_t* SessionPtr) /* Search for Dictionary/Stream object. */ StPtr->State = PDF_STATE_LOCATE_STREAM; - return( File_Decomp_OK ); + return File_Decomp_OK; } /* Run the PDF state machine */ fd_status_t File_Decomp_PDF(fd_session_t* SessionPtr) { - fd_status_t Ret_Code; - if ( (SessionPtr == nullptr) || (SessionPtr->File_Type != FILE_TYPE_PDF) ) - return( File_Decomp_Error ); + return File_Decomp_Error; /* Process all data until blocked */ while ( true ) @@ -1065,15 +1063,16 @@ fd_status_t File_Decomp_PDF(fd_session_t* SessionPtr) { /* Will return File_Decomp_Complete if/when the start of a valid compressed stream is located. Decomp_Type will be set. The parsing will be suspended. */ - if ( (Ret_Code = Locate_Stream_Beginning(SessionPtr) ) == File_Decomp_Error) + fd_status_t Ret_Code = Locate_Stream_Beginning(SessionPtr); + if ( Ret_Code == File_Decomp_Error ) { SessionPtr->Error_Event = FILE_DECOMP_ERR_PDF_PARSE_FAILURE; - return( File_Decomp_DecompError ); + return File_Decomp_DecompError; } /* If we didn't succeed then get more input */ if ( Ret_Code != File_Decomp_Complete ) - return( Ret_Code ); + return Ret_Code; /* The Parsing state remains, we break out to perform the stream decompression. */ @@ -1091,12 +1090,11 @@ fd_status_t File_Decomp_PDF(fd_session_t* SessionPtr) case ( PDF_STATE_INIT_STREAM ): { /* Initialize the selected decompression engine. */ - Ret_Code = Init_Stream(SessionPtr); - if ( Ret_Code != File_Decomp_OK ) + if ( Init_Stream(SessionPtr) != File_Decomp_OK ) { File_Decomp_End_PDF(SessionPtr); if ( Close_Stream(SessionPtr) != File_Decomp_OK ) - return( File_Decomp_Error ); + return File_Decomp_Error; File_Decomp_Alert(SessionPtr, FILE_DECOMP_ERR_PDF_DEFL_FAILURE); break; } @@ -1107,13 +1105,13 @@ fd_status_t File_Decomp_PDF(fd_session_t* SessionPtr) case ( PDF_STATE_PROCESS_STREAM ): { - Ret_Code = Decomp_Stream(SessionPtr); + fd_status_t Ret_Code = Decomp_Stream(SessionPtr); /* Has the decompressor indicated the end of the data */ if ( Ret_Code == File_Decomp_Error ) { File_Decomp_End_PDF(SessionPtr); if ( Close_Stream(SessionPtr) != File_Decomp_OK ) - return( File_Decomp_Error ); + return File_Decomp_Error; File_Decomp_Alert(SessionPtr, FILE_DECOMP_ERR_PDF_DEFL_FAILURE); break; } @@ -1121,21 +1119,21 @@ fd_status_t File_Decomp_PDF(fd_session_t* SessionPtr) else if ( Ret_Code == File_Decomp_OK ) break; else if ( Ret_Code != File_Decomp_Complete ) - return( Ret_Code ); + return Ret_Code ; /* Close the decompression engine */ - if ( (Ret_Code = File_Decomp_End_PDF(SessionPtr) ) == File_Decomp_Error) - return( File_Decomp_Error); + if ( File_Decomp_End_PDF(SessionPtr) == File_Decomp_Error ) + return File_Decomp_Error; /* Put the parser state back where it was interrupted */ if ( (Close_Stream(SessionPtr) ) == File_Decomp_Error ) - return( File_Decomp_Error ); + return File_Decomp_Error; break; } default: - return( File_Decomp_Error ); + return File_Decomp_Error; } // switch() } // while() diff --git a/src/loggers/unified2.cc b/src/loggers/unified2.cc index 9516f1d59..a748ead99 100644 --- a/src/loggers/unified2.cc +++ b/src/loggers/unified2.cc @@ -447,7 +447,6 @@ static void _Unified2LogPacketAlert( static void Unified2Write(uint8_t* buf, uint32_t buf_len, Unified2Config* config) { size_t fwcount = 0; - int ffstatus = 0; /* Nothing to write or nothing to write to */ if ((buf == nullptr) || (config == nullptr) || (u2.stream == nullptr)) @@ -455,7 +454,7 @@ static void Unified2Write(uint8_t* buf, uint32_t buf_len, Unified2Config* config /* Don't use fsync(). It is a total performance killer */ if (((fwcount = fwrite(buf, (size_t)buf_len, 1, u2.stream)) != 1) || - ((ffstatus = fflush(u2.stream)) != 0)) + (fflush(u2.stream) != 0)) { /* errno is saved just to avoid other intervening calls * (e.g. ErrorMessage) potentially resetting it to something else. */ @@ -489,13 +488,13 @@ static void Unified2Write(uint8_t* buf, uint32_t buf_len, Unified2Config* config { /* fwrite() failed. Redo fwrite and fflush */ if (((fwcount = fwrite(buf, (size_t)buf_len, 1, u2.stream)) == 1) && - ((ffstatus = fflush(u2.stream)) == 0)) + fflush(u2.stream) == 0) { error = 0; break; } } - else if ((ffstatus = fflush(u2.stream)) == 0) + else if (fflush(u2.stream) == 0) { error = 0; break; @@ -530,7 +529,7 @@ static void Unified2Write(uint8_t* buf, uint32_t buf_len, Unified2Config* config } if (((fwcount = fwrite(buf, (size_t)buf_len, 1, u2.stream)) == 1) && - ((ffstatus = fflush(u2.stream)) == 0)) + fflush(u2.stream) == 0) { error = 0; break; diff --git a/src/network_inspectors/appid/detector_plugins/detector_imap.cc b/src/network_inspectors/appid/detector_plugins/detector_imap.cc index e2b0151ba..6d3c7df30 100644 --- a/src/network_inspectors/appid/detector_plugins/detector_imap.cc +++ b/src/network_inspectors/appid/detector_plugins/detector_imap.cc @@ -567,8 +567,6 @@ int ImapClientDetector::validate(AppIdDiscoveryArgs& args) { const uint8_t* s = args.data; const uint8_t* end = (args.data + args.size); - unsigned length; - AppIdFlowContentPattern* cmd = nullptr; char tag[IMAP_TAG_MAX_LEN + 1] = { 0 }; #ifdef APP_ID_USES_REASSEMBLED @@ -588,9 +586,8 @@ int ImapClientDetector::validate(AppIdDiscoveryArgs& args) return APPID_INPROCESS; } - while ((length = (end - s)) > 0) + while (end > s) { - unsigned long pattern_index; if (fd->auth) { /* authentication exchange in progress ignore all client-side @@ -636,9 +633,9 @@ int ImapClientDetector::validate(AppIdDiscoveryArgs& args) args.asd.clear_session_flags(APPID_SESSION_CLIENT_GETS_SERVER_PACKETS); return APPID_SUCCESS; } - cmd = nullptr; - pattern_index = num_imap_client_patterns; - length = end - s; + AppIdFlowContentPattern* cmd = nullptr; + unsigned long pattern_index = num_imap_client_patterns; + unsigned length = end - s; cmd_matcher->find_all((const char*)s, (length > longest_pattern ? longest_pattern : length), &pattern_match, false, (void*)&pattern_index); diff --git a/src/network_inspectors/appid/length_app_cache.h b/src/network_inspectors/appid/length_app_cache.h index 149b81ef7..c7e7d1cf2 100644 --- a/src/network_inspectors/appid/length_app_cache.h +++ b/src/network_inspectors/appid/length_app_cache.h @@ -30,8 +30,6 @@ #pragma pack(1) -enum class IpProtocol : uint8_t; - struct LengthSequenceEntry { AppidSessionDirection direction = APP_ID_FROM_INITIATOR; diff --git a/src/network_inspectors/appid/lua_detector_api.cc b/src/network_inspectors/appid/lua_detector_api.cc index 62af8419d..357311344 100644 --- a/src/network_inspectors/appid/lua_detector_api.cc +++ b/src/network_inspectors/appid/lua_detector_api.cc @@ -1763,7 +1763,6 @@ static int detector_add_length_app_cache(lua_State* L) } LengthKey length_sequence; - memset(length_sequence.sequence, 0, sizeof(length_sequence.sequence)); length_sequence.proto = proto; length_sequence.sequence_cnt = sequence_cnt; diff --git a/src/profiler/profiler.cc b/src/profiler/profiler.cc index 06d0696bc..4fa827f5d 100644 --- a/src/profiler/profiler.cc +++ b/src/profiler/profiler.cc @@ -60,9 +60,8 @@ void Profiler::register_module(Module* m) { unsigned i = 0; const char* n, * pn; - const ProfileStats* ps = nullptr; - while ( (ps = m->get_profile(i++, n, pn)) ) + while ( m->get_profile(i++, n, pn) ) register_module(n, pn, m); } } diff --git a/src/utils/util_jsnorm.cc b/src/utils/util_jsnorm.cc index c460763b8..d9447ee35 100644 --- a/src/utils/util_jsnorm.cc +++ b/src/utils/util_jsnorm.cc @@ -1022,23 +1022,16 @@ static int Unescape_exec(UnescapeState* s, ActionUnsc a, int c, JSState* js) static int Unescape_scan_fsm(UnescapeState* s, int c, JSState* js) { - int indexed = 0; - int value = 0; - int uc; - const JSNorm* m = unescape_norm + s->fsm; - - uc = toupper(c); - if (isspace(c)) { - c = uc =' '; + c = ' '; return(Unescape_exec(s, UNESC_ACT_SPACE, c, js)); } - value = valid_chars[uc]; - - if (value) - indexed = 1; + const JSNorm* m = unescape_norm + s->fsm; + int uc = toupper(c); + int value = valid_chars[uc]; + int indexed = value ? 1 : 0; do { @@ -1211,17 +1204,15 @@ static int JSNorm_exec(JSNormState* s, ActionJSNorm a, int c, const char* src, u static int JSNorm_scan_fsm(JSNormState* s, int c, const char* src, uint16_t srclen, const char** ptr, JSState* js) { - char uc; - const JSNorm* m = javascript_norm + s->fsm; - - uc = toupper(c); - if (isspace(c)) { - c = uc =' '; + c = ' '; return(JSNorm_exec(s, ACT_SPACE, c, src, srclen, ptr, js)); } + const JSNorm* m = javascript_norm + s->fsm; + int uc = toupper(c); + do { if (!m->event || (m->event == uc))