Skip to content

Commit

Permalink
Fix cppcheck warnings, part 2
Browse files Browse the repository at this point in the history
  • Loading branch information
dokutan committed Apr 24, 2021
1 parent 107e90a commit 98bb1fb
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 21 deletions.
2 changes: 1 addition & 1 deletion include/generic/getters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ int mouse_generic::get_macro( int number, std::string& macro ){
return 0;

std::vector< uint8_t > macro_bytes;
std::copy( _s_macro_data[number-1].begin(), _s_macro_data[number-1].end(), macro_bytes.begin() );
std::copy( _s_macro_data[number-1].begin(), _s_macro_data[number-1].end(), std::back_inserter(macro_bytes) );

_i_decode_macro( macro_bytes, output, "", 8 );
macro = output.str();
Expand Down
2 changes: 1 addition & 1 deletion include/m709/getters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ int mouse_m709::get_macro( int number, std::string& macro ){
return 0;

std::vector< uint8_t > macro_bytes;
std::copy( _s_macro_data[number-1].begin(), _s_macro_data[number-1].end(), macro_bytes.begin() );
std::copy( _s_macro_data[number-1].begin(), _s_macro_data[number-1].end(), std::back_inserter(macro_bytes) );

_i_decode_macro( macro_bytes, output, "", 8 );
macro = output.str();
Expand Down
2 changes: 1 addition & 1 deletion include/m711/getters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ int mouse_m711::get_macro( int number, std::string& macro ){
return 0;

std::vector< uint8_t > macro_bytes;
std::copy( _s_macro_data[number-1].begin(), _s_macro_data[number-1].end(), macro_bytes.begin() );
std::copy( _s_macro_data[number-1].begin(), _s_macro_data[number-1].end(), std::back_inserter(macro_bytes) );

_i_decode_macro( macro_bytes, output, "", 8 );
macro = output.str();
Expand Down
2 changes: 1 addition & 1 deletion include/m715/getters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ int mouse_m715::get_macro( int number, std::string& macro ){
return 0;

std::vector< uint8_t > macro_bytes;
std::copy( _s_macro_data[number-1].begin(), _s_macro_data[number-1].end(), macro_bytes.begin() );
std::copy( _s_macro_data[number-1].begin(), _s_macro_data[number-1].end(), std::back_inserter(macro_bytes) );

_i_decode_macro( macro_bytes, output, "", 8 );
macro = output.str();
Expand Down
2 changes: 1 addition & 1 deletion include/m719/getters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ int mouse_m719::get_macro( int number, std::string& macro ){
return 0;

std::vector< uint8_t > macro_bytes;
std::copy( _s_macro_data[number-1].begin(), _s_macro_data[number-1].end(), macro_bytes.begin() );
std::copy( _s_macro_data[number-1].begin(), _s_macro_data[number-1].end(), std::back_inserter(macro_bytes) );

_i_decode_macro( macro_bytes, output, "", 8 );
macro = output.str();
Expand Down
2 changes: 1 addition & 1 deletion include/m908/getters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ int mouse_m908::get_macro( int number, std::string& macro ){
return 0;

std::vector< uint8_t > macro_bytes;
std::copy( _s_macro_data[number-1].begin(), _s_macro_data[number-1].end(), macro_bytes.begin() );
std::copy( _s_macro_data[number-1].begin(), _s_macro_data[number-1].end(), std::back_inserter(macro_bytes) );

_i_decode_macro( macro_bytes, output, "", 8 );
macro = output.str();
Expand Down
2 changes: 1 addition & 1 deletion include/m913/getters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ int mouse_m913::get_macro( int number, std::string& macro ){
return 0;

std::vector< uint8_t > macro_bytes;
std::copy( _s_macro_data[number-1].begin(), _s_macro_data[number-1].end(), macro_bytes.begin() );
std::copy( _s_macro_data[number-1].begin(), _s_macro_data[number-1].end(), std::back_inserter(macro_bytes) );

_i_decode_macro( macro_bytes, output, "", 8 );
macro = output.str();
Expand Down
2 changes: 1 addition & 1 deletion include/m990/getters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ int mouse_m990::get_macro( int number, std::string& macro ){
return 0;

std::vector< uint8_t > macro_bytes;
std::copy( _s_macro_data[number-1].begin(), _s_macro_data[number-1].end(), macro_bytes.begin() );
std::copy( _s_macro_data[number-1].begin(), _s_macro_data[number-1].end(), std::back_inserter(macro_bytes) );

_i_decode_macro( macro_bytes, output, "", 8 );
macro = output.str();
Expand Down
2 changes: 1 addition & 1 deletion include/m990chroma/getters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ int mouse_m990chroma::get_macro( int number, std::string& macro ){
return 0;

std::vector< uint8_t > macro_bytes;
std::copy( _s_macro_data[number-1].begin(), _s_macro_data[number-1].end(), macro_bytes.begin() );
std::copy( _s_macro_data[number-1].begin(), _s_macro_data[number-1].end(), std::back_inserter(macro_bytes) );

_i_decode_macro( macro_bytes, output, "", 8 );
macro = output.str();
Expand Down
4 changes: 0 additions & 4 deletions include/rd_mouse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,6 @@ int rd_mouse::_i_decode_macro( const std::vector< uint8_t >& macro_bytes, std::o

bool unknown_code = false;

// failsafe, i sometimes gets incremented by >1 which could lead to it being out of bounds
if( i >= macro_bytes.size() )
break;

// mouse buttons ( 0x81 = down, 0x01 = up )
if( macro_bytes[i] == 0x81 && macro_bytes[i+1] == 0x01 )
output << prefix << "down\tmouse_left\n";
Expand Down
18 changes: 10 additions & 8 deletions include/rd_mouse.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,21 @@
#define RD_MOUSE

#include <libusb.h>
#include <map>
#include <array>
#include <string>

#include <algorithm>
#include <array>
#include <exception>
#include <regex>
#include <fstream>
#include <sstream>
#include <utility>
#include <iostream>
#include <iomanip>
#include <string>
#include <iostream>
#include <iterator>
#include <map>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <string>
#include <utility>
#include <variant>

/* These declarations exist to make it possible for mouse_variant
Expand Down

0 comments on commit 98bb1fb

Please sign in to comment.