summaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2010-11-27 22:38:27 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2010-12-07 11:10:35 -0800
commit3a9bb93dd178084f4ff1abcea331ca5a62f88ce6 (patch)
treee82a82126bb89c4cb1956a531f8d10e0a88f030f /config
parent2416255f7e3fd9190a9e01bda57c992932de4bd9 (diff)
Convert alloc+sprintf pairs into asprintf() & XNFasprintf() calls
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Diffstat (limited to 'config')
-rw-r--r--config/hal.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/config/hal.c b/config/hal.c
index 5e35911fd..0b848a0f7 100644
--- a/config/hal.c
+++ b/config/hal.c
@@ -63,10 +63,8 @@ device_removed(LibHalContext *ctx, const char *udi)
{
char *value;
- value = malloc(strlen(udi) + 5); /* "hal:" + NULL */
- if (!value)
+ if (asprintf (&value, "hal:%s", udi) == -1)
return;
- sprintf(value, "hal:%s", udi);
remove_devices("hal", value);
@@ -228,12 +226,11 @@ device_added(LibHalContext *hal_ctx, const char *udi)
add_option(&options, "driver", driver);
add_option(&options, "name", name);
- config_info = malloc(strlen(udi) + 5); /* "hal:" and NULL */
- if (!config_info) {
+ if (asprintf (&config_info, "hal:%s", udi) == -1) {
+ config_info = NULL;
LogMessage(X_ERROR, "config/hal: couldn't allocate name\n");
goto unwind;
}
- sprintf(config_info, "hal:%s", udi);
/* Check for duplicate devices */
if (device_is_duplicate(config_info))