diff options
author | Peter Senna Tschudin <peter.senna@gmail.com> | 2012-09-17 03:04:58 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2013-03-18 19:37:09 -0400 |
commit | cab3e1ffbe1b9c7a607506338f590dc1e6ca9909 (patch) | |
tree | 279b698e61b2d54534235c6c401ddfc755cf560f /drivers/media/pci/cx25821 | |
parent | 52dee392f491e166cef21c787d1736f052a902cd (diff) |
[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>
Diffstat (limited to 'drivers/media/pci/cx25821')
-rw-r--r-- | drivers/media/pci/cx25821/cx25821-audio-upstream.c | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/drivers/media/pci/cx25821/cx25821-audio-upstream.c b/drivers/media/pci/cx25821/cx25821-audio-upstream.c index 87491ca05ee5..ea973202a66c 100644 --- a/drivers/media/pci/cx25821/cx25821-audio-upstream.c +++ b/drivers/media/pci/cx25821/cx25821-audio-upstream.c | |||
@@ -728,26 +728,17 @@ int cx25821_audio_upstream_init(struct cx25821_dev *dev, int channel_select) | |||
728 | dev->_audio_lines_count = LINES_PER_AUDIO_BUFFER; | 728 | dev->_audio_lines_count = LINES_PER_AUDIO_BUFFER; |
729 | _line_size = AUDIO_LINE_SIZE; | 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 | dev->_audiofilename = kstrdup(dev->input_audiofilename, | 733 | dev->_audiofilename = kstrdup(dev->input_audiofilename, |
733 | GFP_KERNEL); | 734 | GFP_KERNEL); |
734 | 735 | else | |
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 { | ||
744 | dev->_audiofilename = kstrdup(_defaultAudioName, | 736 | dev->_audiofilename = kstrdup(_defaultAudioName, |
745 | GFP_KERNEL); | 737 | GFP_KERNEL); |
746 | 738 | ||
747 | if (!dev->_audiofilename) { | 739 | if (!dev->_audiofilename) { |
748 | err = -ENOMEM; | 740 | err = -ENOMEM; |
749 | goto error; | 741 | goto error; |
750 | } | ||
751 | } | 742 | } |
752 | 743 | ||
753 | cx25821_sram_channel_setup_upstream_audio(dev, sram_ch, | 744 | cx25821_sram_channel_setup_upstream_audio(dev, sram_ch, |