Re: [PATCH 2/3] perf/buildid-cache: Support --list option

From: Jiri Olsa
Date: Fri Apr 13 2018 - 08:56:04 EST


On Mon, Apr 09, 2018 at 04:36:32PM +0530, Ravi Bangoria wrote:

SNIP

> int cmd_buildid_cache(int argc, const char **argv)
> {
> struct strlist *list;
> @@ -304,6 +324,8 @@ int cmd_buildid_cache(int argc, const char **argv)
> int ret = 0;
> int ns_id = -1;
> bool force = false;
> + bool list_files = false;
> + bool opts_flag = false;
> char const *add_name_list_str = NULL,
> *remove_name_list_str = NULL,
> *purge_name_list_str = NULL,
> @@ -327,6 +349,7 @@ int cmd_buildid_cache(int argc, const char **argv)
> "file(s) to remove"),
> OPT_STRING('p', "purge", &purge_name_list_str, "file list",
> "file(s) to remove (remove old caches too)"),
> + OPT_BOOLEAN('l', "list", &list_files, "list all cached files"),
> OPT_STRING('M', "missing", &missing_filename, "file",
> "to find missing build ids in the cache"),
> OPT_BOOLEAN('f', "force", &force, "don't complain, do it"),
> @@ -344,11 +367,18 @@ int cmd_buildid_cache(int argc, const char **argv)
> argc = parse_options(argc, argv, buildid_cache_options,
> buildid_cache_usage, 0);
>
> - if (argc || (!add_name_list_str && !kcore_filename &&
> - !remove_name_list_str && !purge_name_list_str &&
> - !missing_filename && !update_name_list_str))
> + opts_flag = add_name_list_str || kcore_filename ||
> + remove_name_list_str || purge_name_list_str ||
> + missing_filename || update_name_list_str;
> +
> + if (argc || !(list_files || opts_flag))
> usage_with_options(buildid_cache_usage, buildid_cache_options);
>
> + /* -l is exclusive. It can not be used with other options. */
> + if (list_files && opts_flag)
> + usage_with_options_msg(buildid_cache_usage,
> + buildid_cache_options, "-l is exclusive.\n");

missing {} on multiline condition leg

jirka