Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] cx25821: Cleanup filename assignment code

I'm pasting the original code and my proposal on the commit message for
make it easy to compare the two versions.
Line 62 of cx25821-audio-upstream.h contains:
char *_defaultAudioName = "/root/audioGOOD.wav";
Original code after replace kmemdup for kstrdup, and after fix return error
code:
if (dev->input_audiofilename) {
dev->_audiofilename = kstrdup(dev->input_audiofilename,
GFP_KERNEL);
if (!dev->_audiofilename) {
err = -ENOMEM;
goto error;
}
/* Default if filename is empty string */
if (strcmp(dev->input_audiofilename, "") == 0)
dev->_audiofilename = "/root/audioGOOD.wav";
} else {
dev->_audiofilename = kstrdup(_defaultAudioName,
GFP_KERNEL);
if (!dev->_audiofilename) {
err = -ENOMEM;
goto error;
}
}
Code proposed in this patch:
if ((dev->input_audiofilename) &&
(strcmp(dev->input_audiofilename, "") != 0))
dev->_audiofilename = kstrdup(dev->input_audiofilename,
GFP_KERNEL);
else
dev->_audiofilename = kstrdup(_defaultAudioName,
GFP_KERNEL);
if (!dev->_audiofilename) {
err = -ENOMEM;
goto error;
}

Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by

Peter Senna Tschudin and committed by
Mauro Carvalho Chehab
cab3e1ff 52dee392

+6 -15
+6 -15
drivers/media/pci/cx25821/cx25821-audio-upstream.c
··· 728 728 dev->_audio_lines_count = LINES_PER_AUDIO_BUFFER; 729 729 _line_size = AUDIO_LINE_SIZE; 730 730 731 - if (dev->input_audiofilename) { 731 + if ((dev->input_audiofilename) && 732 + (strcmp(dev->input_audiofilename, "") != 0)) 732 733 dev->_audiofilename = kstrdup(dev->input_audiofilename, 733 734 GFP_KERNEL); 734 - 735 - if (!dev->_audiofilename) { 736 - err = -ENOMEM; 737 - goto error; 738 - } 739 - 740 - /* Default if filename is empty string */ 741 - if (strcmp(dev->input_audiofilename, "") == 0) 742 - dev->_audiofilename = "/root/audioGOOD.wav"; 743 - } else { 735 + else 744 736 dev->_audiofilename = kstrdup(_defaultAudioName, 745 737 GFP_KERNEL); 746 738 747 - if (!dev->_audiofilename) { 748 - err = -ENOMEM; 749 - goto error; 750 - } 739 + if (!dev->_audiofilename) { 740 + err = -ENOMEM; 741 + goto error; 751 742 } 752 743 753 744 cx25821_sram_channel_setup_upstream_audio(dev, sram_ch,