From 6c2baf022eaf6eef8fe3e94162e54e5a27f76d6d Mon Sep 17 00:00:00 2001 From: Jean-Philippe Orsini Date: Fri, 19 Sep 2014 09:23:21 +0200 Subject: [PATCH] normalize and cleanup --- src/lib/hdd_atasmart.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/lib/hdd_atasmart.c b/src/lib/hdd_atasmart.c index b34564e..7920d93 100644 --- a/src/lib/hdd_atasmart.c +++ b/src/lib/hdd_atasmart.c @@ -39,6 +39,8 @@ #include #include +static const char *PROVIDER_NAME = "atasmart"; + static int filter_sd(const char *p) { return strlen(p) == 8 && !strncmp(p, "/dev/sd", 7); @@ -133,9 +135,11 @@ struct psensor **hdd_psensor_list_add(struct psensor **sensors, log_debug("hdd_psensor_list_add(hdd_atasmart) open %s", *tmp); if (!sk_disk_open(*tmp, &disk)) { - id = malloc(strlen("atasmart ") + strlen(*tmp) + 1); - strcpy(id, "atasmart "); - strcat(id, *tmp); + id = malloc(strlen(PROVIDER_NAME) + + 1 + + strlen(*tmp) + + 1); + sprintf(id, "%s %s", PROVIDER_NAME, *tmp); sensor = create_sensor(id, *tmp, -- 2.7.4