diff options
-rw-r--r-- | extras/scsi_id/scsi_id.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/extras/scsi_id/scsi_id.c b/extras/scsi_id/scsi_id.c index 39391f6e2e..aa1b16009e 100644 --- a/extras/scsi_id/scsi_id.c +++ b/extras/scsi_id/scsi_id.c @@ -677,13 +677,22 @@ static int per_dev_options(struct sysfs_device *scsi_dev, int *good_bad, */ static void format_serial(char *serial) { - char *p = serial; + char *p = serial, *q; + q = p; while (*p != '\0') { - if (isspace(*p)) - *p = '_'; + if (isspace(*p)) { + if (q > serial && q[-1] != '_') { + *q = '_'; + q++; + } + } else { + *q = *p; + q++; + } p++; } + *q = '\0'; } /* |