Properly handle NULs when normalizing SFP fields

Some generic 1.25gbps DAC cables were seen to have a NUL *after* the
space padding in the model field. This caused the normalization to miss
the space padding in the string. The vendor field did not have the
issue.

Note that this seems to be against spec per SFF-8472, which mentions
only space padding or *all* NUL, not a combination of both. In the case
of all NUL, we'll waste a few cycles with no-op writes.
This commit is contained in:
Matt Merhar committed 2026-09-20 19:55:07 -04:00
1 parent 55431b39f6
commit bb84bdc55a
1 file changed
+1 -1
+1 -1
View File
@@ -95,7 +95,7 @@ bool sfp_read_field(__xdata char *dst, uint8_t sfp, uint8_t start, uint8_t lengt
dst[i] = c;
}
while (length > 0 && dst[--length] == ' ')
while (length-- > 0 && (dst[length] == ' ' || dst[length] == NUL))
dst[length] = NUL;
return true;