[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 5/6] procfs: define macros for the default argument values
From: |
Justus Winter |
Subject: |
[PATCH 5/6] procfs: define macros for the default argument values |
Date: |
Thu, 27 Jun 2013 14:31:27 +0200 |
Define a macro for the default value of each command line
parameter. This allows one to generate a minimal response to
fsys_get_options requests.
* procfs/main.c: New macro definitions for default values.
---
procfs/main.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/procfs/main.c b/procfs/main.c
index 859b9db..4c8440d 100644
--- a/procfs/main.c
+++ b/procfs/main.c
@@ -37,6 +37,13 @@ pid_t opt_fake_self;
pid_t opt_kernel_pid;
uid_t opt_anon_owner;
+/* Default values */
+#define OPT_CLK_TCK sysconf(_SC_CLK_TCK)
+#define OPT_STAT_MODE 0400
+#define OPT_FAKE_SELF -1
+#define OPT_KERNEL_PID 2
+#define OPT_ANON_OWNER 0
+
static error_t
argp_parser (int key, char *arg, struct argp_state *state)
{
@@ -211,11 +218,11 @@ int main (int argc, char **argv)
mach_port_t bootstrap;
error_t err;
- opt_clk_tck = sysconf(_SC_CLK_TCK);
- opt_stat_mode = 0400;
- opt_fake_self = -1;
- opt_kernel_pid = 2;
- opt_anon_owner = 0;
+ opt_clk_tck = OPT_CLK_TCK;
+ opt_stat_mode = OPT_STAT_MODE;
+ opt_fake_self = OPT_FAKE_SELF;
+ opt_kernel_pid = OPT_KERNEL_PID;
+ opt_anon_owner = OPT_ANON_OWNER;
err = argp_parse (&argp, argc, argv, 0, 0, 0);
if (err)
error (1, err, "Could not parse command line");
--
1.7.10.4
- [PATCH 3/6] procfs: enable fsys_set_options, (continued)
- [PATCH 3/6] procfs: enable fsys_set_options, Justus Winter, 2013/06/28
- [PATCH 2/6] procfs: keep old config values if the parsing fails, Justus Winter, 2013/06/28
- [PATCH 5/6] procfs: define macros for the default argument values, Justus Winter, 2013/06/28
- [PATCH 4/6] procfs: handle the --update parameter, Justus Winter, 2013/06/28
- [PATCH 6/6] procfs: provide a more meaningful response to fsys_get_options, Justus Winter, 2013/06/28
- Re: [PATCH 1/6] procfs: fix the error handling in argp_parser, Samuel Thibault, 2013/06/29
- Re: [PATCH 1/6] procfs: fix the error handling in argp_parser, Justus Winter, 2013/06/29
- Re: [PATCH 1/6] procfs: fix the error handling in argp_parser, Samuel Thibault, 2013/06/30
[PATCH 2/6] procfs: keep old config values if the parsing fails, Justus Winter, 2013/06/27
[PATCH 3/6] procfs: enable fsys_set_options, Justus Winter, 2013/06/27
[PATCH 5/6] procfs: define macros for the default argument values,
Justus Winter <=
[PATCH 6/6] procfs: provide a more meaningful response to fsys_get_options, Justus Winter, 2013/06/27
[PATCH 4/6] procfs: handle the --update parameter, Justus Winter, 2013/06/27
Re: some work on procfs, Samuel Thibault, 2013/06/29