From: Dan Williams Date: Tue, 16 Sep 2008 03:58:41 +0000 (-0700) Subject: imsm: only use the device name as a fallback when IMSM_DEVNAME_AS_SERIAL=1 X-Git-Tag: mdadm-3.0-devel1~35 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f9ba0ff1241014b8cee9e929c565dfa3c6531fa8;p=thirdparty%2Fmdadm.git 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 --- diff --git a/super-intel.c b/super-intel.c index c6b7be43..4b05fbed 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,