diff mbox series

[1/3] libsepol: constify tokenized input

Message ID 20231211144827.121636-1-cgzones@googlemail.com (mailing list archive)
State Accepted
Commit 22d3609b13b4
Headers show
Series [1/3] libsepol: constify tokenized input | expand

Commit Message

Christian Göttsche Dec. 11, 2023, 2:48 p.m. UTC
The input string to be tokenized is not modified.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
 libsepol/include/sepol/policydb/util.h | 2 +-
 libsepol/src/util.c                    | 9 +++++----
 2 files changed, 6 insertions(+), 5 deletions(-)

Comments

James Carter Dec. 11, 2023, 3:49 p.m. UTC | #1
On Mon, Dec 11, 2023 at 9:48 AM Christian Göttsche
<cgzones@googlemail.com> wrote:
>
> The input string to be tokenized is not modified.
>
> Signed-off-by: Christian Göttsche <cgzones@googlemail.com>

For these three patches:
Acked-by: James Carter <jwcart2@gmail.com>

> ---
>  libsepol/include/sepol/policydb/util.h | 2 +-
>  libsepol/src/util.c                    | 9 +++++----
>  2 files changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/libsepol/include/sepol/policydb/util.h b/libsepol/include/sepol/policydb/util.h
> index db8da213..4ea5a346 100644
> --- a/libsepol/include/sepol/policydb/util.h
> +++ b/libsepol/include/sepol/policydb/util.h
> @@ -40,7 +40,7 @@ char *sepol_extended_perms_to_string(avtab_extended_perms_t *xperms);
>   * The tokenize function may be used to
>   * replace sscanf
>   */
> -extern int tokenize(char *line_buf, char delim, int num_args, ...);
> +extern int tokenize(const char *line_buf, char delim, int num_args, ...);
>
>  #ifdef __cplusplus
>  }
> diff --git a/libsepol/src/util.c b/libsepol/src/util.c
> index 2f877920..571f6c93 100644
> --- a/libsepol/src/util.c
> +++ b/libsepol/src/util.c
> @@ -221,9 +221,9 @@ err:
>   */
>
>  /* Read a token from a buffer */
> -static inline int tokenize_str(char delim, char **str, char **ptr, size_t *len)
> +static inline int tokenize_str(char delim, char **str, const char **ptr, size_t *len)
>  {
> -       char *tmp_buf = *ptr;
> +       const char *tmp_buf = *ptr;
>         *str = NULL;
>
>         while (**ptr != '\0') {
> @@ -273,9 +273,10 @@ static inline int tokenize_str(char delim, char **str, char **ptr, size_t *len)
>   * contain the remaining content of line_buf. If the delimiter is any whitespace
>   * character, then all whitespace will be squashed.
>   */
> -int tokenize(char *line_buf, char delim, int num_args, ...)
> +int tokenize(const char *line_buf, char delim, int num_args, ...)
>  {
> -       char **arg, *buf_p;
> +       char **arg;
> +       const char *buf_p;
>         int rc, items;
>         size_t arg_len = 0;
>         va_list ap;
> --
> 2.43.0
>
>
James Carter Dec. 12, 2023, 4:43 p.m. UTC | #2
On Mon, Dec 11, 2023 at 10:49 AM James Carter <jwcart2@gmail.com> wrote:
>
> On Mon, Dec 11, 2023 at 9:48 AM Christian Göttsche
> <cgzones@googlemail.com> wrote:
> >
> > The input string to be tokenized is not modified.
> >
> > Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
>
> For these three patches:
> Acked-by: James Carter <jwcart2@gmail.com>
>

These three patches have been merged.
Thanks,
Jim

> > ---
> >  libsepol/include/sepol/policydb/util.h | 2 +-
> >  libsepol/src/util.c                    | 9 +++++----
> >  2 files changed, 6 insertions(+), 5 deletions(-)
> >
> > diff --git a/libsepol/include/sepol/policydb/util.h b/libsepol/include/sepol/policydb/util.h
> > index db8da213..4ea5a346 100644
> > --- a/libsepol/include/sepol/policydb/util.h
> > +++ b/libsepol/include/sepol/policydb/util.h
> > @@ -40,7 +40,7 @@ char *sepol_extended_perms_to_string(avtab_extended_perms_t *xperms);
> >   * The tokenize function may be used to
> >   * replace sscanf
> >   */
> > -extern int tokenize(char *line_buf, char delim, int num_args, ...);
> > +extern int tokenize(const char *line_buf, char delim, int num_args, ...);
> >
> >  #ifdef __cplusplus
> >  }
> > diff --git a/libsepol/src/util.c b/libsepol/src/util.c
> > index 2f877920..571f6c93 100644
> > --- a/libsepol/src/util.c
> > +++ b/libsepol/src/util.c
> > @@ -221,9 +221,9 @@ err:
> >   */
> >
> >  /* Read a token from a buffer */
> > -static inline int tokenize_str(char delim, char **str, char **ptr, size_t *len)
> > +static inline int tokenize_str(char delim, char **str, const char **ptr, size_t *len)
> >  {
> > -       char *tmp_buf = *ptr;
> > +       const char *tmp_buf = *ptr;
> >         *str = NULL;
> >
> >         while (**ptr != '\0') {
> > @@ -273,9 +273,10 @@ static inline int tokenize_str(char delim, char **str, char **ptr, size_t *len)
> >   * contain the remaining content of line_buf. If the delimiter is any whitespace
> >   * character, then all whitespace will be squashed.
> >   */
> > -int tokenize(char *line_buf, char delim, int num_args, ...)
> > +int tokenize(const char *line_buf, char delim, int num_args, ...)
> >  {
> > -       char **arg, *buf_p;
> > +       char **arg;
> > +       const char *buf_p;
> >         int rc, items;
> >         size_t arg_len = 0;
> >         va_list ap;
> > --
> > 2.43.0
> >
> >
diff mbox series

Patch

diff --git a/libsepol/include/sepol/policydb/util.h b/libsepol/include/sepol/policydb/util.h
index db8da213..4ea5a346 100644
--- a/libsepol/include/sepol/policydb/util.h
+++ b/libsepol/include/sepol/policydb/util.h
@@ -40,7 +40,7 @@  char *sepol_extended_perms_to_string(avtab_extended_perms_t *xperms);
  * The tokenize function may be used to
  * replace sscanf
  */
-extern int tokenize(char *line_buf, char delim, int num_args, ...);
+extern int tokenize(const char *line_buf, char delim, int num_args, ...);
 
 #ifdef __cplusplus
 }
diff --git a/libsepol/src/util.c b/libsepol/src/util.c
index 2f877920..571f6c93 100644
--- a/libsepol/src/util.c
+++ b/libsepol/src/util.c
@@ -221,9 +221,9 @@  err:
  */
 
 /* Read a token from a buffer */
-static inline int tokenize_str(char delim, char **str, char **ptr, size_t *len)
+static inline int tokenize_str(char delim, char **str, const char **ptr, size_t *len)
 {
-	char *tmp_buf = *ptr;
+	const char *tmp_buf = *ptr;
 	*str = NULL;
 
 	while (**ptr != '\0') {
@@ -273,9 +273,10 @@  static inline int tokenize_str(char delim, char **str, char **ptr, size_t *len)
  * contain the remaining content of line_buf. If the delimiter is any whitespace
  * character, then all whitespace will be squashed.
  */
-int tokenize(char *line_buf, char delim, int num_args, ...)
+int tokenize(const char *line_buf, char delim, int num_args, ...)
 {
-	char **arg, *buf_p;
+	char **arg;
+	const char *buf_p;
 	int rc, items;
 	size_t arg_len = 0;
 	va_list ap;