Skip to content

Commit

Permalink
Fix all cpp check errors/info messages
Browse files Browse the repository at this point in the history
  • Loading branch information
melroy89 committed Jun 29, 2024
1 parent dc63286 commit ff964d2
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion scripts/cpp-check.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash
# TODO: add to following flag to the cppcheck: --addon=cert
cppcheck --enable=all --library=googletest --suppressions-list=suppressions.txt --error-exitcode=1 "$@" -I lib/commonmarker/src/ -I lib/commonmarker/extensions/ ./src ./tst
cppcheck --enable=all --library=googletest --suppressions-list=suppressions.txt --inline-suppr --check-level=exhaustive --error-exitcode=1 "$@" -I ./src -I lib/commonmarker/src/ -I lib/commonmarker/extensions/ ./src ./tst
2 changes: 1 addition & 1 deletion src/about-dialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void About::hide_about(__attribute__((unused)) int response)
std::string About::get_logo_image()
{
// Use data directory first, used when LibreWeb is installed (Linux or Windows)
for (std::string data_dir : Glib::get_system_data_dirs())
for (const std::string& data_dir : Glib::get_system_data_dirs())
{
std::vector<std::string> path_builder{data_dir, "libreweb", "images", "browser_logo_small.png"};
std::string file_path = Glib::build_path(G_DIR_SEPARATOR_S, path_builder);
Expand Down
8 changes: 4 additions & 4 deletions src/draw.cc
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ void Draw::event_after(GdkEvent* ev)

if (ev->type == GDK_BUTTON_RELEASE)
{
GdkEventButton* event;
const GdkEventButton* event;
event = reinterpret_cast<GdkEventButton*>(ev);
if (event->button != GDK_BUTTON_PRIMARY)
return;
Expand All @@ -145,7 +145,7 @@ void Draw::event_after(GdkEvent* ev)
}
else if (ev->type == GDK_TOUCH_END)
{
GdkEventTouch* event;
const GdkEventTouch* event;
event = reinterpret_cast<GdkEventTouch*>(ev);
ex = event->x;
ey = event->y;
Expand Down Expand Up @@ -513,7 +513,7 @@ void Draw::select_all()
/**
* \brief Return the Texr mark headings for Table of contents
*/
std::vector<Glib::RefPtr<Gtk::TextMark>> Draw::get_headings()
const std::vector<Glib::RefPtr<Gtk::TextMark>>& Draw::get_headings() const
{
return headings_toc_;
}
Expand Down Expand Up @@ -1606,7 +1606,7 @@ void Draw::change_cursor(int x, int y)
auto tags = iter.get_tags();
for (auto const& tag : tags)
{
char* url = static_cast<char*>(tag->get_data("url"));
const char* url = static_cast<char*>(tag->get_data("url"));
if (url != 0 && (strlen(url) > 0))
{
// Link
Expand Down
2 changes: 1 addition & 1 deletion src/draw.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class Draw : public Gtk::TextView
void paste();
void del();
void select_all();
std::vector<Glib::RefPtr<Gtk::TextMark>> get_headings();
const std::vector<Glib::RefPtr<Gtk::TextMark>>& get_headings() const;

// Signals editor calls
void make_heading(int heading_level);
Expand Down
1 change: 1 addition & 0 deletions src/ipfs-daemon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ void IPFSDaemon::spawn()
// Check for PID under UNIX
int daemon_pid = IPFSDaemon::get_existing_pid();
// Is IPFS Daemon already running?
// cppcheck-suppress knownConditionTrueFalse
if (daemon_pid > 0)
{
std::cout << "INFO: IPFS Daemon is already running. Do not start another IPFS process." << std::endl;
Expand Down
10 changes: 6 additions & 4 deletions src/main-window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <whereami.h>

#if defined(__APPLE__)
static void osx_will_quit_cb(__attribute__((unused)) GtkosxApplication* app, __attribute__((unused)) gpointer data)
static void osx_will_quit_cb(__attribute__((unused)) const GtkosxApplication* app, __attribute__((unused)) gpointer data)
{
gtk_main_quit();
}
Expand Down Expand Up @@ -358,6 +358,7 @@ void MainWindow::update_status_popover_and_icon()
void MainWindow::load_stored_settings()
{
// Set additional schema directory, when browser is not yet installed
// cppcheck-suppress knownConditionTrueFalse
if (!is_installed())
{
// Relative to the binary path
Expand Down Expand Up @@ -1065,6 +1066,7 @@ void MainWindow::init_mac_os()
osx_app = reinterpret_cast<GtkosxApplication*>(g_object_new(GTKOSX_TYPE_APPLICATION, NULL));
// TODO: Should I implement those terminate signals. Since I disabled quartz accelerators
MainWindow* mainWindow = this;
// If needed: reinterpret_cast<void(*)(GtkosxApplication*, gpointer)>(osx_will_quit_cb))
g_signal_connect(osx_app, "NSApplicationWillTerminate", G_CALLBACK(osx_will_quit_cb), mainWindow);
// TODO: Open file callback?
// g_signal_connect (osx_app, "NSApplicationOpenFile", G_CALLBACK (osx_open_file_cb), mainWindow);
Expand Down Expand Up @@ -1266,7 +1268,7 @@ void MainWindow::selectAll()
/**
* \brief Triggers when the textview widget changes size
*/
void MainWindow::on_size_alloc(__attribute__((unused)) Gdk::Rectangle& allocation)
void MainWindow::on_size_alloc(__attribute__((unused)) const Gdk::Rectangle& allocation)
{
if (!is_editor_enabled())
update_margins();
Expand Down Expand Up @@ -1810,7 +1812,7 @@ void MainWindow::forward()
/**
* \brief Fill-in table of contents and show
*/
void MainWindow::set_table_of_contents(std::vector<Glib::RefPtr<Gtk::TextMark>> headings)
void MainWindow::set_table_of_contents(const std::vector<Glib::RefPtr<Gtk::TextMark>>& headings)
{
Gtk::TreeRow heading1Row, heading2Row, heading3Row, heading4Row, heading5Row;
int previousLevel = 1; // Default heading 1
Expand Down Expand Up @@ -2083,7 +2085,7 @@ bool MainWindow::is_editor_enabled()
std::string MainWindow::get_icon_image_from_theme(const std::string& icon_name, const std::string& typeof_icon)
{
// Use data directory first, used when LibreWeb is installed (Linux or Windows)
for (std::string data_dir : Glib::get_system_data_dirs())
for (const std::string& data_dir : Glib::get_system_data_dirs())
{
std::vector<std::string> path_builder{data_dir, "libreweb", "images", "icons", current_icon_theme_, typeof_icon, icon_name + ".png"};
std::string file_path = Glib::build_path(G_DIR_SEPARATOR_S, path_builder);
Expand Down
4 changes: 2 additions & 2 deletions src/main-window.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class MainWindow : public Gtk::Window
void paste();
void del();
void selectAll();
void on_size_alloc(Gdk::Rectangle& allocation);
void on_size_alloc(const Gdk::Rectangle& allocation);
void on_toc_row_activated(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* column);
void new_doc();
void open();
Expand Down Expand Up @@ -334,7 +334,7 @@ class MainWindow : public Gtk::Window
void init_signals();
void init_mac_os();
bool is_installed();
void set_table_of_contents(std::vector<Glib::RefPtr<Gtk::TextMark>> headings);
void set_table_of_contents(const std::vector<Glib::RefPtr<Gtk::TextMark>>& headings);
void enable_edit();
void disable_edit();
bool is_editor_enabled();
Expand Down
2 changes: 1 addition & 1 deletion src/middleware.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Middleware : public MiddlewareInterface
{
public:
explicit Middleware(MainWindow& main_window, const std::string& timeout);
virtual ~Middleware();
virtual ~Middleware() override;
void do_request(const std::string& path = std::string(),
bool is_set_address_bar = true,
bool is_history_request = false,
Expand Down
3 changes: 2 additions & 1 deletion suppressions.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
missingIncludeSystem
missingInclude:lib/*
missingInclude
unusedFunction
*:lib/commonmarker/*
checkersReport

0 comments on commit ff964d2

Please sign in to comment.