From c57bc8d8c3026ca069c3e7e54e0f29469d0312af Mon Sep 17 00:00:00 2001 From: Bastian Koppelmann Date: Tue, 30 Aug 2022 11:46:08 +0200 Subject: fix:navit: Fix -Waddress warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit since 'lastline[]' is stack-allocated it can never be NULL, thus we don't need to check for that. This fixes the following compiler warning: warning: the comparison will always evaluate as ‘true’ for the address of ‘lastline’ will never be NULL [-Waddress] 1809 | if ((lastline != NULL) && (strcmp(lastline, TEXTFILE_COMMENT_NAVI_STOPPED))) { --- navit/navit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/navit/navit.c b/navit/navit.c index d3ef113f5..f01c9efcd 100644 --- a/navit/navit.c +++ b/navit/navit.c @@ -1806,7 +1806,7 @@ static int navit_former_destinations_active(struct navit *this_) { if (destination_file) { while(fgets(lastline, sizeof(lastline), destination_file)); fclose(destination_file); - if ((lastline != NULL) && (strcmp(lastline, TEXTFILE_COMMENT_NAVI_STOPPED))) { + if (strcmp(lastline, TEXTFILE_COMMENT_NAVI_STOPPED)) { active=1; } } -- cgit v1.2.1 From ab53751e89770f347a834ca2bb380c882249f8da Mon Sep 17 00:00:00 2001 From: Bastian Koppelmann Date: Tue, 30 Aug 2022 11:51:45 +0200 Subject: fix:gui:qt5_qml: Fix -Wmissing-prototype warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit get_icon() was declared in proxy.h, which we never included. This fixes: proxy.c:34:52: warning: unused variable ‘img’ [-Wunused-variable] 34 | struct graphics_image *img; --- navit/gui/qt5_qml/proxy.c | 1 + 1 file changed, 1 insertion(+) diff --git a/navit/gui/qt5_qml/proxy.c b/navit/gui/qt5_qml/proxy.c index 399925519..3e970129d 100644 --- a/navit/gui/qt5_qml/proxy.c +++ b/navit/gui/qt5_qml/proxy.c @@ -9,6 +9,7 @@ #include "transform.h" #include "debug.h" #include "search.h" +#include "proxy.h" char * get_icon(struct navit *nav, struct item *item) { -- cgit v1.2.1 From 016d6b357484ea34337f0c80ce74e77601cf3d1a Mon Sep 17 00:00:00 2001 From: Bastian Koppelmann Date: Tue, 30 Aug 2022 12:50:05 +0200 Subject: Fix:graphics:svg_debug: Fix -Wincompatible-pointer-types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit we are assigning a char* to int*. So lets explicitly cast it to int*. This fixes: graphics_svg_debug.c:173:16: warning: assignment to ‘unsigned int *’ from incompatible pointer type ‘unsigned char *’ [-Wincompatible-pointer-types] 173 | gc->dashed = dash_list; | ^ --- navit/graphics/svg_debug/graphics_svg_debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/navit/graphics/svg_debug/graphics_svg_debug.c b/navit/graphics/svg_debug/graphics_svg_debug.c index 348906ad8..23ce4a297 100644 --- a/navit/graphics/svg_debug/graphics_svg_debug.c +++ b/navit/graphics/svg_debug/graphics_svg_debug.c @@ -170,7 +170,7 @@ static void svg_debug_gc_set_linewidth(struct graphics_gc_priv *gc, int w) { static void svg_debug_gc_set_dashes(struct graphics_gc_priv *gc, int w, int offset, unsigned char *dash_list, int n) { - gc->dashed = dash_list; + gc->dashed = (unsigned int*)dash_list; gc->is_dashed = TRUE; if (gc->graphics_gc_methods_proxy->gc_set_dashes) { gc->graphics_gc_methods_proxy->gc_set_dashes(gc->graphics_gc_priv_proxy, -- cgit v1.2.1 From 2536ca07bb3a98514404859d2427c99bfbdddf7d Mon Sep 17 00:00:00 2001 From: Bastian Koppelmann Date: Tue, 30 Aug 2022 13:03:57 +0200 Subject: Fix:vehicle_demo: Fix -Wparentheses warning This fixes the following warning: vehicle_demo.c:105:12: warning: suggest parentheses around assignment used as truth value [-Wparentheses] 105 | if(flags = tracking_get_current_flags(navit_get_tracking(priv->navit))) { | ^~~~~ --- navit/vehicle/demo/vehicle_demo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/navit/vehicle/demo/vehicle_demo.c b/navit/vehicle/demo/vehicle_demo.c index fbca975d3..724b54048 100644 --- a/navit/vehicle/demo/vehicle_demo.c +++ b/navit/vehicle/demo/vehicle_demo.c @@ -102,7 +102,7 @@ static int vehicle_demo_position_attr_get(struct vehicle_priv *priv, attr->u.str=priv->timep; break; case attr_position_fix_type: - if(flags = tracking_get_current_flags(navit_get_tracking(priv->navit))) { + if((flags = tracking_get_current_flags(navit_get_tracking(priv->navit)))) { if(*flags & AF_UNDERGROUND) attr->u.num = 0; } else -- cgit v1.2.1 From eb0fe23700304dd564bee5b8851dd6affc776ef2 Mon Sep 17 00:00:00 2001 From: Bastian Koppelmann Date: Tue, 30 Aug 2022 13:19:21 +0200 Subject: Fix:graphics:qt5: Fix -Wunused-variable for QPainter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes the warning: QNavitQuick.cpp:170:15: warning: unused variable ‘painter’ [-Wunused-variable] 170 | QPainter* painter = NULL; | ^~~~~~~ --- navit/graphics/qt5/QNavitQuick.cpp | 1 - navit/graphics/qt5/QNavitWidget.cpp | 1 - 2 files changed, 2 deletions(-) diff --git a/navit/graphics/qt5/QNavitQuick.cpp b/navit/graphics/qt5/QNavitQuick.cpp index 966072852..ec734c7de 100644 --- a/navit/graphics/qt5/QNavitQuick.cpp +++ b/navit/graphics/qt5/QNavitQuick.cpp @@ -167,7 +167,6 @@ void QNavitQuick::keyReleaseEvent(QKeyEvent* event) { void QNavitQuick::geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry) { dbg(lvl_debug, "enter"); QQuickPaintedItem::geometryChanged(newGeometry, oldGeometry); - QPainter* painter = NULL; if (graphics_priv == NULL) { dbg(lvl_debug, "Context not set, aborting"); return; diff --git a/navit/graphics/qt5/QNavitWidget.cpp b/navit/graphics/qt5/QNavitWidget.cpp index 43c04d87f..74dddf1db 100644 --- a/navit/graphics/qt5/QNavitWidget.cpp +++ b/navit/graphics/qt5/QNavitWidget.cpp @@ -95,7 +95,6 @@ void QNavitWidget::paintEvent(QPaintEvent* event) { } void QNavitWidget::resizeEvent(QResizeEvent* event) { - QPainter* painter = NULL; if (graphics_priv->pixmap != NULL) { if((width() != graphics_priv->pixmap->width()) || (height() != graphics_priv->pixmap->height())) { delete graphics_priv->pixmap; -- cgit v1.2.1 From 691760ef01179348bd0df1e7ee6da38e6f88d3de Mon Sep 17 00:00:00 2001 From: Bastian Koppelmann Date: Tue, 30 Aug 2022 13:26:40 +0200 Subject: Fix:gui:qt5_qml: Fix -Wwrite-strings warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We assign string constants to a char* which will lead to an error if anyone tries to write that pointer, as constant data is mapped read-only. This patch makes these const char* pointers. Fixes the warning: backend.cpp:588:27: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings] 588 | _current_street = "Enter Street"; | ^~~~~~~~~~~~~~ --- navit/gui/qt5_qml/backend.cpp | 6 +++--- navit/gui/qt5_qml/backend.h | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/navit/gui/qt5_qml/backend.cpp b/navit/gui/qt5_qml/backend.cpp index c9733b173..11057c76c 100644 --- a/navit/gui/qt5_qml/backend.cpp +++ b/navit/gui/qt5_qml/backend.cpp @@ -78,9 +78,9 @@ void Backend::get_maps() { label = g_strdup(description.u.str); } else { if (!map_get_attr(attr.u.map, attr_type, &type, NULL)) - type.u.str = ""; + type.u.str = (char*)""; if (!map_get_attr(attr.u.map, attr_data, &data, NULL)) - data.u.str = ""; + data.u.str = (char*)""; label = g_strdup_printf("%s:%s", type.u.str, data.u.str); } is_active = false; @@ -501,7 +501,7 @@ void Backend::updateSearch(QString text) { search->partial = 1; dbg(lvl_debug,"attempting to use country '%s'", _country_iso2); search_attr.type=attr_country_iso2; - search_attr.u.str=_country_iso2; + search_attr.u.str=(char*)_country_iso2; search_list_search(search->sl, &search_attr, 0); while((res=search_list_get_result(search->sl))); diff --git a/navit/gui/qt5_qml/backend.h b/navit/gui/qt5_qml/backend.h index 259be516c..9a27590d5 100644 --- a/navit/gui/qt5_qml/backend.h +++ b/navit/gui/qt5_qml/backend.h @@ -104,10 +104,10 @@ private: VehicleObject * m_currentVehicle; QList _search_results; void set_default_country(); - char * _country_iso2; - char * _current_country; - char * _current_town; - char * _current_street; + const char * _country_iso2; + const char * _current_country; + const char * _current_town; + const char * _current_street; struct search_param *search; enum attr_type _search_context; }; -- cgit v1.2.1 From 9279593543065d1453cf83d217b5b385ca2b506d Mon Sep 17 00:00:00 2001 From: Bastian Koppelmann Date: Tue, 30 Aug 2022 13:30:45 +0200 Subject: Fix:gui:qt5_qml: Fix -Wunused-variable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit this fixes the warnings: backend.cpp:176:25: warning: unused variable ‘nav’ [-Wunused-variable] 176 | struct navigation * nav = NULL; | ^~~ --- navit/gui/qt5_qml/backend.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/navit/gui/qt5_qml/backend.cpp b/navit/gui/qt5_qml/backend.cpp index 11057c76c..af1b42aa5 100644 --- a/navit/gui/qt5_qml/backend.cpp +++ b/navit/gui/qt5_qml/backend.cpp @@ -63,16 +63,13 @@ void Backend::showMenu(struct point *p) { * @returns nothing */ void Backend::get_maps() { - struct attr attr, on, off, description, type, data, active; + struct attr attr, description, type, data, active; char * label; bool is_active; struct attr_iter * iter; _maps.clear(); iter = navit_attr_iter_new(NULL); - on.type = off.type = attr_active; - on.u.num = 1; - off.u.num = 0; while (navit_get_attr(this->nav, attr_map, &attr, iter)) { if (map_get_attr(attr.u.map, attr_description, &description, NULL)) { label = g_strdup(description.u.str); @@ -159,7 +156,6 @@ void Backend::set_engine(QQmlApplicationEngine * engine) { * @returns 0 if the item should be discarded, 1 otherwise */ int Backend::filter_pois(struct item *item) { - enum item_type *types; enum item_type type=item->type; if (type >= type_line) return 0; @@ -173,7 +169,6 @@ int Backend::filter_pois(struct item *item) { */ void Backend::get_bookmarks() { struct attr attr,mattr; - struct navigation * nav = NULL; struct item *item; struct coord c; struct pcoord pc; -- cgit v1.2.1 From eb03d7e6ea92c28a6be4d4bfb46f98fc3e8fb90c Mon Sep 17 00:00:00 2001 From: Bastian Koppelmann Date: Tue, 30 Aug 2022 13:39:47 +0200 Subject: Fix:gui/qt5_qml: Fix -Wreorder MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit member variables ought to be initialized in the same order as they are declared. This fixes the warning: qml_poi.h:47:13: warning: ‘PoiObject::m_icon’ will be initialized after [-Wreorder] 47 | QString m_icon; | ^~~~~~ --- navit/gui/qt5_qml/qml_bookmark.cpp | 2 +- navit/gui/qt5_qml/qml_poi.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/navit/gui/qt5_qml/qml_bookmark.cpp b/navit/gui/qt5_qml/qml_bookmark.cpp index 5f46a3a44..acfa987fb 100644 --- a/navit/gui/qt5_qml/qml_bookmark.cpp +++ b/navit/gui/qt5_qml/qml_bookmark.cpp @@ -8,7 +8,7 @@ BookmarkObject::BookmarkObject( const QString &name, struct pcoord &coords, QObject *parent) - : QObject(parent), m_name(name), m_coords(coords) { + : QObject(parent), m_coords(coords), m_name(name) { } QString BookmarkObject::name() const { diff --git a/navit/gui/qt5_qml/qml_poi.cpp b/navit/gui/qt5_qml/qml_poi.cpp index 8f0a0ab64..3e9c56745 100644 --- a/navit/gui/qt5_qml/qml_poi.cpp +++ b/navit/gui/qt5_qml/qml_poi.cpp @@ -11,7 +11,7 @@ PoiObject::PoiObject( const QString &icon, struct pcoord &coords, QObject *parent) - : QObject(parent), m_name(name), m_type(type), m_icon(icon), m_coords(coords) { + : QObject(parent), m_coords(coords), m_name(name), m_type(type), m_icon(icon) { } QString PoiObject::name() const { -- cgit v1.2.1 From cb4216da50a5ead25f3bb086740b1a7e543fb4be Mon Sep 17 00:00:00 2001 From: Bastian Koppelmann Date: Tue, 30 Aug 2022 13:47:30 +0200 Subject: Fix:gui:qt5_qml: Fix -Wunused-variable for proxy.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes the warning: proxy.c:35:52: warning: unused variable ‘img’ [-Wunused-variable] 35 | struct graphics_image *img; | --- navit/gui/qt5_qml/proxy.c | 1 - 1 file changed, 1 deletion(-) diff --git a/navit/gui/qt5_qml/proxy.c b/navit/gui/qt5_qml/proxy.c index 3e970129d..c38fe37e7 100644 --- a/navit/gui/qt5_qml/proxy.c +++ b/navit/gui/qt5_qml/proxy.c @@ -32,7 +32,6 @@ char * get_icon(struct navit *nav, struct item *item) { if(el->type==element_icon) { char *src; char *icon; - struct graphics_image *img; if(item_is_custom_poi(*item)) { struct map_rect *mr=map_rect_new(item->map, NULL); item=map_rect_get_item_byid(mr, item->id_hi, item->id_lo); -- cgit v1.2.1 From 69d870e276b4511aba56d4a13b998a4040b1d1eb Mon Sep 17 00:00:00 2001 From: Stefan Wildemann Date: Wed, 21 Sep 2022 21:38:10 +0200 Subject: fix:core:Forcefully terminate string read with fgets --- navit/navit.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/navit/navit.c b/navit/navit.c index f01c9efcd..e6e43064d 100644 --- a/navit/navit.c +++ b/navit/navit.c @@ -1806,6 +1806,8 @@ static int navit_former_destinations_active(struct navit *this_) { if (destination_file) { while(fgets(lastline, sizeof(lastline), destination_file)); fclose(destination_file); + /*forcefully terminate the string, there is no proper fgets error handling.*/ + lastline[sizeof(lastline) -1] = 0; if (strcmp(lastline, TEXTFILE_COMMENT_NAVI_STOPPED)) { active=1; } -- cgit v1.2.1