• Peter Senna Tschudin's avatar
    [media] cx25821: Cleanup filename assignment code · cab3e1ff
    Peter Senna Tschudin authored
    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>
    cab3e1ff
cx25821-audio-upstream.c 19.5 KB