Re: [PATCH v3 4/7] staging: speakup: replace spk_strlwr() with strlcpytolower()

From: Samuel Thibault
Date: Wed Jul 13 2016 - 16:57:43 EST


Markus Mayer, on Fri 08 Jul 2016 15:43:11 -0700, wrote:
> After introducing generic strltolower() and strtolower(), spk_strlwr()
> is no longer needed.
>
> Signed-off-by: Markus Mayer <mmayer@xxxxxxxxxxxx>

Acked-by: Samuel Thibault <samuel.thibault@xxxxxxxxxxxx>

> ---
>
> Samuel, I left off your ACK, since the implementation of my function
> changed in v2 and again in v3. This patch has been updated to match the
> new strlcpy() semantics. Here, this means we want the length argument
> to be sizeof(new_synth_name).
>
> See https://patchwork.kernel.org/patch/9215217/ for the previous version.
>
>
> drivers/staging/speakup/kobjects.c | 3 +--
> drivers/staging/speakup/main.c | 3 ++-
> drivers/staging/speakup/speakup.h | 1 -
> drivers/staging/speakup/varhandlers.c | 12 ------------
> 4 files changed, 3 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/staging/speakup/kobjects.c b/drivers/staging/speakup/kobjects.c
> index 528cbdc..c6e0c2d 100644
> --- a/drivers/staging/speakup/kobjects.c
> +++ b/drivers/staging/speakup/kobjects.c
> @@ -387,11 +387,10 @@ static ssize_t synth_store(struct kobject *kobj, struct kobj_attribute *attr,
> len = strlen(buf);
> if (len < 2 || len > 9)
> return -EINVAL;
> - strncpy(new_synth_name, buf, len);
> + strlcpytolower(new_synth_name, buf, sizeof(new_synth_name));
> if (new_synth_name[len - 1] == '\n')
> len--;
> new_synth_name[len] = '\0';
> - spk_strlwr(new_synth_name);
> if ((synth != NULL) && (!strcmp(new_synth_name, synth->name))) {
> pr_warn("%s already in use\n", new_synth_name);
> } else if (synth_init(new_synth_name) != 0) {
> diff --git a/drivers/staging/speakup/main.c b/drivers/staging/speakup/main.c
> index 97ca4ec..970f568 100644
> --- a/drivers/staging/speakup/main.c
> +++ b/drivers/staging/speakup/main.c
> @@ -2314,7 +2314,8 @@ static int __init speakup_init(void)
> spk_initialize_msgs(); /* Initialize arrays for i18n. */
> spk_reset_default_chars();
> spk_reset_default_chartab();
> - spk_strlwr(synth_name);
> + if (synth_name)
> + strtolower(synth_name);
> spk_vars[0].u.n.high = vc->vc_cols;
> for (var = spk_vars; var->var_id != MAXVARS; var++)
> speakup_register_var(var);
> diff --git a/drivers/staging/speakup/speakup.h b/drivers/staging/speakup/speakup.h
> index df74c91..4725785 100644
> --- a/drivers/staging/speakup/speakup.h
> +++ b/drivers/staging/speakup/speakup.h
> @@ -50,7 +50,6 @@ void synth_insert_next_index(int sent_num);
> void spk_reset_index_count(int sc);
> void spk_get_index_count(int *linecount, int *sentcount);
> int spk_set_key_info(const u_char *key_info, u_char *k_buffer);
> -char *spk_strlwr(char *s);
> char *spk_s2uchar(char *start, char *dest);
> int speakup_kobj_init(void);
> void speakup_kobj_exit(void);
> diff --git a/drivers/staging/speakup/varhandlers.c b/drivers/staging/speakup/varhandlers.c
> index e1393d2..a1af222 100644
> --- a/drivers/staging/speakup/varhandlers.c
> +++ b/drivers/staging/speakup/varhandlers.c
> @@ -309,18 +309,6 @@ int spk_set_mask_bits(const char *input, const int which, const int how)
> return 0;
> }
>
> -char *spk_strlwr(char *s)
> -{
> - char *p;
> -
> - if (!s)
> - return NULL;
> -
> - for (p = s; *p; p++)
> - *p = tolower(*p);
> - return s;
> -}
> -
> char *spk_s2uchar(char *start, char *dest)
> {
> int val;
> --
> 2.7.4
>

--
Samuel
bien sûr que ça convient mieux à tout le monde
enfin, dans la mesure où tout le monde c'est comme moi
-+- le consensus, c'est facile -+-