Skip to content

Commit

Permalink
[cleanup] Do not use const for pointers used for storing dynamic data
Browse files Browse the repository at this point in the history
Probably in attempt to hide compilation warnings due to storing dynamically
allocated data in const pointers, there are multiple places where releasing
of dynamic memory uses casts. Some of these casts are incorrect and there
are still compilation issues.

Remove const attribute from pointers that are used to store dynamically
allocated data and remove the unnecessary casts at free() / g_free().

Signed-off-by: Simo Piiroinen <simo.piiroinen@jollamobile.com>
  • Loading branch information
spiiroin committed Jul 7, 2016
1 parent 1fd5d72 commit a9cab1f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/usb_moded-dbus.c
Expand Up @@ -294,7 +294,7 @@ static DBusHandlerResult msg_handler(DBusConnection *const connection, DBusMessa
{
if((reply = dbus_message_new_method_return(msg)))
dbus_message_append_args (reply, DBUS_TYPE_STRING, &config, DBUS_TYPE_STRING, &setting, DBUS_TYPE_INVALID);
free((void *)setting);
free(setting);
}
else
reply = dbus_message_new_error(msg, DBUS_ERROR_INVALID_ARGS, config);
Expand Down
8 changes: 4 additions & 4 deletions src/usb_moded-modesetting.c
Expand Up @@ -98,7 +98,7 @@ static int set_mass_storage_mode(struct mode_list_elem *data)
{
gchar *command;
char command2[256], *real_path = NULL, *mountpath;
const char *mount;
char *mount;
gchar **mounts;
int ret = 0, i = 0, mountpoints = 0, fua = 0, try = 0;

Expand Down Expand Up @@ -199,7 +199,7 @@ umount: command = g_strconcat("mount | grep ", mountpath, NULL);
}
}
g_strfreev(mounts);
g_free((gpointer *)mount);
g_free(mount);
if(real_path)
free(real_path);
}
Expand All @@ -216,7 +216,7 @@ static int unset_mass_storage_mode(struct mode_list_elem *data)
{
gchar *command;
char command2[256], *real_path = NULL, *mountpath;
const char *mount;
char *mount;
gchar **mounts;
int ret = 1, i = 0;

Expand Down Expand Up @@ -277,7 +277,7 @@ static int unset_mass_storage_mode(struct mode_list_elem *data)
}
}
g_strfreev(mounts);
g_free((gpointer *)mount);
g_free(mount);
if(real_path)
free(real_path);
}
Expand Down
8 changes: 4 additions & 4 deletions src/usb_moded-udev.c
Expand Up @@ -44,7 +44,7 @@ static struct udev *udev;
static struct udev_monitor *mon;
static GIOChannel *iochannel;
static guint watch_id;
static const char *dev_name;
static char *dev_name = 0;
static int cleanup = 0;
/* track cable and charger connects disconnects */
static int cable = 0, charger = 0;
Expand Down Expand Up @@ -141,7 +141,7 @@ gboolean hwal_init(void)
if(udev_path)
{
dev = udev_device_new_from_syspath(udev, udev_path);
g_free((gpointer *)udev_path);
g_free(udev_path);
}
else
dev = udev_device_new_from_syspath(udev, "/sys/class/power_supply/usb");
Expand Down Expand Up @@ -195,7 +195,7 @@ gboolean hwal_init(void)
if(udev_subsystem)
{
ret = udev_monitor_filter_add_match_subsystem_devtype(mon, udev_subsystem, NULL);
g_free((gpointer *)udev_subsystem);
g_free(udev_subsystem);
}
else
ret = udev_monitor_filter_add_match_subsystem_devtype(mon, "power_supply", NULL);
Expand Down Expand Up @@ -289,7 +289,7 @@ void hwal_cleanup(void)
iochannel = NULL;
}
cancel_cable_connection_timeout();
free((void *) dev_name);
free(dev_name);
udev_monitor_unref(mon);
udev_unref(udev);
}
Expand Down

0 comments on commit a9cab1f

Please sign in to comment.