* [PATCH] iwd: Do not try to handle out of memory fails
@ 2021-06-23 7:22 Daniel Wagner
2021-06-23 7:39 ` Daniel Wagner
0 siblings, 1 reply; 2+ messages in thread
From: Daniel Wagner @ 2021-06-23 7:22 UTC (permalink / raw)
To: connman; +Cc: Daniel Wagner
There is little point in trying to handle out of memory
situation. Most GLib function do fail with calling abort() when memory
allocation fails, e.g. g_strdup(). So fail hard when allocation the
iwd data structures.
---
plugins/iwd.c | 44 ++++++--------------------------------------
1 file changed, 6 insertions(+), 38 deletions(-)
diff --git a/plugins/iwd.c b/plugins/iwd.c
index 4ba107f3e113..14a442a7b67c 100644
--- a/plugins/iwd.c
+++ b/plugins/iwd.c
@@ -1372,13 +1372,7 @@ static void create_adapter(GDBusProxy *proxy)
struct iwd_adapter *iwda;
GSList *modes, *list;
- iwda = g_try_new0(struct iwd_adapter, 1);
-
- if (!iwda) {
- connman_error("Out of memory creating IWD adapter");
- return;
- }
-
+ iwda = g_new0(struct iwd_adapter, 1);
iwda->path = g_strdup(path);
g_hash_table_replace(adapters, iwda->path, iwda);
@@ -1423,13 +1417,7 @@ static void create_device(GDBusProxy *proxy)
const char *path = g_dbus_proxy_get_path(proxy);
struct iwd_device *iwdd;
- iwdd = g_try_new0(struct iwd_device, 1);
-
- if (!iwdd) {
- connman_error("Out of memory creating IWD device");
- return;
- }
-
+ iwdd = g_new0(struct iwd_device, 1);
iwdd->path = g_strdup(path);
g_hash_table_replace(devices, iwdd->path, iwdd);
@@ -1596,13 +1584,7 @@ static void create_network(GDBusProxy *proxy)
const char *path = g_dbus_proxy_get_path(proxy);
struct iwd_network *iwdn;
- iwdn = g_try_new0(struct iwd_network, 1);
-
- if (!iwdn) {
- connman_error("Out of memory creating IWD network");
- return;
- }
-
+ iwdn = g_new0(struct iwd_network, 1);
iwdn->path = g_strdup(path);
g_hash_table_replace(networks, iwdn->path, iwdn);
@@ -1682,12 +1664,7 @@ static void create_know_network(GDBusProxy *proxy)
const char *path = g_dbus_proxy_get_path(proxy);
struct iwd_known_network *iwdkn;
- iwdkn = g_try_new0(struct iwd_known_network, 1);
- if (!iwdkn) {
- connman_error("Out of memory creating IWD known network");
- return;
- }
-
+ iwdkn = g_new0(struct iwd_known_network, 1);
iwdkn->path = g_strdup(path);
g_hash_table_replace(known_networks, iwdkn->path, iwdkn);
@@ -1721,12 +1698,7 @@ static void create_station(GDBusProxy *proxy)
const char *path = g_dbus_proxy_get_path(proxy);
struct iwd_station *iwds;
- iwds = g_try_new0(struct iwd_station, 1);
- if (!iwds) {
- connman_error("Out of memory creating IWD station");
- return;
- }
-
+ iwds = g_new0(struct iwd_station, 1);
iwds->path = g_strdup(path);
g_hash_table_replace(stations, iwds->path, iwds);
@@ -1754,11 +1726,7 @@ static void create_ap(GDBusProxy *proxy)
const char *path = g_dbus_proxy_get_path(proxy);
struct iwd_ap *iwdap;
- iwdap = g_try_new0(struct iwd_ap, 1);
- if (!iwdap) {
- connman_error("Out of memory creating IWD access point");
- return;
- }
+ iwdap = g_new0(struct iwd_ap, 1);
iwdap->index = -1;
iwdap->path = g_strdup(path);
--
2.32.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] iwd: Do not try to handle out of memory fails
2021-06-23 7:22 [PATCH] iwd: Do not try to handle out of memory fails Daniel Wagner
@ 2021-06-23 7:39 ` Daniel Wagner
0 siblings, 0 replies; 2+ messages in thread
From: Daniel Wagner @ 2021-06-23 7:39 UTC (permalink / raw)
To: connman
On Wed, Jun 23, 2021 at 09:22:54AM +0200, Daniel Wagner wrote:
> There is little point in trying to handle out of memory
> situation. Most GLib function do fail with calling abort() when memory
> allocation fails, e.g. g_strdup(). So fail hard when allocation the
> iwd data structures.
Patch applied
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-06-23 7:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-23 7:22 [PATCH] iwd: Do not try to handle out of memory fails Daniel Wagner
2021-06-23 7:39 ` Daniel Wagner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).