Skip to content

Commit

Permalink
Merge "Nullability check for getopt module" am: f6f8315
Browse files Browse the repository at this point in the history
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2482938

Change-Id: Ic77c35e0a615b19276c92e79c095265cf7274dbc
Signed-off-by: Automerger Merge Worker <[email protected]>
  • Loading branch information
ZijunZhaoCCK authored and android-build-merge-worker-robot committed Mar 13, 2023
2 parents 02e9b1e + f6f8315 commit ba498cf
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions libc/include/getopt.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,19 @@
#define optional_argument 2

struct option {
/** Name of long option. */
const char *name;
/**
* Name of long option. Options must have a non-NULL name.
* A NULL name signals the end of the options array.
*/
const char * _Nullable name;

/**
* One of `no_argument`, `required_argument`, or `optional_argument`.
*/
int has_arg;

/** If not NULL, set `*flag` to val when option found. */
int* flag;
int* _Nullable flag;

/** If `flag` not NULL, the value to assign to `*flag`; otherwise the return value. */
int val;
Expand All @@ -69,12 +72,12 @@ __BEGIN_DECLS
/**
* [getopt_long(3)](http://man7.org/linux/man-pages/man3/getopt.3.html) parses command-line options.
*/
int getopt_long(int __argc, char* const* __argv, const char* __options, const struct option* __long_options, int* __long_index);
int getopt_long(int __argc, char* _Nonnull const* _Nonnull __argv, const char* _Nonnull __options, const struct option* _Nonnull __long_options, int* _Nullable __long_index);

/**
* [getopt_long_only(3)](http://man7.org/linux/man-pages/man3/getopt.3.html) parses command-line options.
*/
int getopt_long_only(int __argc, char* const* __argv, const char* __options, const struct option* __long_options, int* __long_index);
int getopt_long_only(int __argc, char* _Nonnull const* _Nonnull __argv, const char* _Nonnull __options, const struct option* _Nonnull __long_options, int* _Nullable __long_index);

#ifndef _OPTRESET_DECLARED
#define _OPTRESET_DECLARED
Expand Down

0 comments on commit ba498cf

Please sign in to comment.