if (attrs->n_actions >= HIST_ACTIONS_MAX)
return ret;
- if ((strncmp(str, "onmatch(", sizeof("onmatch(") - 1) == 0) ||
- (strncmp(str, "onmax(", sizeof("onmax(") - 1) == 0)) {
+ if ((str_has_prefix(str, "onmatch(")) ||
+ (str_has_prefix(str, "onmax("))) {
attrs->action_str[attrs->n_actions] = kstrdup(str, GFP_KERNEL);
if (!attrs->action_str[attrs->n_actions]) {
ret = -ENOMEM;
{
int ret = 0;
- if ((strncmp(str, "key=", sizeof("key=") - 1) == 0) ||
- (strncmp(str, "keys=", sizeof("keys=") - 1) == 0)) {
+ if ((str_has_prefix(str, "key=")) ||
+ (str_has_prefix(str, "keys="))) {
attrs->keys_str = kstrdup(str, GFP_KERNEL);
if (!attrs->keys_str) {
ret = -ENOMEM;
goto out;
}
- } else if ((strncmp(str, "val=", sizeof("val=") - 1) == 0) ||
- (strncmp(str, "vals=", sizeof("vals=") - 1) == 0) ||
- (strncmp(str, "values=", sizeof("values=") - 1) == 0)) {
+ } else if ((str_has_prefix(str, "val=")) ||
+ (str_has_prefix(str, "vals=")) ||
+ (str_has_prefix(str, "values="))) {
attrs->vals_str = kstrdup(str, GFP_KERNEL);
if (!attrs->vals_str) {
ret = -ENOMEM;
goto out;
}
- } else if (strncmp(str, "sort=", sizeof("sort=") - 1) == 0) {
+ } else if (str_has_prefix(str, "sort=")) {
attrs->sort_key_str = kstrdup(str, GFP_KERNEL);
if (!attrs->sort_key_str) {
ret = -ENOMEM;
goto out;
}
- } else if (strncmp(str, "name=", sizeof("name=") - 1) == 0) {
+ } else if (str_has_prefix(str, "name=")) {
attrs->name = kstrdup(str, GFP_KERNEL);
if (!attrs->name) {
ret = -ENOMEM;
goto out;
}
- } else if (strncmp(str, "clock=", sizeof("clock=") - 1) == 0) {
+ } else if (str_has_prefix(str, "clock=")) {
strsep(&str, "=");
if (!str) {
ret = -EINVAL;
ret = -ENOMEM;
goto out;
}
- } else if (strncmp(str, "size=", sizeof("size=") - 1) == 0) {
+ } else if (str_has_prefix(str, "size=")) {
int map_bits = parse_map_size(str);
if (map_bits < 0) {
if (!onmax_fn_name || !str)
goto free;
- if (strncmp(onmax_fn_name, "save", sizeof("save") - 1) == 0) {
+ if (str_has_prefix(onmax_fn_name, "save")) {
char *params = strsep(&str, ")");
if (!params) {
for (i = 0; i < hist_data->attrs->n_actions; i++) {
str = hist_data->attrs->action_str[i];
- if (strncmp(str, "onmatch(", sizeof("onmatch(") - 1) == 0) {
+ if (str_has_prefix(str, "onmatch(")) {
char *action_str = str + sizeof("onmatch(") - 1;
data = onmatch_parse(tr, action_str);
break;
}
data->fn = action_trace;
- } else if (strncmp(str, "onmax(", sizeof("onmax(") - 1) == 0) {
+ } else if (str_has_prefix(str, "onmax(")) {
char *action_str = str + sizeof("onmax(") - 1;
data = onmax_parse(action_str);