Kernel string parsing functions support a single new line
before the null terminator of a string. Our numeric string
parsing should do the same. This allows strings to be
echo'ed directly into proc files.
Signed-off-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Change-Id: Ia9d36b4f4f6849547391115d31be34a14215fc2a
Reviewed-on: http://review.whamcloud.com/20353
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Jenkins
Reviewed-by: Frank Zago <fzago@cray.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
start = buffer;
while (*buffer) {
+ /* allow for a single new line before the null terminator */
+ if (*buffer == '\n') {
+ *buffer = '\0';
+ buffer++;
+
+ if (*buffer)
+ return -EINVAL;
+
+ break;
+ }
+
/* any chars after our unit indicates a malformed string */
if (hit_unit)
return -EINVAL;