mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-30 14:33:24 -04:00
ALSA: hda: Add hda_append_suffix() local helper
As strlcat() shall be deprecated in future, provide an alternative just for a simple purpose -- append a suffix string to the given string buffer -- and use it at appropriate places. The code isn't really efficient, but we don't ask for speed here, so let it be. Link: https://lore.kernel.org/amolHJpiluNmBsDU@dev Reviewed-by: Ian Bridges <icb@fastmail.org> Tested-by: Ian Bridges <icb@fastmail.org> Link: https://patch.msgid.link/20260730161518.641254-1-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
@@ -2701,7 +2701,7 @@ static void get_jack_mode_name(struct hda_codec *codec, hda_nid_t pin,
|
||||
struct hda_gen_spec *spec = codec->spec;
|
||||
|
||||
snd_hda_get_pin_label(codec, pin, &spec->autocfg, name, name_len);
|
||||
strlcat(name, " Jack Mode", name_len);
|
||||
hda_append_suffix(name, " Jack Mode", name_len);
|
||||
}
|
||||
|
||||
static int get_out_jack_num_items(struct hda_codec *codec, hda_nid_t pin)
|
||||
@@ -5678,7 +5678,7 @@ static void fill_pcm_stream_name(char *str, size_t len, const char *sfx,
|
||||
break;
|
||||
}
|
||||
}
|
||||
strlcat(str, sfx, len);
|
||||
hda_append_suffix(str, sfx, len);
|
||||
}
|
||||
|
||||
/* copy PCM stream info from @default_str, and override non-NULL entries
|
||||
|
||||
@@ -723,4 +723,11 @@ void snd_hda_codec_display_power(struct hda_codec *codec, bool enable);
|
||||
#define codec_dbg(codec, fmt, args...) \
|
||||
dev_dbg(hda_codec_dev(codec), fmt, ##args)
|
||||
|
||||
/* append a suffix string safely; equivalent with strlcat() */
|
||||
static inline void hda_append_suffix(char *str, const char *suffix, size_t size)
|
||||
{
|
||||
size_t len = strnlen(str, size);
|
||||
strscpy(str + len, suffix, size - len);
|
||||
}
|
||||
|
||||
#endif /* __SOUND_HDA_LOCAL_H */
|
||||
|
||||
@@ -615,7 +615,7 @@ static int add_jack_kctl(struct hda_codec *codec, hda_nid_t nid,
|
||||
snd_hda_get_pin_label(codec, nid, cfg, name, sizeof(name));
|
||||
if (phantom_jack)
|
||||
/* Example final name: "Internal Mic Phantom Jack" */
|
||||
strncat(name, " Phantom", sizeof(name) - strlen(name) - 1);
|
||||
hda_append_suffix(name, " Phantom", sizeof(name));
|
||||
err = snd_hda_jack_add_kctl(codec, nid, name, phantom_jack, 0, NULL);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
Reference in New Issue
Block a user