strchomp() is only needed to strip trailing spaces from a string.
There is no need to replace NUL characters with NUL characters.
So simplify the check for "NUL or space" to just "space".
Update the function description as well,
as it doesn't strip all whitespace, just spaces.
Signed-off-by: Caleb Sander <csander@purestorage.com>
const char *nvmf_dev = "/dev/nvme-fabrics";
/**
- * strchomp() - Strip trailing white space
+ * strchomp() - Strip trailing spaces
* @str: String to strip
* @max: Maximum length of string
*/
{
int i;
- for (i = max - 1; i >= 0; i--) {
- if (str[i] != '\0' && str[i] != ' ')
- return;
- else
- str[i] = '\0';
+ for (i = max - 1; i >= 0 && str[i] == ' '; i--) {
+ str[i] = '\0';
}
}