Commit cab3e1ff authored by Peter Senna Tschudin's avatar Peter Senna Tschudin Committed by Mauro Carvalho Chehab

[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: default avatarPeter Senna Tschudin <peter.senna@gmail.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 52dee392
...@@ -728,26 +728,17 @@ int cx25821_audio_upstream_init(struct cx25821_dev *dev, int channel_select) ...@@ -728,26 +728,17 @@ int cx25821_audio_upstream_init(struct cx25821_dev *dev, int channel_select)
dev->_audio_lines_count = LINES_PER_AUDIO_BUFFER; dev->_audio_lines_count = LINES_PER_AUDIO_BUFFER;
_line_size = AUDIO_LINE_SIZE; _line_size = AUDIO_LINE_SIZE;
if (dev->input_audiofilename) { if ((dev->input_audiofilename) &&
(strcmp(dev->input_audiofilename, "") != 0))
dev->_audiofilename = kstrdup(dev->input_audiofilename, dev->_audiofilename = kstrdup(dev->input_audiofilename,
GFP_KERNEL); GFP_KERNEL);
else
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, dev->_audiofilename = kstrdup(_defaultAudioName,
GFP_KERNEL); GFP_KERNEL);
if (!dev->_audiofilename) { if (!dev->_audiofilename) {
err = -ENOMEM; err = -ENOMEM;
goto error; goto error;
}
} }
cx25821_sram_channel_setup_upstream_audio(dev, sram_ch, cx25821_sram_channel_setup_upstream_audio(dev, sram_ch,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment