diff options
author | Robert Moore <Robert.Moore@intel.com> | 2013-05-07 12:04:53 -0700 |
---|---|---|
committer | Robert Moore <Robert.Moore@intel.com> | 2013-05-07 12:04:53 -0700 |
commit | 63ebf517fdd5aec6b3ca4f870d47d930c7d04ad5 (patch) | |
tree | 12abe96d628873cf4a919c4db55c22d8784dd853 | |
parent | ba84d0fc18ba910a47a3f71c68a43543c06e6831 (diff) |
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.
-rw-r--r-- | source/common/getopt.c | 68 | ||||
-rw-r--r-- | source/compiler/aslcompiler.h | 9 | ||||
-rw-r--r-- | source/compiler/aslerror.c | 134 | ||||
-rw-r--r-- | source/compiler/aslglobal.h | 3 | ||||
-rw-r--r-- | source/compiler/aslmain.c | 22 | ||||
-rw-r--r-- | source/compiler/aslmessages.h | 84 | ||||
-rw-r--r-- | source/compiler/dtutils.c | 17 | ||||
-rw-r--r-- | source/compiler/prscan.c | 32 | ||||
-rw-r--r-- | source/include/acapps.h | 6 |
9 files changed, 295 insertions, 80 deletions
diff --git a/source/common/getopt.c b/source/common/getopt.c index 45eb72664..de4ea5f0b 100644 --- a/source/common/getopt.c +++ b/source/common/getopt.c @@ -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; } diff --git a/source/compiler/aslcompiler.h b/source/compiler/aslcompiler.h index 4c2bfcb87..d258c9d44 100644 --- a/source/compiler/aslcompiler.h +++ b/source/compiler/aslcompiler.h @@ -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, diff --git a/source/compiler/aslerror.c b/source/compiler/aslerror.c index 6d9398add..886302678 100644 --- a/source/compiler/aslerror.c +++ b/source/compiler/aslerror.c @@ -751,6 +751,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 * * PARAMETERS: Level - Seriousness (Warning/error, etc.) @@ -773,34 +880,25 @@ AslError ( char *ExtraMessage) { - switch (Level) - { - case ASL_WARNING2: - case ASL_WARNING3: - - if (Gbl_WarningLevel < Level) - { - return; - } - break; - - default: + /* Check if user wants to ignore this exception */ - break; + if (AslIsExceptionDisabled (Level, MessageId)) + { + 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); } } diff --git a/source/compiler/aslglobal.h b/source/compiler/aslglobal.h index 9d285eb23..5468711f6 100644 --- a/source/compiler/aslglobal.h +++ b/source/compiler/aslglobal.h @@ -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 */ diff --git a/source/compiler/aslmain.c b/source/compiler/aslmain.c index 4f420030d..64136c21f 100644 --- a/source/compiler/aslmain.c +++ b/source/compiler/aslmain.c @@ -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"); diff --git a/source/compiler/aslmessages.h b/source/compiler/aslmessages.h index 3915739f2..586afcae6 100644 --- a/source/compiler/aslmessages.h +++ b/source/compiler/aslmessages.h @@ -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; +#ifdef ASL_EXCEPTIONS + +/* Strings for message reporting levels, must match values above */ -/* Values for all compiler messages */ +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 */ diff --git a/source/compiler/dtutils.c b/source/compiler/dtutils.c index 44d295a19..dacb9c481 100644 --- a/source/compiler/dtutils.c +++ b/source/compiler/dtutils.c @@ -154,20 +154,11 @@ DtError ( char *ExtraMessage) { - switch (Level) - { - case ASL_WARNING2: - case ASL_WARNING3: + /* Check if user wants to ignore this exception */ - if (Gbl_WarningLevel < Level) - { - return; - } - break; - - default: - - break; + if (AslIsExceptionDisabled (Level, MessageId)) + { + return; } if (FieldObject) diff --git a/source/compiler/prscan.c b/source/compiler/prscan.c index f4a58bb9b..a32f14c6a 100644 --- a/source/compiler/prscan.c +++ b/source/compiler/prscan.c @@ -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: diff --git a/source/include/acapps.h b/source/include/acapps.h index 072cc1092..eefa5d6b7 100644 --- a/source/include/acapps.h +++ b/source/include/acapps.h @@ -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; |