iASL: Add mechanism to disable specific warnings/remarks.

New command line option, -vw<messageid>. also #pragma disable <messageid>.
ACPICA BZ 989. Chao Guan, Bob Moore.
This commit is contained in:
Robert Moore 2013-05-07 12:04:53 -07:00
parent ba84d0fc18
commit 63ebf517fd
9 changed files with 295 additions and 80 deletions

View File

@ -113,6 +113,15 @@
*
*****************************************************************************/
/*
* ACPICA getopt() implementation
*
* Option strings:
* "f" - Option has no arguments
* "f:" - Option requires an argument
* "f^" - Option has optional single-char sub-options
* "f|" - Option has required single-char sub-options
*/
#include <stdio.h>
#include <string.h>
@ -124,9 +133,59 @@
if (AcpiGbl_Opterr) {fprintf (stderr, "%s%c\n", msg, badchar);}
int AcpiGbl_Opterr = 1;
int AcpiGbl_Optind = 1;
char *AcpiGbl_Optarg;
int AcpiGbl_Opterr = 1;
int AcpiGbl_Optind = 1;
int AcpiGbl_SubOptChar = 0;
char *AcpiGbl_Optarg;
static int CurrentCharPtr = 1;
/*******************************************************************************
*
* FUNCTION: AcpiGetoptArgument
*
* PARAMETERS: argc, argv - from main
*
* RETURN: 0 if an argument was found, -1 otherwise. Sets AcpiGbl_Optarg
* to point to the next argument.
*
* DESCRIPTION: Get the next argument. Used to obtain arguments for the
* two-character options after the original call to AcpiGetopt.
* Note: Either the argument starts at the next character after
* the option, or it is pointed to by the next argv entry.
* (After call to AcpiGetopt, we need to backup to the previous
* argv entry).
*
******************************************************************************/
int
AcpiGetoptArgument (
int argc,
char **argv)
{
AcpiGbl_Optind--;
CurrentCharPtr++;
if (argv[AcpiGbl_Optind][(int) (CurrentCharPtr+1)] != '\0')
{
AcpiGbl_Optarg = &argv[AcpiGbl_Optind++][(int) (CurrentCharPtr+1)];
}
else if (++AcpiGbl_Optind >= argc)
{
ACPI_OPTION_ERROR ("Option requires an argument: -", 'v');
CurrentCharPtr = 1;
return (-1);
}
else
{
AcpiGbl_Optarg = argv[AcpiGbl_Optind++];
}
CurrentCharPtr = 1;
return (0);
}
/*******************************************************************************
@ -148,7 +207,6 @@ AcpiGetopt(
char **argv,
char *opts)
{
static int CurrentCharPtr = 1;
int CurrentChar;
char *OptsPtr;
@ -224,6 +282,7 @@ AcpiGetopt(
AcpiGbl_Optarg = "^";
}
AcpiGbl_SubOptChar = AcpiGbl_Optarg[0];
AcpiGbl_Optind++;
CurrentCharPtr = 1;
}
@ -244,6 +303,7 @@ AcpiGetopt(
return ('?');
}
AcpiGbl_SubOptChar = AcpiGbl_Optarg[0];
AcpiGbl_Optind++;
CurrentCharPtr = 1;
}

View File

@ -363,6 +363,15 @@ AslError (
ACPI_PARSE_OBJECT *Op,
char *ExtraMessage);
ACPI_STATUS
AslDisableException (
char *MessageIdString);
BOOLEAN
AslIsExceptionDisabled (
UINT8 Level,
UINT8 MessageId);
void
AslCoreSubsystemError (
ACPI_PARSE_OBJECT *Op,

View File

@ -749,6 +749,113 @@ AslCommonError (
}
/*******************************************************************************
*
* FUNCTION: AslDisableException
*
* PARAMETERS: MessageIdString - ID to be disabled
*
* RETURN: Status
*
* DESCRIPTION: Enter a message ID into the global disabled messages table
*
******************************************************************************/
ACPI_STATUS
AslDisableException (
char *MessageIdString)
{
UINT32 MessageId;
/* Convert argument to an integer and validate it */
MessageId = (UINT32) strtoul (MessageIdString, NULL, 0);
if ((MessageId < 2000) || (MessageId > 5999))
{
printf ("\"%s\" is not a valid warning/remark ID\n",
MessageIdString);
return (AE_BAD_PARAMETER);
}
/* Insert value into the global disabled message array */
if (Gbl_DisabledMessagesIndex >= ASL_MAX_DISABLED_MESSAGES)
{
printf ("Too many messages have been disabled (max %u)\n",
ASL_MAX_DISABLED_MESSAGES);
return (AE_LIMIT);
}
Gbl_DisabledMessages[Gbl_DisabledMessagesIndex] = MessageId;
Gbl_DisabledMessagesIndex++;
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: AslIsExceptionDisabled
*
* PARAMETERS: Level - Seriousness (Warning/error, etc.)
* MessageId - Index into global message buffer
*
* RETURN: TRUE if exception/message should be ignored
*
* DESCRIPTION: Check if the user has specified options such that this
* exception should be ignored
*
******************************************************************************/
BOOLEAN
AslIsExceptionDisabled (
UINT8 Level,
UINT8 MessageId)
{
UINT32 EncodedMessageId;
UINT32 i;
switch (Level)
{
case ASL_WARNING2:
case ASL_WARNING3:
/* Check for global disable via -w1/-w2/-w3 options */
if (Level > Gbl_WarningLevel)
{
return (TRUE);
}
/* Fall through */
case ASL_WARNING:
case ASL_REMARK:
/*
* Ignore this warning/remark if it has been disabled by
* the user (-vw option)
*/
EncodedMessageId = MessageId + ((Level + 1) * 1000);
for (i = 0; i < Gbl_DisabledMessagesIndex; i++)
{
/* Simple implementation via fixed array */
if (EncodedMessageId == Gbl_DisabledMessages[i])
{
return (TRUE);
}
}
break;
default:
break;
}
return (FALSE);
}
/*******************************************************************************
*
* FUNCTION: AslError
@ -773,34 +880,25 @@ AslError (
char *ExtraMessage)
{
switch (Level)
/* Check if user wants to ignore this exception */
if (AslIsExceptionDisabled (Level, MessageId))
{
case ASL_WARNING2:
case ASL_WARNING3:
if (Gbl_WarningLevel < Level)
{
return;
}
break;
default:
break;
return;
}
if (Op)
{
AslCommonError (Level, MessageId, Op->Asl.LineNumber,
Op->Asl.LogicalLineNumber,
Op->Asl.LogicalByteOffset,
Op->Asl.Column,
Op->Asl.Filename, ExtraMessage);
Op->Asl.LogicalLineNumber,
Op->Asl.LogicalByteOffset,
Op->Asl.Column,
Op->Asl.Filename, ExtraMessage);
}
else
{
AslCommonError (Level, MessageId, 0,
0, 0, 0, NULL, ExtraMessage);
0, 0, 0, NULL, ExtraMessage);
}
}

View File

@ -182,6 +182,7 @@ extern char *AslCompilertext;
#define ASL_DEFAULT_LINE_BUFFER_SIZE (1024 * 32) /* 32K */
#define ASL_MSG_BUFFER_SIZE 4096
#define ASL_MAX_DISABLED_MESSAGES 32
#define HEX_TABLE_LINE_SIZE 8
#define HEX_LISTING_LINE_SIZE 8
@ -296,6 +297,7 @@ ASL_EXTERN char *Gbl_TemplateSignature;
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_CurrentHexColumn, 0);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_CurrentAmlOffset, 0);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_CurrentLine, 0);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_DisabledMessagesIndex, 0);
ASL_EXTERN UINT8 ASL_INIT_GLOBAL (Gbl_HexBytesWereWritten, FALSE);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_NumNamespaceObjects, 0);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_ReservedMethods, 0);
@ -322,6 +324,7 @@ ASL_EXTERN UINT8 Gbl_AmlBuffer[HEX_LISTING_LINE_SIZE];
ASL_EXTERN char MsgBuffer[ASL_MSG_BUFFER_SIZE];
ASL_EXTERN char StringBuffer[ASL_MSG_BUFFER_SIZE];
ASL_EXTERN char StringBuffer2[ASL_MSG_BUFFER_SIZE];
ASL_EXTERN UINT32 Gbl_DisabledMessages[ASL_MAX_DISABLED_MESSAGES];
#endif /* __ASLGLOBAL_H */

View File

@ -208,6 +208,7 @@ Options (
ACPI_OPTION ("-vo", "Enable optimization comments");
ACPI_OPTION ("-vr", "Disable remarks");
ACPI_OPTION ("-vs", "Disable signon");
ACPI_OPTION ("-vw <messageid>", "Disable specific warning or remark");
ACPI_OPTION ("-w1 -w2 -w3", "Set warning reporting level");
ACPI_OPTION ("-we", "Report warnings as errors");
@ -518,8 +519,8 @@ AslDoOptions (
char **argv,
BOOLEAN IsResponseFile)
{
int j;
ACPI_STATUS Status;
UINT32 j;
/* Get the command line options */
@ -966,9 +967,26 @@ AslDoOptions (
break;
case 't':
Gbl_VerboseTemplates = TRUE;
break;
case 'w':
/* Get the required argument */
if (AcpiGetoptArgument (argc, argv))
{
return (-1);
}
Status = AslDisableException (AcpiGbl_Optarg);
if (ACPI_FAILURE (Status))
{
return (-1);
}
break;
default:
printf ("Unknown option: -v%s\n", AcpiGbl_Optarg);
@ -1089,8 +1107,6 @@ AslCommandLine (
}
}
/* Abort if anything went wrong on the command line */
if (BadCommandLine)
{
printf ("\n");

View File

@ -118,17 +118,52 @@
#define __ASLMESSAGES_H
#define ASL_WARNING 0
#define ASL_WARNING2 1
#define ASL_WARNING3 2
#define ASL_ERROR 3
#define ASL_REMARK 4
#define ASL_OPTIMIZATION 5
#define ASL_NUM_REPORT_LEVELS 6
typedef enum
{
ASL_OPTIMIZATION = 0,
ASL_REMARK,
ASL_WARNING,
ASL_WARNING2,
ASL_WARNING3,
ASL_ERROR,
ASL_NUM_REPORT_LEVELS
} ASL_MESSAGE_TYPES;
/* Values for all compiler messages */
#ifdef ASL_EXCEPTIONS
/* Strings for message reporting levels, must match values above */
const char *AslErrorLevel [ASL_NUM_REPORT_LEVELS] = {
"Optimize",
"Remark ",
"Warning ",
"Warning ",
"Warning ",
"Error "
};
/* All lowercase versions for IDEs */
const char *AslErrorLevelIde [ASL_NUM_REPORT_LEVELS] = {
"optimize",
"remark ",
"warning ",
"warning ",
"warning ",
"error "
};
#define ASL_ERROR_LEVEL_LENGTH 8 /* Length of strings above */
#endif
/*
* Values for all compiler messages.
*
* NOTE: With the introduction of the -vw option to disable specific messages,
* new messages should only be added to the end of this list, so that values
* for existing messages are not disturbed.
*/
typedef enum
{
ASL_MSG_RESERVED = 0,
@ -308,9 +343,15 @@ typedef enum
#ifdef ASL_EXCEPTIONS
/* Actual message strings for each compiler message */
char *AslMessages [] = {
/*
* Actual message strings for each compiler message.
*
* NOTE: With the introduction of the -vw option to disable specific messages,
* new messages should only be added to the end of this list, so that values
* for existing messages are not disturbed.
*/
char *AslMessages [] =
{
/* The zeroth message is reserved */ "",
/* ASL_MSG_ALIGNMENT */ "Must be a multiple of alignment/granularity value",
/* ASL_MSG_ALPHANUMERIC_STRING */ "String must be entirely alphanumeric",
@ -482,27 +523,6 @@ char *AslMessages [] = {
/* ASL_MSG_ZERO_VALUE */ "Value must be non-zero"
};
const char *AslErrorLevel [ASL_NUM_REPORT_LEVELS] = {
"Warning ",
"Warning ",
"Warning ",
"Error ",
"Remark ",
"Optimize"
};
const char *AslErrorLevelIde [ASL_NUM_REPORT_LEVELS] = {
"warning ",
"warning ",
"warning ",
"error ",
"remark ",
"optimize"
};
#define ASL_ERROR_LEVEL_LENGTH 8 /* Length of strings above */
#endif /* ASL_EXCEPTIONS */
#endif /* __ASLMESSAGES_H */

View File

@ -154,20 +154,11 @@ DtError (
char *ExtraMessage)
{
switch (Level)
/* Check if user wants to ignore this exception */
if (AslIsExceptionDisabled (Level, MessageId))
{
case ASL_WARNING2:
case ASL_WARNING3:
if (Gbl_WarningLevel < Level)
{
return;
}
break;
default:
break;
return;
}
if (FieldObject)

View File

@ -769,23 +769,35 @@ PrDoDirective (
case PR_DIRECTIVE_PRAGMA:
/* Only "#pragma message" supported at this time */
if (!strcmp (Token, "disable"))
{
Token = PrGetNextToken (NULL, PR_TOKEN_SEPARATORS, Next);
if (!Token)
{
goto SyntaxError;
}
if (strcmp (Token, "message"))
TokenOffset = Token - Gbl_MainTokenBuffer;
AslDisableException (&Gbl_CurrentLineBuffer[TokenOffset]);
}
else if (!strcmp (Token, "message"))
{
Token = PrGetNextToken (NULL, PR_TOKEN_SEPARATORS, Next);
if (!Token)
{
goto SyntaxError;
}
TokenOffset = Token - Gbl_MainTokenBuffer;
AcpiOsPrintf ("%s\n", &Gbl_CurrentLineBuffer[TokenOffset]);
}
else
{
PrError (ASL_ERROR, ASL_MSG_UNKNOWN_PRAGMA,
THIS_TOKEN_OFFSET (Token));
return;
}
Token = PrGetNextToken (NULL, PR_TOKEN_SEPARATORS, Next);
if (!Token)
{
goto SyntaxError;
}
TokenOffset = Token - Gbl_MainTokenBuffer;
AcpiOsPrintf ("%s\n", &Gbl_CurrentLineBuffer[TokenOffset]);
break;
case PR_DIRECTIVE_UNDEF:

View File

@ -175,8 +175,14 @@ AcpiGetopt(
char **argv,
char *opts);
int
AcpiGetoptArgument (
int argc,
char **argv);
extern int AcpiGbl_Optind;
extern int AcpiGbl_Opterr;
extern int AcpiGbl_SubOptChar;
extern char *AcpiGbl_Optarg;