On Wed, Jun 17, 2020 at 11:36:46AM +0300, Alexey Budankov wrote:

SNIP

> +     memset(cmd_data, 0, data_size--);
> +
> +     do {
> +             err = read(evlist->ctl_fd.fd, &c, 1);
> +             if (err > 0) {
> +                     if (c == '\n' || c == '\0')
> +                             break;
> +                     cmd_data[bytes_read++] = c;
> +                     if (bytes_read == data_size)
> +                             break;
> +             } else {
> +                     if (err == -1)
> +                             pr_err("Failed to read from ctlfd %d: %m\n", 
> evlist->ctl_fd.fd);
> +                     break;
> +             }
> +     } while (1);
> +
> +     pr_debug("Message from ctl_fd: \"%s%s\"\n", cmd_data,
> +              bytes_read == data_size ? "" : c == '\n' ? "\\n" : "\\0");
> +
> +     if (err > 0) {
> +             if (!strncmp(cmd_data, EVLIST_CTL_CMD_ENABLE_TAG,
> +                          strlen(EVLIST_CTL_CMD_ENABLE_TAG))) {

you could use sizeof(EVLIST_CTL_CMD_ENABLE_TAG) instead, no function call

> +                     *cmd = EVLIST_CTL_CMD_ENABLE;
> +             } else if (!strncmp(cmd_data, EVLIST_CTL_CMD_DISABLE_TAG,
> +                                 strlen(EVLIST_CTL_CMD_DISABLE_TAG))) {

ditto

jirka

Reply via email to