Skip to content

Commit f327e62

Browse files
committed
posix: c_lib_ext: apply clang-format to getopt sources
The getopt sources were not formatted according to our codying style conventions, so apply formatting rules as a separate commit. Signed-off-by: Chris Friedt <[email protected]>
1 parent 00bb121 commit f327e62

File tree

4 files changed

+99
-128
lines changed

4 files changed

+99
-128
lines changed

lib/posix/c_lib_ext/getopt/getopt.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@
4141
#include <zephyr/logging/log.h>
4242
LOG_MODULE_REGISTER(getopt);
4343

44-
#define BADCH ((int)'?')
45-
#define BADARG ((int)':')
46-
#define EMSG ""
44+
#define BADCH ((int)'?')
45+
#define BADARG ((int)':')
46+
#define EMSG ""
4747

4848
void getopt_init(void)
4949
{
@@ -61,7 +61,7 @@ void getopt_init(void)
6161

6262
#if CONFIG_GETOPT_LONG
6363
state->nonopt_start = -1; /* first non option argument (for permute) */
64-
state->nonopt_end = -1; /* first option after non options (for permute) */
64+
state->nonopt_end = -1; /* first option after non options (for permute) */
6565
#endif
6666

6767
opterr = 1;
@@ -151,8 +151,7 @@ int getopt(int nargc, char *const nargv[], const char *ostr)
151151
return BADARG;
152152
}
153153
if (state->opterr) {
154-
LOG_DBG("option requires an argument -- %c",
155-
state->optopt);
154+
LOG_DBG("option requires an argument -- %c", state->optopt);
156155
}
157156
z_getopt_global_state_update(state);
158157
return BADCH;
@@ -161,5 +160,5 @@ int getopt(int nargc, char *const nargv[], const char *ostr)
161160
++state->optind;
162161
}
163162
z_getopt_global_state_update(state);
164-
return state->optopt; /* return option letter */
163+
return state->optopt; /* return option letter */
165164
}

lib/posix/c_lib_ext/getopt/getopt.h

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,29 @@ extern "C" {
1414
#include <zephyr/kernel.h>
1515

1616
struct getopt_state {
17-
int opterr; /* if error message should be printed */
18-
int optind; /* index into parent argv vector */
19-
int optopt; /* character checked for validity */
20-
int optreset; /* reset getopt */
21-
char *optarg; /* argument associated with option */
17+
int opterr; /* if error message should be printed */
18+
int optind; /* index into parent argv vector */
19+
int optopt; /* character checked for validity */
20+
int optreset; /* reset getopt */
21+
char *optarg; /* argument associated with option */
2222

23-
char *place; /* option letter processing */
23+
char *place; /* option letter processing */
2424

2525
#if CONFIG_GETOPT_LONG
2626
int nonopt_start;
2727
int nonopt_end;
2828
#endif
2929
};
3030

31-
extern int optreset; /* reset getopt */
31+
extern int optreset; /* reset getopt */
3232
extern char *optarg;
3333
extern int opterr;
3434
extern int optind;
3535
extern int optopt;
3636

37-
#define no_argument 0
38-
#define required_argument 1
39-
#define optional_argument 2
37+
#define no_argument 0
38+
#define required_argument 1
39+
#define optional_argument 2
4040

4141
struct option {
4242
/* name of long option */
@@ -79,9 +79,8 @@ struct getopt_state *getopt_state_get(void);
7979
* @return If an option was successfully found, function returns
8080
* the option character.
8181
*/
82-
int getopt_long(int nargc, char *const *nargv,
83-
const char *options, const struct option *long_options,
84-
int *idx);
82+
int getopt_long(int nargc, char *const *nargv, const char *options,
83+
const struct option *long_options, int *idx);
8584

8685
/**
8786
* @brief Parses the command-line arguments.
@@ -106,9 +105,8 @@ int getopt_long(int nargc, char *const *nargv,
106105
* @return If an option was successfully found, function returns
107106
* the option character.
108107
*/
109-
int getopt_long_only(int nargc, char *const *nargv,
110-
const char *options, const struct option *long_options,
111-
int *idx);
108+
int getopt_long_only(int nargc, char *const *nargv, const char *options,
109+
const struct option *long_options, int *idx);
112110

113111
#ifdef __cplusplus
114112
}

lib/posix/c_lib_ext/getopt/getopt_common.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
* When more threads are using getopt please call getopt_state_get to know
1717
* getopt state for the current thread.
1818
*/
19-
int opterr = 1; /* if error message should be printed */
20-
int optind = 1; /* index into parent argv vector */
21-
int optopt; /* character checked for validity */
22-
int optreset; /* reset getopt */
23-
char *optarg; /* argument associated with option */
19+
int opterr = 1; /* if error message should be printed */
20+
int optind = 1; /* index into parent argv vector */
21+
int optopt; /* character checked for validity */
22+
int optreset; /* reset getopt */
23+
char *optarg; /* argument associated with option */
2424

2525
/* Common state for all threads that did not have own getopt state. */
2626
static struct getopt_state m_getopt_common_state = {
@@ -34,7 +34,7 @@ static struct getopt_state m_getopt_common_state = {
3434

3535
#if CONFIG_GETOPT_LONG
3636
.nonopt_start = -1, /* first non option argument (for permute) */
37-
.nonopt_end = -1, /* first option after non options (for permute) */
37+
.nonopt_end = -1, /* first option after non options (for permute) */
3838
#endif
3939
};
4040

0 commit comments

Comments
 (0)