From f9ba0ff1241014b8cee9e929c565dfa3c6531fa8 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Mon, 15 Sep 2008 20:58:41 -0700 Subject: [PATCH] imsm: only use the device name as a fallback when IMSM_DEVNAME_AS_SERIAL=1 Also ensure that the serial buffer is initialized. Signed-off-by: Dan Williams --- super-intel.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/super-intel.c b/super-intel.c index c6b7be4..4b05fbe 100644 --- a/super-intel.c +++ b/super-intel.c @@ -849,16 +849,14 @@ static int imsm_read_serial(int fd, char *devname, memset(scsi_serial, 0, sizeof(scsi_serial)); - if (imsm_env_devname_as_serial()) { - char name[MAX_RAID_SERIAL_LEN]; - - fd2devname(fd, name); - strcpy((char *) serial, name); + rv = scsi_get_serial(fd, scsi_serial, sizeof(scsi_serial)); + + if (rv && imsm_env_devname_as_serial()) { + memset(serial, 0, MAX_RAID_SERIAL_LEN); + fd2devname(fd, (char *) serial); return 0; } - rv = scsi_get_serial(fd, scsi_serial, sizeof(scsi_serial)); - if (rv != 0) { if (devname) fprintf(stderr,