Merge branch 'more_warnings' into 'main'

Misc improvements (more gcc warnings, fix memory leaks, etc)

See merge request Zwarf/picplanner!7
main
Zwarf 2023-11-13 12:37:30 +00:00
commit 3c60287c0a
22 zmienionych plików z 212 dodań i 274 usunięć

Wyświetl plik

@ -16,9 +16,53 @@ configure_file(
output: 'picplanner-config.h',
configuration: config_h,
)
add_project_arguments([
'-I' + meson.build_root(),
], language: 'c')
cc = meson.get_compiler('c')
global_c_args = ['-I' + meson.build_root()]
test_c_args = [
'-Wcast-align',
'-Wdate-time',
'-Wdeclaration-after-statement',
['-Werror=format-security', '-Werror=format=2'],
'-Wendif-labels',
'-Werror=incompatible-pointer-types',
'-Werror=missing-declarations',
'-Werror=overflow',
'-Werror=return-type',
'-Werror=shift-count-overflow',
'-Werror=shift-overflow=2',
'-Wfloat-equal',
'-Wformat-nonliteral',
'-Wformat-security',
'-Winit-self',
'-Wmaybe-uninitialized',
'-Wmisleading-indentation',
'-Wmissing-include-dirs',
'-Wmissing-noreturn',
'-Wnested-externs',
'-Wold-style-definition',
'-Wshadow',
'-Wstrict-prototypes',
'-Wswitch-default',
'-Wno-switch-enum',
'-Wtype-limits',
'-Wunused-function',
'-Wunused-variable',
]
if get_option('buildtype') != 'plain'
test_c_args += '-fstack-protector-strong'
endif
foreach arg: test_c_args
if cc.has_multi_arguments(arg)
global_c_args += arg
endif
endforeach
add_project_arguments(
global_c_args,
language: 'c')
subdir('data')

Wyświetl plik

@ -46,7 +46,7 @@ double
double latitude)
{
double siderial_time;
double *coordinates_milky_way;
g_autofree double *coordinates_milky_way = NULL;
double *coordinates_horizontal_milky_way;
coordinates_milky_way = picplanner_get_coordinates_rotational_milky_way ();
@ -55,8 +55,6 @@ double
latitude,
siderial_time);
g_free (coordinates_milky_way);
return coordinates_horizontal_milky_way;
}
@ -70,22 +68,19 @@ double
double longitude,
double latitude)
{
GDateTime *iteration_time;
double *coordinates_milky_way;
double *array_coordinates_milky_way = malloc (sizeof (double) * 2 * NUM_DATA_POINTS);
for (int i=0; i<NUM_DATA_POINTS; i++)
{
iteration_time = g_date_time_add_minutes (date_time, i*24*60/NUM_DATA_POINTS-12*60);
g_autoptr (GDateTime) iteration_time =
g_date_time_add_minutes (date_time, i*24*60/NUM_DATA_POINTS-12*60);
g_autofree double *coordinates_milky_way =
picplanner_get_coordinates_milky_way (iteration_time,
longitude,
latitude);
coordinates_milky_way = picplanner_get_coordinates_milky_way (iteration_time,
longitude,
latitude);
array_coordinates_milky_way[2*i] = coordinates_milky_way[0];
array_coordinates_milky_way[2*i+1] = coordinates_milky_way[1];
g_free (coordinates_milky_way);
g_date_time_unref (iteration_time);
}
return array_coordinates_milky_way;
@ -166,4 +161,4 @@ char
g_date_time_unref (date_time_disturbance);
return char_no_disturbance;
}
}

Wyświetl plik

@ -21,7 +21,7 @@
double
*picplanner_get_coordinates_rotational_milky_way ();
*picplanner_get_coordinates_rotational_milky_way (void);
double
*picplanner_get_coordinates_milky_way (GDateTime *date_time,

Wyświetl plik

@ -68,8 +68,8 @@ picplanner_get_illumination (GDateTime *date_time)
{
double illumination;
double elongation;
double *coordinates_moon;
double *coordinates_sun;
g_autofree double *coordinates_moon = NULL;
g_autofree double *coordinates_sun = NULL;
double ra_sun, dec_sun, ra_moon, dec_moon;
coordinates_moon = picplanner_get_coordinates_rotational_moon (date_time);
coordinates_sun = picplanner_get_coordinates_rotational_sun (date_time);
@ -82,9 +82,6 @@ picplanner_get_illumination (GDateTime *date_time)
elongation = sin(dec_sun)*sin(dec_moon) + cos(dec_sun)*cos(dec_moon)*cos(ra_sun-ra_moon);
illumination = (1 - elongation)/2;
g_free (coordinates_moon);
g_free (coordinates_sun);
return illumination*100.;
}
@ -95,7 +92,7 @@ double
double latitude)
{
double siderial_time;
double *coordinates_moon;
g_autofree double *coordinates_moon = NULL;
double *coordinates_horizontal_moon;
coordinates_moon = picplanner_get_coordinates_rotational_moon (date_time);
@ -104,7 +101,6 @@ double
latitude,
siderial_time);
g_free (coordinates_moon);
return coordinates_horizontal_moon;
}
@ -115,22 +111,19 @@ double
double longitude,
double latitude)
{
GDateTime *iteration_time;
double *coordinates_moon;
double *array_coordinates_moon = malloc (sizeof (double) * 2 * NUM_DATA_POINTS);
for (int i=0; i<NUM_DATA_POINTS; i++)
{
iteration_time = g_date_time_add_minutes (date_time, i*24*60/NUM_DATA_POINTS-12*60);
g_autoptr (GDateTime) iteration_time =
g_date_time_add_minutes (date_time, i*24*60/NUM_DATA_POINTS-12*60);
g_autofree double *coordinates_moon =
picplanner_get_coordinates_moon (iteration_time,
longitude,
latitude);
coordinates_moon = picplanner_get_coordinates_moon (iteration_time,
longitude,
latitude);
array_coordinates_moon[2*i] = coordinates_moon[0];
array_coordinates_moon[2*i+1] = coordinates_moon[1];
g_free (coordinates_moon);
g_date_time_unref (iteration_time);
}
return array_coordinates_moon;

Wyświetl plik

@ -64,7 +64,7 @@ double
double latitude)
{
double siderial_time;
double *coordinates_sun;
g_autofree double *coordinates_sun = NULL;
double *coordinates_horizontal_sun;
@ -73,7 +73,6 @@ double
coordinates_horizontal_sun = picplanner_transform_rotational_to_horizontal (coordinates_sun,
latitude,
siderial_time);
g_free (coordinates_sun);
return coordinates_horizontal_sun;
}
@ -84,23 +83,18 @@ double
double longitude,
double latitude)
{
GDateTime *iteration_time;
double *coordinates_sun;
double *array_coordinates_sun = malloc (sizeof (double) * 2 * NUM_DATA_POINTS);
for (int i=0; i<NUM_DATA_POINTS; i++)
{
iteration_time = g_date_time_add_minutes (date_time, i*24*60/NUM_DATA_POINTS-12*60);
coordinates_sun = picplanner_get_coordinates_sun (iteration_time,
longitude,
latitude);
GDateTime *iteration_time = g_date_time_add_minutes (date_time, i*24*60/NUM_DATA_POINTS-12*60);
g_autofree double *coordinates_sun =
picplanner_get_coordinates_sun (iteration_time,
longitude,
latitude);
array_coordinates_sun[2*i] = coordinates_sun[0];
array_coordinates_sun[2*i+1] = coordinates_sun[1];
g_free (coordinates_sun);
g_date_time_unref (iteration_time);
}
return array_coordinates_sun;

Wyświetl plik

@ -193,18 +193,7 @@ double
y = cos (declination) * sin (time_sidereal - right_ascension);
if (x < 0 && y <= 0)
azimuth = atan (y / x);
else if (x < 0 && y > 0)
azimuth = atan (y / x) + 2 * M_PI;
else if (x > 0)
azimuth = atan (y / x) + M_PI;
else if (x == 0 && y < 0)
azimuth = M_PI / 2;
else if (x == 0 && y > 0)
azimuth = -3 * M_PI / 2;
else
azimuth = 0;
azimuth = atan2 (y, x);
elevation = asin (sin (latitude) * sin (declination)
+ cos (latitude) * cos (declination) * cos (time_sidereal - right_ascension));

Wyświetl plik

@ -42,7 +42,7 @@ times_to_time_zone (int day_utc,
int hour_local);
int
*get_time_utc ();
*get_time_utc (void);
int
*utc_time_to_local_time (int *time_utc);

Wyświetl plik

@ -60,9 +60,6 @@ set_user_location (GObject *source_object,
gpointer user_data)
{
(void) source_object;
(void) user_data;
double latitude;
double longitude;
@ -72,6 +69,9 @@ set_user_location (GObject *source_object,
static GClueLocation *location; /* How can one free this? */
(void) source_object;
(void) user_data;
simple = gclue_simple_new_finish (res, &error);
if (error == NULL)
@ -112,4 +112,4 @@ get_user_location (GtkButton *self,
set_user_location,
user_data);
}
}
}

Wyświetl plik

@ -119,11 +119,11 @@ picplanner_draw_layer_size_allocate (GtkWidget *widget,
int height,
int baseline)
{
(void) baseline;
PicplannerDrawLayer *self = PICPLANNER_DRAW_LAYER (widget);
GtkAllocation allocation;
GtkWidget *child;
(void) baseline;
for (child = gtk_widget_get_first_child (GTK_WIDGET (self));
child != NULL;
child = gtk_widget_get_next_sibling (child))
@ -146,7 +146,7 @@ picplanner_draw_layer_size_allocate (GtkWidget *widget,
x_offset = 0;
y_offset = (height-width)/2;
}
else
else
{
min_size = height;
x_offset = (width-height)/2;
@ -337,10 +337,10 @@ picplanner_draw_layer_add_node_coordinates (PicplannerDrawLayer *layer,
double x,
double y)
{
g_return_if_fail (PICPLANNER_IS_DRAW_LAYER (layer));
PicplannerDrawLayerPrivate *priv = picplanner_draw_layer_get_instance_private (layer);
g_return_if_fail (PICPLANNER_IS_DRAW_LAYER (layer));
priv->nodes_coordinates = (double *) realloc (priv->nodes_coordinates, sizeof (double) * (priv->nodes_len+1) * 2);
priv->nodes_coordinates[priv->nodes_len*2] = x;
@ -355,10 +355,10 @@ void
picplanner_draw_layer_remove_all (PicplannerDrawLayer *layer)
{
PicplannerDrawLayerPrivate *priv = picplanner_draw_layer_get_instance_private (layer);
GtkWidget *child;
g_return_if_fail (PICPLANNER_IS_DRAW_LAYER (layer));
GtkWidget *child;
child = gtk_widget_get_first_child (GTK_WIDGET (layer));
while (child)
@ -371,8 +371,7 @@ picplanner_draw_layer_remove_all (PicplannerDrawLayer *layer)
child = next;
}
g_free (priv->nodes_coordinates);
priv->nodes_coordinates = NULL;
g_clear_pointer (&priv->nodes_coordinates, g_free);
priv->nodes_len = 0;
gtk_widget_queue_draw (GTK_WIDGET (layer));

Wyświetl plik

@ -39,7 +39,7 @@ struct _PicplannerApplication
G_DEFINE_TYPE (PicplannerApplication, picplanner_application, ADW_TYPE_APPLICATION)
void
static void
first_run_set_timezone (PicplannerApplication *application)
{
gint64 timezone;
@ -123,8 +123,6 @@ picplanner_application_show_about (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
(void) action;
(void) parameter;
PicplannerApplication *self = PICPLANNER_APPLICATION (user_data);
GtkWindow *window = NULL;
@ -134,7 +132,10 @@ picplanner_application_show_about (GSimpleAction *action,
const gchar *copyright =
"Copyright \xC2\xA9 2020 Zwarf\n\n"
"License Map Data ODBL OpenStreetMap Contributors\nMap Imagery CC-BY-SA 2.0 OpenStreetMap";
g_return_if_fail (PICPLANNER_IS_APPLICATION (self));
(void) action;
(void) parameter;
window = gtk_application_get_active_window (GTK_APPLICATION (self));
@ -162,11 +163,12 @@ picplanner_application_show_preferences (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
(void) action;
(void) parameter;
PicplannerPrefs *prefs;
GtkWindow *window = NULL;
(void) action;
(void) parameter;
window = gtk_application_get_active_window (GTK_APPLICATION (user_data));
prefs = picplanner_prefs_new (PICPLANNER_WINDOW (window));
gtk_window_present (GTK_WINDOW (prefs));
@ -181,10 +183,12 @@ picplanner_inverte_scheme (GSettings *settings,
gchar *key,
gpointer user_data)
{
(void) key;
PicplannerApplication *app = user_data;
AdwStyleManager *manager = adw_application_get_style_manager (ADW_APPLICATION (app));
gboolean invert_scheme = g_settings_get_boolean (settings, "invert-scheme");
(void) key;
if (invert_scheme)
{
if (adw_style_manager_get_dark (manager))
@ -202,19 +206,23 @@ picplanner_inverte_scheme (GSettings *settings,
static void
picplanner_application_init (PicplannerApplication *self)
{
GSimpleAction *quit_action = g_simple_action_new ("quit", NULL);
GSimpleAction *quit_action;
GSimpleAction *about_action;
GSimpleAction *preferences_action;
const char *accels[] = {"<primary>q", NULL};
quit_action = g_simple_action_new ("quit", NULL);
g_signal_connect_swapped (quit_action, "activate", G_CALLBACK (g_application_quit), self);
g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (quit_action));
GSimpleAction *about_action = g_simple_action_new ("about", NULL);
about_action = g_simple_action_new ("about", NULL);
g_signal_connect (about_action, "activate", G_CALLBACK (picplanner_application_show_about), self);
g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (about_action));
GSimpleAction *preferences_action = g_simple_action_new ("preferences", NULL);
preferences_action = g_simple_action_new ("preferences", NULL);
g_signal_connect (preferences_action, "activate", G_CALLBACK (picplanner_application_show_preferences), self);
g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (preferences_action));
const char *accels[] = {"<primary>q", NULL};
gtk_application_set_accels_for_action (GTK_APPLICATION (self), "app.quit", accels);
self->settings = g_settings_new ("de.zwarf.picplanner");

Wyświetl plik

@ -41,10 +41,13 @@ find_loc_children (GWeatherLocation *location,
{
if (gweather_location_get_level (child) == GWEATHER_LOCATION_CITY)
{
g_autofree char *location_string_merge = NULL;
g_autofree char *location_norm = NULL;
g_autofree char *location_string = NULL;
const char *city = gweather_location_get_name (child);
const char *region = gweather_location_get_name (gweather_location_get_parent (child));
const char *country = gweather_location_get_country_name (child);
char *location_string_merge;
if (gweather_location_get_level (gweather_location_get_parent (child))
== GWEATHER_LOCATION_COUNTRY)
{
@ -58,24 +61,20 @@ find_loc_children (GWeatherLocation *location,
country);
}
char *location_norm = g_utf8_normalize (location_string_merge,
location_norm = g_utf8_normalize (location_string_merge,
strlen (location_string_merge),
G_NORMALIZE_ALL_COMPOSE);
char *location_string = g_utf8_casefold (location_norm, strlen (location_norm));
location_string = g_utf8_casefold (location_norm, strlen (location_norm));
g_free (location_string_merge);
g_free (location_norm);
if (strstr (location_string, search_str))
{
locations[*iteration] = g_object_ref(child);
(*iteration)++;
if (*iteration>=NUM_SEARCH_RESULTS)
{
g_free (location_string);
return TRUE;
}
}
g_free (location_string);
}
else
{

Wyświetl plik

@ -54,10 +54,9 @@ void
time_picker_set_time_zone (TimePicker *time_picker,
double time_zone)
{
char *char_time_zone;
g_autofree char *char_time_zone = NULL;
char_time_zone = g_strdup_printf ("UTC %s%.1f", time_zone>=0 ? "+" : "", time_zone);
gtk_label_set_text (GTK_LABEL (time_picker->label_time_zone), char_time_zone);
g_free (char_time_zone);
}
@ -147,7 +146,7 @@ static gboolean
time_spin_button_text (GtkSpinButton *self)
{
int value;
char *button_text;
g_autofree char *button_text = NULL;
GtkAdjustment *adjustment;
adjustment = gtk_spin_button_get_adjustment (self);
@ -155,7 +154,6 @@ time_spin_button_text (GtkSpinButton *self)
button_text = g_strdup_printf ("%02d", value);
gtk_editable_set_text (GTK_EDITABLE (self),
button_text);
g_free (button_text);
return TRUE;
}
@ -169,10 +167,11 @@ static void
day_selected (GtkCalendar *self,
TimePicker *time_picker)
{
(void) self;
GDateTime *date_selected;
char *button_text;
g_autoptr (GDateTime) date_selected = NULL;
GtkPopover *popover;
g_autofree char *button_text = NULL;
(void) self;
date_selected = gtk_calendar_get_date (GTK_CALENDAR (time_picker->calendar));
/*
@ -185,8 +184,13 @@ day_selected (GtkCalendar *self,
gtk_menu_button_set_label (GTK_MENU_BUTTON (time_picker->calendar_button),
button_text);
g_free (button_text);
g_date_time_unref (date_selected);
/*
* Close Popover after the day was selected
* TODO: Popdown happens automatically if a month is chosen which has less days then
* the day number previously selected.
*/
popover = GTK_POPOVER(time_picker->calendar_popover);
gtk_popover_popdown (popover);
input_changed (GTK_WIDGET (self), time_picker);
}
@ -238,7 +242,7 @@ time_picker_class_init (TimePickerClass *class)
}
TimePicker *
time_picker_new ()
time_picker_new (void)
{
return g_object_new (TIME_PICKER_TYPE, NULL);
}

Wyświetl plik

@ -48,6 +48,6 @@ int
time_picker_get_minute (TimePicker *time_picker);
TimePicker *time_picker_new ();
TimePicker *time_picker_new (void);
G_END_DECLS

Wyświetl plik

@ -134,11 +134,10 @@ picplanner_milky_way_set_disturbance (PicplannerMilkyway *milky_way,
double *coordinates_array_moon,
double *coordinates_array_milky_way)
{
char *char_label_disturbance_sun;
char *char_label_disturbance_moon;
char *char_label_no_disturbance;
char *char_label_possibly_no_disturbance;
g_autofree char *char_label_disturbance_sun = NULL;
g_autofree char *char_label_disturbance_moon = NULL;
g_autofree char *char_label_no_disturbance = NULL;
g_autofree char *char_label_possibly_no_disturbance = NULL;
char_label_disturbance_sun = picplanner_get_char_disturbance (date_time_noon,
-18, 360, -360,
@ -171,11 +170,6 @@ picplanner_milky_way_set_disturbance (PicplannerMilkyway *milky_way,
coordinates_array_milky_way);
gtk_label_set_text (GTK_LABEL (milky_way->label_possible_disturbance_sun), char_label_possibly_no_disturbance);
g_free (char_label_disturbance_sun);
g_free (char_label_disturbance_moon);
g_free (char_label_no_disturbance);
g_free (char_label_possibly_no_disturbance);
}
@ -204,7 +198,7 @@ picplanner_milkyway_class_init (PicplannerMilkywayClass *class)
}
PicplannerMilkyway *
picplanner_milkyway_new ()
picplanner_milkyway_new (void)
{
return g_object_new (PICPLANNER_MILKYWAY_TYPE, NULL);
}

Wyświetl plik

@ -43,6 +43,6 @@ picplanner_milky_way_set_disturbance (PicplannerMilkyway *milky_way,
double *coordinates_array_milky_way);
PicplannerMilkyway *picplanner_milkyway_new ();
PicplannerMilkyway *picplanner_milkyway_new (void);
G_END_DECLS

Wyświetl plik

@ -139,13 +139,12 @@ picplanner_moon_set_illumination_intensity (PicplannerMoon *moon,
double illumination,
char *phase)
{
char *char_label_illumination;
g_autofree char *char_label_illumination = NULL;
char_label_illumination = g_strdup_printf ("%d%%", (int)round(illumination));
gtk_label_set_text (GTK_LABEL (moon->label_illumination), char_label_illumination);
gtk_label_set_text (GTK_LABEL (moon->label_phase), phase);
g_free (char_label_illumination);
}
@ -172,7 +171,7 @@ picplanner_moon_class_init (PicplannerMoonClass *class)
}
PicplannerMoon *
picplanner_moon_new ()
picplanner_moon_new (void)
{
return g_object_new (PICPLANNER_MOON_TYPE, NULL);
}

Wyświetl plik

@ -40,6 +40,6 @@ picplanner_moon_set_illumination_intensity (PicplannerMoon *moon,
char *phase);
PicplannerMoon *picplanner_moon_new ();
PicplannerMoon *picplanner_moon_new (void);
G_END_DECLS

Wyświetl plik

@ -163,10 +163,10 @@ input_changed (GtkWidget *self,
gpointer user_data,
gpointer data_overview)
{
(void) user_data;
PicplannerOverview *overview;
overview = PICPLANNER_OVERVIEW (data_overview);
(void) user_data;
if (!overview->input_currently)
{
if (!G_IS_SETTINGS(self) && !PICPLANNER_IS_OVERVIEW (self))
@ -204,14 +204,14 @@ picplanner_overview_set_current_coordinates_sun (PicplannerOverview *overview,
int current_index,
GDateTime *date_time)
{
char *char_elevation_sun;
char *char_azimuth_sun;
char *char_sun_rise;
char *char_sun_set;
g_autofree char *char_elevation_sun = NULL;
g_autofree char *char_azimuth_sun = NULL;
g_autofree char *char_sun_rise = NULL;
g_autofree char *char_sun_set = NULL;
GDateTime *date_time_noon;
GDateTime *date_time_rise;
GDateTime *date_time_set;
g_autoptr (GDateTime) date_time_noon = NULL;
g_autoptr (GDateTime) date_time_rise = NULL;
g_autoptr (GDateTime) date_time_set = NULL;
date_time_noon = g_date_time_new (g_date_time_get_timezone (date_time),
g_date_time_get_year (date_time),
@ -252,14 +252,6 @@ picplanner_overview_set_current_coordinates_sun (PicplannerOverview *overview,
gtk_label_set_text (GTK_LABEL (overview->label_sun_set), char_sun_set);
gtk_label_set_text (GTK_LABEL (overview->label_elevation_sun), char_elevation_sun);
gtk_label_set_text (GTK_LABEL (overview->label_azimuth_sun), char_azimuth_sun);
g_date_time_unref (date_time_rise);
g_date_time_unref (date_time_set);
g_free (char_sun_rise);
g_free (char_sun_set);
g_free (char_elevation_sun);
g_free (char_azimuth_sun);
}
@ -276,14 +268,14 @@ picplanner_overview_set_current_coordinates_moon (PicplannerOverview *overview,
int current_index,
GDateTime *date_time)
{
char *char_elevation_moon;
char *char_azimuth_moon;
char *char_moon_rise;
char *char_moon_set;
g_autofree char *char_elevation_moon = NULL;
g_autofree char *char_azimuth_moon = NULL;
g_autofree char *char_moon_rise = NULL;
g_autofree char *char_moon_set = NULL;
GDateTime *date_time_noon;
GDateTime *date_time_rise;
GDateTime *date_time_set;
g_autoptr (GDateTime) date_time_noon = NULL;
g_autoptr (GDateTime) date_time_rise = NULL;
g_autoptr (GDateTime) date_time_set = NULL;
date_time_noon = g_date_time_new (g_date_time_get_timezone (date_time),
g_date_time_get_year (date_time),
@ -323,15 +315,6 @@ picplanner_overview_set_current_coordinates_moon (PicplannerOverview *overview,
gtk_label_set_text (GTK_LABEL (overview->label_moon_set), char_moon_set);
gtk_label_set_text (GTK_LABEL (overview->label_elevation_moon), char_elevation_moon);
gtk_label_set_text (GTK_LABEL (overview->label_azimuth_moon), char_azimuth_moon);
g_date_time_unref (date_time_rise);
g_date_time_unref (date_time_set);
g_free (char_moon_rise);
g_free (char_moon_set);
g_free (char_elevation_moon);
g_free (char_azimuth_moon);
}
@ -348,14 +331,14 @@ picplanner_overview_set_current_coordinates_milky_way (PicplannerOverview *overv
int current_index,
GDateTime *date_time)
{
char *char_elevation_milky_way;
char *char_azimuth_milky_way;
char *char_milky_way_rise;
char *char_milky_way_set;
g_autofree char *char_elevation_milky_way = NULL;
g_autofree char *char_azimuth_milky_way = NULL;
g_autofree char *char_milky_way_rise = NULL;
g_autofree char *char_milky_way_set = NULL;
GDateTime *date_time_noon;
GDateTime *date_time_rise;
GDateTime *date_time_set;
g_autoptr (GDateTime) date_time_noon = NULL;
g_autoptr (GDateTime) date_time_rise = NULL;
g_autoptr (GDateTime) date_time_set = NULL;
date_time_noon = g_date_time_new (g_date_time_get_timezone (date_time),
g_date_time_get_year (date_time),
@ -395,14 +378,6 @@ picplanner_overview_set_current_coordinates_milky_way (PicplannerOverview *overv
gtk_label_set_text (GTK_LABEL (overview->label_milky_way_set), char_milky_way_set);
gtk_label_set_text (GTK_LABEL (overview->label_elevation_milky_way), char_elevation_milky_way);
gtk_label_set_text (GTK_LABEL (overview->label_azimuth_milky_way), char_azimuth_milky_way);
g_date_time_unref (date_time_rise);
g_date_time_unref (date_time_set);
g_free (char_milky_way_rise);
g_free (char_milky_way_set);
g_free (char_elevation_milky_way);
g_free (char_azimuth_milky_way);
}
@ -649,13 +624,14 @@ shumate_map_metric_imperial_scale (GSettings *settings,
gchar *key,
gpointer user_data)
{
(void) settings;
(void) key;
PicplannerOverview *overview = user_data;
ShumateScale *scale;
gboolean metric;
gboolean imperial;
(void) settings;
(void) key;
scale = shumate_simple_map_get_scale (overview->map);
metric = g_settings_get_boolean (settings, "map-unit-metric");
imperial = g_settings_get_boolean (settings, "map-unit-imperial");
@ -853,7 +829,7 @@ picplanner_overview_class_init (PicplannerOverviewClass *class)
}
PicplannerOverview *
picplanner_overview_new ()
picplanner_overview_new (void)
{
return g_object_new (PICPLANNER_OVERVIEW_TYPE, NULL);
}

Wyświetl plik

@ -27,7 +27,7 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (PicplannerOverview, picplanner_overview, PICPLANNER, OVERVIEW, GtkBox)
PicplannerOverview
*picplanner_overview_new ();
*picplanner_overview_new (void);
void
picplanner_overview_map_fullscreen (PicplannerOverview *overview,

Wyświetl plik

@ -139,14 +139,14 @@ search_location_chosen (GtkWidget *self,
GtkWidget *row,
gpointer user_data)
{
(void) self;
PicplannerWindow *window = user_data;
double latitude;
double longitude;
double *p_latitude = &latitude;
double *p_longitude = &longitude;
int i;
(void) self;
for (i=0; i<NUM_SEARCH_RESULTS; i++)
{
if (row == window->search_result_row[i])
@ -172,16 +172,16 @@ static void
search_location (GtkWidget *self,
gpointer user_data)
{
(void) self;
PicplannerWindow *window = user_data;
const char *search_text = gtk_editable_get_text (GTK_EDITABLE (window->search_entry));
char *search_norm = g_utf8_normalize (search_text, strlen (search_text), G_NORMALIZE_ALL_COMPOSE);
char *search_string = g_utf8_casefold (search_text, strlen (search_norm));
g_autofree char *search_norm = g_utf8_normalize (search_text, strlen (search_text), G_NORMALIZE_ALL_COMPOSE);
g_autofree char *search_string = g_utf8_casefold (search_text, strlen (search_norm));
g_autoptr (GWeatherLocation) world = NULL;
(void) self;
world = gweather_location_get_world ();
for (int i=0; i<NUM_SEARCH_RESULTS; i++)
@ -201,8 +201,8 @@ search_location (GtkWidget *self,
double *p_longitude = &longitude;
double *p_latitude = &latitude;
char *char_coordinates;
char *char_subtitle;
g_autofree char *char_coordinates = NULL;
g_autofree char *char_subtitle = NULL;
gtk_widget_set_visible (window->stack, FALSE);
gtk_widget_set_visible (window->search_results_scroll, TRUE);
@ -253,8 +253,6 @@ search_location (GtkWidget *self,
gtk_list_box_append (GTK_LIST_BOX (window->search_result_box),
window->search_result_row[i]);
g_free (char_coordinates);
}
}
@ -265,9 +263,6 @@ search_location (GtkWidget *self,
gtk_widget_set_visible (window->stack, TRUE);
gtk_widget_set_visible (window->search_results_scroll, FALSE);
}
g_free (search_norm);
g_free (search_string);
}
void
@ -282,12 +277,12 @@ picplanner_set_location (double latitude, double longitude, PicplannerWindow *wi
* Changing the date_time variable after a user input was recognized.
* Afterwards, emit a signal to start the calculations.
*/
void
static void
picplanner_update_date_time (PicplannerWindow *window)
{
int year, month, day, hour, minute;
double latitude, longitude;
double latitude, longitude, time_zone;
GWeatherLocation *loc;
longitude = gtk_spin_button_get_value (GTK_SPIN_BUTTON (window->east_entry));
@ -323,7 +318,7 @@ picplanner_update_date_time (PicplannerWindow *window)
0);
}
double time_zone = (double) g_date_time_get_utc_offset (window->date_time)/3600/1000/1000;
time_zone = (double) g_date_time_get_utc_offset (window->date_time)/3600/1000/1000;
time_picker_set_time_zone (TIME_PICKER (window->time_picker),
time_zone);
}
@ -344,19 +339,19 @@ calculate_positions (PicplannerWindow *window)
double longitude, latitude;
double illumination_moon, illumination_moon_later;
int *rise_upper_set_lower_index_sun;
int *rise_upper_set_index_moon;
int *rise_upper_set_index_milky_way;
int *dark_blue_golden_index;
g_autofree int *rise_upper_set_lower_index_sun = NULL;
g_autofree int *rise_upper_set_index_moon = NULL;
g_autofree int *rise_upper_set_index_milky_way = NULL;
g_autofree int *dark_blue_golden_index = NULL;
double *array_coordinates_sun;
double *array_coordinates_moon;
double *array_coordinates_milky_way;
g_autofree double *array_coordinates_sun = NULL;
g_autofree double *array_coordinates_moon = NULL;
g_autofree double *array_coordinates_milky_way = NULL;
char *phase_moon;
g_autofree char *phase_moon = NULL;
GDateTime *date_time_noon;
GDateTime *date_time_later;
g_autoptr (GDateTime) date_time_noon = NULL;
g_autoptr (GDateTime) date_time_later = NULL;
longitude = gtk_spin_button_get_value (GTK_SPIN_BUTTON (window->east_entry));
@ -509,19 +504,6 @@ calculate_positions (PicplannerWindow *window)
rise_upper_set_index_milky_way);
}
/*
* Free allocated memory
*/
g_free (rise_upper_set_lower_index_sun);
g_free (rise_upper_set_index_moon);
g_free (rise_upper_set_index_milky_way);
g_free (dark_blue_golden_index);
g_free (array_coordinates_sun);
g_free (array_coordinates_moon);
g_free (array_coordinates_milky_way);
g_free (phase_moon);
g_date_time_unref (date_time_noon);
/*
* TODO:
* Free loc?
@ -565,9 +547,10 @@ input_changed (GtkWidget *self,
gpointer data_map_move,
gpointer data_window_change)
{
(void) self;
PicplannerWindow *window;
(void) self;
if (PICPLANNER_IS_WINDOW (data_window_change))
window = PICPLANNER_WINDOW (data_window_change);
else
@ -595,9 +578,10 @@ input_changed_remove_content (GtkWidget *self,
gpointer data_map_move,
gpointer data_window_change)
{
(void) self;
PicplannerWindow *window;
(void) self;
if (PICPLANNER_IS_WINDOW (data_window_change))
window = PICPLANNER_WINDOW (data_window_change);
else

Wyświetl plik

@ -61,24 +61,24 @@ picplanner_sun_set_rise_upper_set (PicplannerSun *sun,
double *coordinates_array,
int *index_rise_upper_set_lower)
{
char *char_morning_rise_time;
char *char_morning_rise_azimuth;
g_autofree char *char_morning_rise_time = NULL;
g_autofree char *char_morning_rise_azimuth = NULL;
char *char_upper_time;
char *char_upper_azimuth;
char *char_upper_elevation;
g_autofree char *char_upper_time = NULL;
g_autofree char *char_upper_azimuth = NULL;
g_autofree char *char_upper_elevation = NULL;
char *char_lower_time;
char *char_lower_azimuth;
char *char_lower_elevation;
g_autofree char *char_lower_time = NULL;
g_autofree char *char_lower_azimuth = NULL;
g_autofree char *char_lower_elevation = NULL;
char *char_evening_set_time;
char *char_evening_set_azimuth;
g_autofree char *char_evening_set_time = NULL;
g_autofree char *char_evening_set_azimuth = NULL;
GDateTime *date_time_rise;
GDateTime *date_time_upper;
GDateTime *date_time_set;
GDateTime *date_time_lower;
g_autoptr (GDateTime) date_time_rise = NULL;
g_autoptr (GDateTime) date_time_upper = NULL;
g_autoptr (GDateTime) date_time_set = NULL;
g_autoptr (GDateTime) date_time_lower = NULL;
date_time_rise = g_date_time_add_minutes (date_time,
@ -159,26 +159,6 @@ picplanner_sun_set_rise_upper_set (PicplannerSun *sun,
gtk_label_set_text (GTK_LABEL (sun->label_lower_time), char_lower_time);
gtk_label_set_text (GTK_LABEL (sun->label_lower_azimuth), char_lower_azimuth);
gtk_label_set_text (GTK_LABEL (sun->label_lower_elevation), char_lower_elevation);
/*
* Free allocated memory.
*/
g_date_time_unref (date_time_rise);
g_date_time_unref (date_time_upper);
g_date_time_unref (date_time_set);
g_free (char_morning_rise_time);
g_free (char_morning_rise_azimuth);
g_free (char_upper_time);
g_free (char_upper_azimuth);
g_free (char_upper_elevation);
g_free (char_lower_time);
g_free (char_lower_azimuth);
g_free (char_lower_elevation);
g_free (char_evening_set_time);
g_free (char_evening_set_azimuth);
}
@ -191,21 +171,21 @@ picplanner_sun_set_dark_blue_golden (PicplannerSun *sun,
GDateTime *date_time,
int *index_dark_blue_golden)
{
char *char_dark_night_morning;
char *char_blue_hour_morning;
char *char_golden_hour_morning;
GDateTime *dark_night_morning_end;
GDateTime *blue_hour_morning_begin;
GDateTime *blue_hour_golden_hour_morning_switch;
GDateTime *golden_hour_morning_end;
g_autofree char *char_dark_night_morning = NULL;
g_autofree char *char_blue_hour_morning = NULL;
g_autofree char *char_golden_hour_morning = NULL;
g_autoptr (GDateTime) dark_night_morning_end = NULL;
g_autoptr (GDateTime) blue_hour_morning_begin = NULL;
g_autoptr (GDateTime) blue_hour_golden_hour_morning_switch = NULL;
g_autoptr (GDateTime) golden_hour_morning_end = NULL;
char *char_golden_hour_evening;
char *char_blue_hour_evening;
char *char_dark_night_evening;
GDateTime *golden_hour_evening_begin;
GDateTime *golden_hour_blue_hour_evening_switch;
GDateTime *blue_hour_evening_end;
GDateTime *dark_night_evening_begin;
g_autofree char *char_golden_hour_evening = NULL;
g_autofree char *char_blue_hour_evening = NULL;
g_autofree char *char_dark_night_evening = NULL;
g_autoptr (GDateTime) golden_hour_evening_begin = NULL;
g_autoptr (GDateTime) golden_hour_blue_hour_evening_switch = NULL;
g_autoptr (GDateTime) blue_hour_evening_end = NULL;
g_autoptr (GDateTime) dark_night_evening_begin = NULL;
dark_night_morning_end = g_date_time_add_minutes (date_time,
index_dark_blue_golden[0]*24*60/NUM_DATA_POINTS-12*60);
@ -354,26 +334,6 @@ picplanner_sun_set_dark_blue_golden (PicplannerSun *sun,
gtk_label_set_text (GTK_LABEL (sun->label_evening_golden), char_golden_hour_evening);
gtk_label_set_text (GTK_LABEL (sun->label_evening_blue), char_blue_hour_evening);
gtk_label_set_text (GTK_LABEL (sun->label_evening_dark), char_dark_night_evening);
/*
* Free allocated memory.
*/
g_date_time_unref (dark_night_morning_end);
g_date_time_unref (blue_hour_morning_begin);
g_date_time_unref (blue_hour_golden_hour_morning_switch);
g_date_time_unref (golden_hour_morning_end);
g_date_time_unref (golden_hour_evening_begin);
g_date_time_unref (golden_hour_blue_hour_evening_switch);
g_date_time_unref (blue_hour_evening_end);
g_date_time_unref (dark_night_evening_begin);
g_free (char_dark_night_morning);
g_free (char_blue_hour_morning);
g_free (char_golden_hour_morning);
g_free (char_golden_hour_evening);
g_free (char_blue_hour_evening);
g_free (char_dark_night_evening);
}
static void
@ -406,7 +366,7 @@ picplanner_sun_class_init (PicplannerSunClass *class)
}
PicplannerSun *
picplanner_sun_new ()
picplanner_sun_new (void)
{
return g_object_new (PICPLANNER_SUN_TYPE, NULL);
}

Wyświetl plik

@ -49,6 +49,6 @@ picplanner_sun_set_dark_blue_golden (PicplannerSun *sun,
int *index_dark_blue_golden);
PicplannerSun *picplanner_sun_new ();
PicplannerSun *picplanner_sun_new (void);
G_END_DECLS