Commit 1c90322a authored by spiiroin's avatar spiiroin

[dyn-config] Fix miscellaneous issues

String fields in modedata_t structures are filled in via functions that
return 'gchar *' pointers - adjust structure data types and release
function accordingly.

The modelist_free() function uses g_list_foreach() iterator and a
callback function that is not appropriate for the action, and then uses
a cast to hide any compiler warnings - get rid of the cast by using
g_list_free_full() iterator and a suitable callback function.

The modelist_load() function looks complex and indiscriminately loads
all files from dynamic mode configuration directory. If there are for
example editor backup files present, this can lead to hard to detect
issues - simplify the logic and use glob pattern expansion to derive
list of files to load.
Signed-off-by: spiiroin's avatarSimo Piiroinen <simo.piiroinen@jollamobile.com>
parent 390ccadd
This diff is collapsed.
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#ifndef USB_MODED_DYN_CONFIG_H_ #ifndef USB_MODED_DYN_CONFIG_H_
# define USB_MODED_DYN_CONFIG_H_ # define USB_MODED_DYN_CONFIG_H_
# include <stdbool.h>
# include <glib.h> # include <glib.h>
/* ========================================================================= * /* ========================================================================= *
...@@ -95,29 +96,29 @@ ...@@ -95,29 +96,29 @@
*/ */
typedef struct modedata_t typedef struct modedata_t
{ {
char *mode_name; /**< Mode name */ gchar *mode_name; /**< Mode name */
char *mode_module; /**< Needed module for given mode */ gchar *mode_module; /**< Needed module for given mode */
int appsync; /**< Requires appsync or not */ int appsync; /**< Requires appsync or not */
int network; /**< Bring up network or not */ int network; /**< Bring up network or not */
int mass_storage; /**< Use mass-storage functions */ int mass_storage; /**< Use mass-storage functions */
char *network_interface; /**< Which network interface to bring up if network needs to be enabled */ gchar *network_interface; /**< Which network interface to bring up if network needs to be enabled */
char *sysfs_path; /**< Path to set sysfs options */ gchar *sysfs_path; /**< Path to set sysfs options */
char *sysfs_value; /**< Option name/value to write to sysfs */ gchar *sysfs_value; /**< Option name/value to write to sysfs */
char *sysfs_reset_value; /**< Value to reset the the sysfs to default */ gchar *sysfs_reset_value; /**< Value to reset the the sysfs to default */
char *android_extra_sysfs_path; /**< Path for static value that never changes that needs to be set by sysfs :( */ gchar *android_extra_sysfs_path; /**< Path for static value that never changes that needs to be set by sysfs :( */
char *android_extra_sysfs_value; /**< Static value that never changes that needs to be set by sysfs :( */ gchar *android_extra_sysfs_value; /**< Static value that never changes that needs to be set by sysfs :( */
char *android_extra_sysfs_path2; /**< Path for static value that never changes that needs to be set by sysfs :( */ gchar *android_extra_sysfs_path2; /**< Path for static value that never changes that needs to be set by sysfs :( */
char *android_extra_sysfs_value2; /**< Static value that never changes that needs to be set by sysfs :( */ gchar *android_extra_sysfs_value2; /**< Static value that never changes that needs to be set by sysfs :( */
char *android_extra_sysfs_path3; /**< Path for static value that never changes that needs to be set by sysfs :( */ gchar *android_extra_sysfs_path3; /**< Path for static value that never changes that needs to be set by sysfs :( */
char *android_extra_sysfs_value3; /**< Static value that never changes that needs to be set by sysfs :( */ gchar *android_extra_sysfs_value3; /**< Static value that never changes that needs to be set by sysfs :( */
char *android_extra_sysfs_path4; /**< Path for static value that never changes that needs to be set by sysfs :( */ gchar *android_extra_sysfs_path4; /**< Path for static value that never changes that needs to be set by sysfs :( */
char *android_extra_sysfs_value4; /**< Static value that never changes that needs to be set by sysfs :( */ gchar *android_extra_sysfs_value4; /**< Static value that never changes that needs to be set by sysfs :( */
char *idProduct; /**< Product id to assign to a specific profile */ gchar *idProduct; /**< Product id to assign to a specific profile */
char *idVendorOverride; /**< Temporary vendor override for special modes used by odms in testing/manufacturing */ gchar *idVendorOverride; /**< Temporary vendor override for special modes used by odms in testing/manufacturing */
int nat; /**< If NAT should be set up in this mode or not */ int nat; /**< If NAT should be set up in this mode or not */
int dhcp_server; /**< if a DHCP server needs to be configured and started or not */ int dhcp_server; /**< if a DHCP server needs to be configured and started or not */
# ifdef CONNMAN # ifdef CONNMAN
char* connman_tethering; /**< Connman's tethering technology path */ gchar *connman_tethering; /**< Connman's tethering technology path */
# endif # endif
} modedata_t; } modedata_t;
...@@ -129,13 +130,13 @@ typedef struct modedata_t ...@@ -129,13 +130,13 @@ typedef struct modedata_t
* MODEDATA * MODEDATA
* ------------------------------------------------------------------------- */ * ------------------------------------------------------------------------- */
void modedata_free(modedata_t *list_item); void modedata_free(modedata_t *self);
/* ------------------------------------------------------------------------- * /* ------------------------------------------------------------------------- *
* MODELIST * MODELIST
* ------------------------------------------------------------------------- */ * ------------------------------------------------------------------------- */
void modelist_free(GList *modelist); void modelist_free(GList *modelist);
GList *modelist_load(int diag); GList *modelist_load(bool diag);
#endif /* USB_MODED_DYN_CONFIG_H_ */ #endif /* USB_MODED_DYN_CONFIG_H_ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment