On Fri, Nov 11 2016, Song Liu wrote: > +static ssize_t r5c_journal_mode_store(struct mddev *mddev, > + const char *page, size_t len) > +{ > + struct r5conf *conf = mddev->private; > + struct r5l_log *log = conf->log; > + int val = -1, i; > + > + if (!log) > + return -ENODEV; > + > + for (i = 0; i < sizeof(r5c_journal_mode_str) / sizeof(r5c_journal_mode_str[0]); i++) > + if (strlen(r5c_journal_mode_str[i]) == len - 1 && > + strncmp(page, r5c_journal_mode_str[i], len - 1) == 0) { > + val = i; > + break; I don't really like this "len - 1". It is presumably there to skip a trailing newline, but it doesn't check that there is a new line to skip. Some people seem to have a habit of using "echo -n ...." to write to sysfs. I suggest. if (len && page[len-1] == '\n') len -= 1; then just use "len" instead of "len - 1". Thanks, NeilBrown
Attachment:
signature.asc
Description: PGP signature