speakup_audptr: cleanup synth_version
The buffer was bigger than necessary, and the while loop not very canonical. Also better use i as variable name for an index. Reported-by: kernel test robot <lkp@intel.com> Suggested-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Link: https://lore.kernel.org/r/20220206023845.bpzxtjohekclffra@begin Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
9583e4ee49
commit
353b940c90
@ -126,20 +126,22 @@ static void synth_flush(struct spk_synth *synth)
|
|||||||
|
|
||||||
static void synth_version(struct spk_synth *synth)
|
static void synth_version(struct spk_synth *synth)
|
||||||
{
|
{
|
||||||
unsigned char test = 0;
|
unsigned i;
|
||||||
char synth_id[40] = "";
|
char synth_id[33];
|
||||||
|
|
||||||
synth->synth_immediate(synth, "\x05[Q]");
|
synth->synth_immediate(synth, "\x05[Q]");
|
||||||
synth_id[test] = synth->io_ops->synth_in(synth);
|
synth_id[0] = synth->io_ops->synth_in(synth);
|
||||||
if (synth_id[test] == 'A') {
|
if (synth_id[0] != 'A')
|
||||||
do {
|
return;
|
||||||
/* read version string from synth */
|
|
||||||
synth_id[++test] = synth->io_ops->synth_in(synth);
|
for (i = 1; i < sizeof(synth_id) - 1; i++) {
|
||||||
} while (synth_id[test] != '\n' && test < 32);
|
/* read version string from synth */
|
||||||
synth_id[++test] = 0x00;
|
synth_id[i] = synth->io_ops->synth_in(synth);
|
||||||
|
if (synth_id[i] == '\n')
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (synth_id[0] == 'A')
|
synth_id[i] = '\0';
|
||||||
pr_info("%s version: %s", synth->long_name, synth_id);
|
pr_info("%s version: %s", synth->long_name, synth_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int synth_probe(struct spk_synth *synth)
|
static int synth_probe(struct spk_synth *synth)
|
||||||
|
Reference in New Issue
Block a user