[gthumb] Fixed 'may be used uninitialized' warnings
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] Fixed 'may be used uninitialized' warnings
- Date: Sun, 29 Nov 2020 09:13:55 +0000 (UTC)
commit a23f17e1b27257a56b6ed69e8e811da9cce22dd6
Author: Paolo Bacchilega <paobac src gnome org>
Date: Sun Nov 29 09:52:43 2020 +0100
Fixed 'may be used uninitialized' warnings
extensions/map_view/gth-map-view.c | 4 ++--
gthumb/cairo-utils.c | 5 +++++
gthumb/gth-image-viewer.c | 23 ++++++++++++++++-------
gthumb/gtk-utils.c | 2 +-
gthumb/uri-utils.c | 6 +++---
5 files changed, 27 insertions(+), 13 deletions(-)
---
diff --git a/extensions/map_view/gth-map-view.c b/extensions/map_view/gth-map-view.c
index e37291c8..0f1b9e92 100644
--- a/extensions/map_view/gth-map-view.c
+++ b/extensions/map_view/gth-map-view.c
@@ -143,8 +143,8 @@ gth_map_view_get_coordinates (GthMapView *self,
double *out_longitude)
{
int coordinates_available;
- double latitude;
- double longitude;
+ double latitude = 0.0;
+ double longitude = 0.0;
coordinates_available = 0;
diff --git a/gthumb/cairo-utils.c b/gthumb/cairo-utils.c
index e6ad4c91..dce1ac54 100644
--- a/gthumb/cairo-utils.c
+++ b/gthumb/cairo-utils.c
@@ -1446,6 +1446,11 @@ _cairo_create_dnd_icon (cairo_surface_t *image,
frame_rect.width = thumbnail_rect.width;
frame_rect.height = icon_size;
break;
+
+ default:
+ icon_rect.width = 0;
+ icon_rect.height = 0;
+ break;
}
if (multi_dnd) {
diff --git a/gthumb/gth-image-viewer.c b/gthumb/gth-image-viewer.c
index 58d346ae..b0b556db 100644
--- a/gthumb/gth-image-viewer.c
+++ b/gthumb/gth-image-viewer.c
@@ -588,8 +588,8 @@ static double
get_zoom_to_fit (GthImageViewer *self,
GtkAllocation *allocation)
{
- int original_width;
- int original_height;
+ int original_width = 0;
+ int original_height = 0;
int frame_border_2;
double x_level;
double y_level;
@@ -597,6 +597,9 @@ get_zoom_to_fit (GthImageViewer *self,
gth_image_viewer_get_original_size (self, &original_width, &original_height);
frame_border_2 = _gth_image_viewer_get_frame_border (self) * 2;
+ if ((original_width == 0) || (original_height == 0))
+ return 1.0;
+
x_level = (double) (allocation->width - frame_border_2) / original_width;
y_level = (double) (allocation->height - frame_border_2) / original_height;
@@ -608,13 +611,16 @@ static double
get_zoom_to_fit_width (GthImageViewer *self,
GtkAllocation *allocation)
{
- int original_width;
+ int original_width = 0;
int frame_border_2;
gth_image_viewer_get_original_size (self, &original_width, NULL);
frame_border_2 = _gth_image_viewer_get_frame_border (self) * 2;
- return (double) (allocation->width - frame_border_2) / original_width;
+ if (original_width > 0)
+ return (double) (allocation->width - frame_border_2) / original_width;
+ else
+ return 0;
}
@@ -622,13 +628,16 @@ static double
get_zoom_to_fit_height (GthImageViewer *self,
GtkAllocation *allocation)
{
- int original_height;
+ int original_height = 0;
int frame_border_2;
gth_image_viewer_get_original_size (self, NULL, &original_height);
frame_border_2 = _gth_image_viewer_get_frame_border (self) * 2;
- return (double) (allocation->height - frame_border_2) / original_height;
+ if (original_height > 0)
+ return (double) (allocation->height - frame_border_2) / original_height;
+ else
+ return 0;
}
@@ -2612,7 +2621,7 @@ gth_image_viewer_paint (GthImageViewer *self,
int height,
cairo_filter_t filter)
{
- int original_width;
+ int original_width = 0;
int surface_width;
double zoom_level;
double src_dx;
diff --git a/gthumb/gtk-utils.c b/gthumb/gtk-utils.c
index 16ff339b..7c5731b0 100644
--- a/gthumb/gtk-utils.c
+++ b/gthumb/gtk-utils.c
@@ -1242,7 +1242,7 @@ _gtk_window_get_monitor_info (GtkWindow *window,
if ((number != NULL) || (name != NULL)) {
GdkDisplay *display;
int monitor_num;
- const char *monitor_name;
+ const char *monitor_name = NULL;
int i;
display = gdk_monitor_get_display (monitor);
diff --git a/gthumb/uri-utils.c b/gthumb/uri-utils.c
index 4c417db5..30ea6041 100644
--- a/gthumb/uri-utils.c
+++ b/gthumb/uri-utils.c
@@ -77,7 +77,7 @@ _g_uri_parse (const char *uri,
UriState state;
const char *p;
gunichar c;
- const char *part_begin;
+ const char *part_begin = NULL;
if (uri == NULL)
return FALSE;
@@ -499,8 +499,8 @@ _g_uri_get_part (const char *uri,
UriPart part)
{
UriInfo info;
- const char *begin;
- gsize size;
+ const char *begin = NULL;
+ gsize size = 0;
if (! _g_uri_parse (uri, &info))
return NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]