Convert alloc+sprintf pairs into asprintf() & XNFasprintf() calls

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Mikhail Gusarov <dottedmag@dottedmag.net>
This commit is contained in:
Alan Coopersmith
2010-11-27 22:38:27 -08:00
parent 2416255f7e
commit 3a9bb93dd1
11 changed files with 36 additions and 62 deletions

View File

@@ -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))