Skip to content

Commit

Permalink
AudioDxe: Fix Coverity warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
mikebeaton committed Dec 19, 2021
1 parent 44de104 commit 70196d0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Staging/AudioDxe/HdaCodec/HdaCodec.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

#include "AudioDxe.h"

#define HDA_CODEC_ERROR_ON_NO_OUTPUTS

typedef struct _HDA_CODEC_DEV HDA_CODEC_DEV;
typedef struct _HDA_FUNC_GROUP HDA_FUNC_GROUP;
typedef struct _HDA_WIDGET_DEV HDA_WIDGET_DEV;
Expand Down
11 changes: 10 additions & 1 deletion Staging/AudioDxe/HdaCodec/HdaCodecAudioIo.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,18 @@ HdaCodecAudioIoSetupPlayback(
}
OutputIndexMask &= ~LShiftU64(MAX_UINT64, HdaCodecDev->OutputPortsCount);

#if defined(HDA_CODEC_ERROR_ON_NO_OUTPUTS)
// Fail visibily if nothing is requested.
// (Not required, should just play nothing without this.)
if (OutputIndexMask == 0) {
return EFI_INVALID_PARAMETER;
}
#endif

// Avoid Coverity warnings (the bit mask checks actually ensure that these cannot be used uninitialised).
StreamBits = 0;
StreamDiv = 0;
StreamMult = 0;
StreamBase44kHz = FALSE;

// Expand the requested stream frequency and sample size params,
// and check that every requested channel can support them.
Expand Down Expand Up @@ -474,10 +481,12 @@ HdaCodecAudioIoSetupPlayback(
// Save requested outputs.
AudioIoPrivateData->SelectedOutputIndexMask = OutputIndexMask;

#if !defined(HDA_CODEC_ERROR_ON_NO_OUTPUTS)
// Nothing to play.
if (OutputIndexMask == 0) {
return EFI_SUCCESS;
}
#endif

// Calculate stream format and setup stream.
StreamFmt = HDA_CONVERTER_FORMAT_SET(Channels - 1, StreamBits,
Expand Down

0 comments on commit 70196d0

Please sign in to comment.