Skip to content

Commit

Permalink
fix:various:fix compiler warnings (navit-gps#940)
Browse files Browse the repository at this point in the history
* fix:core:build without warnings

on my setup navit_core build without non avoidable warnings.

* fix:dbus:fix compiler warnings

* fix:gui/internal: remov compiler warnings

* fix:various:remove compiler warnings

* fix:various remove compiler warnings.

* fix:various: fix android compiler warnings
  • Loading branch information
metalstrolch authored and jkoan committed Jun 30, 2021
1 parent ba2e2cb commit acc719e
Show file tree
Hide file tree
Showing 29 changed files with 419 additions and 350 deletions.
13 changes: 7 additions & 6 deletions navit/binding/dbus/binding_dbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -626,13 +626,13 @@ static char *get_iter_name(char *type) {
}

static DBusHandlerResult request_attr_iter(DBusConnection *connection, DBusMessage *message, char *type,
struct attr_iter *(*func)(void)) {
struct attr_iter *(*func)(void*)) {
DBusMessage *reply;
char *iter_name;
char *opath;
struct attr_iter *attr_iter;

attr_iter=(*func)();
attr_iter=(*func)(NULL);
iter_name=get_iter_name(type);
opath=object_new(iter_name,attr_iter);
g_free(iter_name);
Expand Down Expand Up @@ -833,7 +833,7 @@ static DBusHandlerResult request_config_get_attr(DBusConnection *connection, DBu
}

static DBusHandlerResult request_config_attr_iter(DBusConnection *connection, DBusMessage *message) {
return request_attr_iter(connection, message, "config", (struct attr_iter * (*)(void))config_attr_iter_new);
return request_attr_iter(connection, message, "config", (struct attr_iter * (*)(void*))config_attr_iter_new);
}

static DBusHandlerResult request_config_attr_iter_destroy(DBusConnection *connection, DBusMessage *message) {
Expand Down Expand Up @@ -941,7 +941,7 @@ static DBusHandlerResult request_map_dump(DBusConnection *connection, DBusMessag
/* mapset */

static DBusHandlerResult request_mapset_attr_iter(DBusConnection *connection, DBusMessage *message) {
return request_attr_iter(connection, message, "mapset", (struct attr_iter * (*)(void))mapset_attr_iter_new);
return request_attr_iter(connection, message, "mapset", (struct attr_iter * (*)(void*))mapset_attr_iter_new);
}

static DBusHandlerResult request_mapset_attr_iter_destroy(DBusConnection *connection, DBusMessage *message) {
Expand Down Expand Up @@ -986,7 +986,7 @@ static DBusHandlerResult request_roadprofile_set_attr(DBusConnection *connection
}

static DBusHandlerResult request_roadprofile_attr_iter(DBusConnection *connection, DBusMessage *message) {
return request_attr_iter(connection, message, "roadprofile", (struct attr_iter * (*)(void))roadprofile_attr_iter_new);
return request_attr_iter(connection, message, "roadprofile", (struct attr_iter * (*)(void*))roadprofile_attr_iter_new);
}

static DBusHandlerResult request_roadprofile_attr_iter_destroy(DBusConnection *connection, DBusMessage *message) {
Expand Down Expand Up @@ -1232,6 +1232,7 @@ static DBusHandlerResult request_navit_traffic_export_gpx(DBusConnection *connec
" xmlns='http://www.topografix.com/GPX/1/1'\n"
" xsi:schemaLocation='http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd'>\n";
char *trailer = "</gpx>\n";
memset(&c_last, 0, sizeof(c_last));

navit = object_get_from_message(message, "navit");
if (! navit)
Expand Down Expand Up @@ -1955,7 +1956,7 @@ static DBusHandlerResult request_vehicleprofile_set_attr(DBusConnection *connect

static DBusHandlerResult request_vehicleprofile_attr_iter(DBusConnection *connection, DBusMessage *message) {
return request_attr_iter(connection, message, "vehicleprofile",
(struct attr_iter * (*)(void))vehicleprofile_attr_iter_new);
(struct attr_iter * (*)(void*))vehicleprofile_attr_iter_new);
}

static DBusHandlerResult request_vehicleprofile_attr_iter_destroy(DBusConnection *connection, DBusMessage *message) {
Expand Down
20 changes: 14 additions & 6 deletions navit/font/freetype/font_freetype.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ static int library_init = 0;
static int library_deinit = 0;


static void font_freetype_get_text_bbox(struct graphics_priv *gr, struct font_freetype_font *font, char *text, int dx, int dy, struct point *ret, int estimate) {
static void font_freetype_get_text_bbox(struct graphics_priv *gr, struct font_freetype_font *font, char *text, int dx,
int dy, struct point *ret, int estimate) {
char *p = text;
FT_BBox bbox;
FT_UInt glyph_index;
Expand Down Expand Up @@ -233,8 +234,12 @@ static struct font_freetype_text *font_freetype_text_new(char *text, struct font
#else
fribidi_charset_to_unicode(FRIBIDI_CHAR_SET_UTF8, text, textlen, unicode_text);
#endif
fribidi_log2vis(unicode_text, unicode_len, &base, visual_unicode_text, NULL, NULL, NULL);
// TODO: check return value
/* fribidi_log2vis seems to be deprecated, but I don't know what to replace it with */
if(fribidi_log2vis(unicode_text, unicode_len, &base, visual_unicode_text, NULL, NULL, NULL) == 0) {
dbg(lvl_error,"fribidi_log2vis error condition detected. Try to recover");
/* error condition. Continue withthe original unicode text instead */
memcpy(visual_unicode_text, unicode_text, sizeof(unicode_text));
}
#ifdef FRIBIDIOLD
fribidi_unicode_to_utf8(visual_unicode_text, unicode_len, visual_text);
#else
Expand Down Expand Up @@ -362,7 +367,8 @@ static FT_Error face_requester( FTC_FaceID face_id, FT_Library library, FT_Point
#endif

/** Implementation of font_freetype_methods.font_new */
static struct font_freetype_font *font_freetype_font_new(struct graphics_priv *gr, struct graphics_font_methods *meth, char *fontfamily, int size, int flags) {
static struct font_freetype_font *font_freetype_font_new(struct graphics_priv *gr, struct graphics_font_methods *meth,
char *fontfamily, int size, int flags) {
struct font_freetype_font *font =
g_new(struct font_freetype_font, 1);
int exact, found=0;
Expand Down Expand Up @@ -503,7 +509,8 @@ static struct font_freetype_font *font_freetype_font_new(struct graphics_priv *g
}

/** Implementation of font_freetype_methods.get_shadow. */
static int font_freetype_glyph_get_shadow(struct font_freetype_glyph *g, unsigned char *data, int stride, struct color *foreground, struct color *background) {
static int font_freetype_glyph_get_shadow(struct font_freetype_glyph *g, unsigned char *data, int stride,
struct color *foreground, struct color *background) {
int x, y, w = g->w, h = g->h;
unsigned int bg, fg;
unsigned char *pm, *psp,*ps,*psn;
Expand Down Expand Up @@ -555,7 +562,8 @@ static int font_freetype_glyph_get_shadow(struct font_freetype_glyph *g, unsigne
}

/** Implementation of font_freetype_methods.get_glyph. */
static int font_freetype_glyph_get_glyph(struct font_freetype_glyph *g, unsigned char *data, int stride, struct color *fg, struct color *bg, struct color *transparent) {
static int font_freetype_glyph_get_glyph(struct font_freetype_glyph *g, unsigned char *data, int stride,
struct color *fg, struct color *bg, struct color *transparent) {
int x, y, w = g->w, h = g->h;
unsigned int tr;
unsigned char v,vi,*pm, *ps;
Expand Down
8 changes: 5 additions & 3 deletions navit/geom.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ int geom_poly_point_inside(struct coord *cp, int count, struct coord *c) {



GList *geom_poly_segments_insert(GList *list, struct geom_poly_segment *first, struct geom_poly_segment *second, struct geom_poly_segment *third) {
GList *geom_poly_segments_insert(GList *list, struct geom_poly_segment *first, struct geom_poly_segment *second,
struct geom_poly_segment *third) {
int count;
struct geom_poly_segment *ret;
struct coord *pos;
Expand Down Expand Up @@ -226,15 +227,16 @@ GList *geom_poly_segments_insert(GList *list, struct geom_poly_segment *first, s
return list;
}

void geom_poly_segment_destroy(struct geom_poly_segment *seg) {
/* unused id for GFunc compatibiliy */
void geom_poly_segment_destroy(struct geom_poly_segment *seg, void * unused) {
g_free(seg->first);
g_free(seg);
}

GList *geom_poly_segments_remove(GList *list, struct geom_poly_segment *seg) {
if (seg) {
list=g_list_remove(list, seg);
geom_poly_segment_destroy(seg);
geom_poly_segment_destroy(seg, NULL);
}
return list;
}
Expand Down
25 changes: 14 additions & 11 deletions navit/geom.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,23 @@ extern "C" {

#define sq(x) ((double)(x)*(x))

struct rect {struct coord l,h;};
struct rect {
struct coord l,h;
};

enum geom_poly_segment_type {
geom_poly_segment_type_none,
geom_poly_segment_type_way_inner,
geom_poly_segment_type_way_outer,
geom_poly_segment_type_way_left_side,
geom_poly_segment_type_way_right_side,
geom_poly_segment_type_way_unknown,
geom_poly_segment_type_none,
geom_poly_segment_type_way_inner,
geom_poly_segment_type_way_outer,
geom_poly_segment_type_way_left_side,
geom_poly_segment_type_way_right_side,
geom_poly_segment_type_way_unknown,

};

struct geom_poly_segment {
enum geom_poly_segment_type type;
struct coord *first,*last;
enum geom_poly_segment_type type;
struct coord *first,*last;
};
/* prototypes */
void geom_coord_copy(struct coord *from, struct coord *to, int count, int reverse);
Expand All @@ -56,8 +58,9 @@ long long geom_poly_area(struct coord *c, int count);
int geom_poly_centroid(struct coord *c, int count, struct coord *r);
int geom_poly_point_inside(struct coord *cp, int count, struct coord *c);
int geom_poly_closest_point(struct coord *pl, int count, struct coord *p, struct coord *c);
GList *geom_poly_segments_insert(GList *list, struct geom_poly_segment *first, struct geom_poly_segment *second, struct geom_poly_segment *third);
void geom_poly_segment_destroy(struct geom_poly_segment *seg);
GList *geom_poly_segments_insert(GList *list, struct geom_poly_segment *first, struct geom_poly_segment *second,
struct geom_poly_segment *third);
void geom_poly_segment_destroy(struct geom_poly_segment *seg, void * unused);
GList *geom_poly_segments_remove(GList *list, struct geom_poly_segment *seg);
int geom_poly_segment_compatible(struct geom_poly_segment *s1, struct geom_poly_segment *s2, int dir);
GList *geom_poly_segments_sort(GList *in, enum geom_poly_segment_type type);
Expand Down
23 changes: 16 additions & 7 deletions navit/graphics/opengl/graphics_opengl.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,12 @@ static struct graphics_gc_priv *gc_new(struct graphics_priv *gr, struct graphics
return gc;
}

#ifdef HAVE_FREEIMAGE
static struct graphics_image_priv image_error;
#endif

static struct graphics_image_priv *image_new(struct graphics_priv *gr, struct graphics_image_methods *meth, char *path, int *w, int *h, struct point *hot, int rotation) {
static struct graphics_image_priv *image_new(struct graphics_priv *gr, struct graphics_image_methods *meth, char *path,
int *w, int *h, struct point *hot, int rotation) {
#ifdef HAVE_FREEIMAGE
FIBITMAP *image;
RGBQUAD aPixel;
Expand Down Expand Up @@ -797,7 +800,8 @@ static void draw_rectangle(struct graphics_priv *gr, struct graphics_gc_priv *gc
graphics_priv_root->dirty = 1;
}

static void display_text_draw(struct font_freetype_text *text, struct graphics_priv *gr, struct graphics_gc_priv *fg, struct graphics_gc_priv *bg, int color, struct point *p) {
static void display_text_draw(struct font_freetype_text *text, struct graphics_priv *gr, struct graphics_gc_priv *fg,
struct graphics_gc_priv *bg, int color, struct point *p) {
int i, x, y, stride;
struct font_freetype_glyph *g, **gp;
unsigned char *shadow, *glyph;
Expand Down Expand Up @@ -927,7 +931,8 @@ static void display_text_draw(struct font_freetype_text *text, struct graphics_p
}
}

static void draw_text(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct graphics_gc_priv *bg, struct graphics_font_priv *font, char *text, struct point *p, int dx, int dy) {
static void draw_text(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct graphics_gc_priv *bg,
struct graphics_font_priv *font, char *text, struct point *p, int dx, int dy) {
if ((gr->parent && !gr->parent->overlay_enabled)
|| (gr->parent && gr->parent->overlay_enabled
&& !gr->overlay_enabled)) {
Expand Down Expand Up @@ -955,7 +960,8 @@ static void draw_text(struct graphics_priv *gr, struct graphics_gc_priv *fg, str
}


static void draw_image(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, struct graphics_image_priv *img) {
static void draw_image(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p,
struct graphics_image_priv *img) {
#ifdef USE_OPENGLES
draw_image_es(gr, p, img->w, img->h, img->data);
#else
Expand Down Expand Up @@ -1159,7 +1165,8 @@ static void *get_data(struct graphics_priv *this, const char *type) {
this->platform=graphics_opengl_egl_new(this->window_system_methods->get_display(this->window_system),
this->window_system_methods->get_window(this->window_system),
&this->platform_methods);
this->window_system_methods->set_callbacks(this->window_system, this, resize_callback_do, click_notify_do, motion_notify_do, NULL);
this->window_system_methods->set_callbacks(this->window_system, this, resize_callback_do, click_notify_do,
motion_notify_do, NULL);
resize_callback(this->width,this->height);
#if 0
glClearColor ( 0.4, 0.4, 0.4, 1);
Expand Down Expand Up @@ -1398,7 +1405,8 @@ static void motion_notify(int x, int y) {
static gboolean graphics_opengl_idle(void *data) {
static int opengl_init_ok = 0;
if (!opengl_init_ok) {
callback_list_call_attr_2(graphics_priv_root->cbl, attr_resize, GINT_TO_POINTER (graphics_priv_root->width), GINT_TO_POINTER (graphics_priv_root->height));
callback_list_call_attr_2(graphics_priv_root->cbl, attr_resize, GINT_TO_POINTER (graphics_priv_root->width),
GINT_TO_POINTER (graphics_priv_root->height));
opengl_init_ok = 1;
} else {

Expand Down Expand Up @@ -1494,7 +1502,8 @@ static void glut_close(void) {
}


static struct graphics_priv *graphics_opengl_new(struct navit *nav, struct graphics_methods *meth, struct attr **attrs, struct callback_list *cbl) {
static struct graphics_priv *graphics_opengl_new(struct navit *nav, struct graphics_methods *meth, struct attr **attrs,
struct callback_list *cbl) {
struct attr *attr;

if (!event_request_system("glib", "graphics_opengl_new"))
Expand Down
11 changes: 8 additions & 3 deletions navit/gui/gtk/destination.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
#include "projection.h"
#include "navit_nls.h"
#include "bookmarks.h"

#ifndef _WIN32
#include <errno.h>
#endif
#define COL_COUNT 8

static struct search_param {
Expand Down Expand Up @@ -78,7 +80,6 @@ static void button_map(GtkWidget *widget, struct search_param *search) {
GtkTreeViewColumn *focus_column;
struct pcoord *point=NULL; /* A pointer on the geographical position of the selected map point */
GtkTreeIter iter;
char *label;
GList* p;

gtk_tree_view_get_cursor(GTK_TREE_VIEW(search->treeview), &path, &focus_column);
Expand Down Expand Up @@ -368,6 +369,7 @@ static void parse_xkbd_args (const char *cmd, char **argv) {
bufp = buf;
break;
}
/* fall through */
default:
*bufp++ = *p;
break;
Expand Down Expand Up @@ -399,7 +401,10 @@ static int spawn_xkbd (char *xkbd_path, char *xkbd_str) {
int a = 0;
size_t n;

pipe (fd);
if(pipe (fd) < 0) {
dbg(lvl_error,"Unable to create pipe (%s). Do not try to spawn keyboard.", strerror(errno));
return 0;
}
kbd_pid = fork ();
if (kbd_pid == 0) {
close (fd[0]);
Expand Down
23 changes: 12 additions & 11 deletions navit/gui/gtk/gui_gtk_statusbar.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
struct statusbar_priv {
struct gui_priv *gui;
GtkWidget *hbox;
char gps_text[128];
char gps_text[500];
GtkWidget *gps;
char route_text[128];
GtkWidget *route;
Expand Down Expand Up @@ -88,7 +88,7 @@ static void statusbar_route_update(struct statusbar_priv *this, struct navit *na
double route_len=0; /* Distance to destination. We get it in kilometers. */
time_t eta;
struct tm *eta_tm=NULL;
char buffer[128];
char buffer[109];
double lng, lat, direction=0, height=0, speed=0, hdop=0;
int sats=0, qual=0;
int status=0;
Expand Down Expand Up @@ -155,15 +155,16 @@ static void statusbar_route_update(struct statusbar_priv *this, struct navit *na
qual=attr.u.num;
coord_format(lat,lng,DEGREES_MINUTES_SECONDS,buffer,sizeof(buffer));

sprintf(this->gps_text,"GPS:%s %02d/%02d HD:%02.2f %s %4.0f%s %3.0f°%-2s %3.1f%s",
status_fix2str(status),
sats, qual, hdop, buffer,
imperial ? height * FEET_PER_METER : height,
imperial == TRUE ? "\'" : "m",
direction, dir,
imperial == TRUE ? speed * KILOMETERS_TO_MILES : speed,
imperial == TRUE ? " mph" : "km/h"
);
snprintf(this->gps_text,sizeof(this->gps_text),"GPS:%s %02d/%02d HD:%02.2f %s %4.0f%s %3.0f°%-2s %3.1f%s",
status_fix2str(status),
sats, qual, hdop, buffer,
imperial ? height * FEET_PER_METER : height,
imperial == TRUE ? "\'" : "m",
direction, dir,
imperial == TRUE ? speed * KILOMETERS_TO_MILES : speed,
imperial == TRUE ? " mph" : "km/h"
);
this->gps_text[sizeof(this->gps_text)-1] = 0;

gtk_label_set_text(GTK_LABEL(this->gps), this->gps_text);
}
Expand Down
6 changes: 4 additions & 2 deletions navit/gui/internal/gui_internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -1641,6 +1641,7 @@ char *gui_internal_cmd_match_expand(char *pattern, struct attr **in) {
break;
case '\\':
p=*pattern++;
/* fall through */
default:
*r++=p;
}
Expand All @@ -1662,6 +1663,7 @@ static int gui_internal_match(const char *pattern, const char *string) {
break;
case '\\':
p=*pattern++;
/* fall through */
default:
if (*string++ != p)
return 0;
Expand Down Expand Up @@ -1705,7 +1707,7 @@ int gui_internal_set(char *remove, char *add) {


static void gui_internal_window_closed(struct gui_priv *this) {
gui_internal_cmd2_quit(this, NULL, NULL, NULL, NULL);
gui_internal_cmd2_quit(this, NULL, NULL, NULL);
}


Expand Down Expand Up @@ -1914,7 +1916,7 @@ static int gui_internal_is_active_vehicle(struct gui_priv *this, struct vehicle

static void save_vehicle_xml(struct vehicle *v) {
struct attr attr;
struct attr_iter *iter=vehicle_attr_iter_new();
struct attr_iter *iter=vehicle_attr_iter_new(NULL);
int childs=0;
printf("<vehicle");
while (vehicle_get_attr(v, attr_any_xml, &attr, iter)) {
Expand Down
Loading

0 comments on commit acc719e

Please sign in to comment.