[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] docs/misra: add exceptions to rules


  • To: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 22 Aug 2023 18:06:36 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=2EbZgH7SeckSf9BV9v2xl/XwY32LO8ezUZPwITIBIjk=; b=JAkl2o1KuumUDe+bOvq61JG4aafp3fh20x4kncArnPKKhBSVx//0FJBKez88vOcw/gd1oD1ynsjv8O/tNc62jgbe6Nsn4/Jg9JQ5QW52drppwb+xa+qrf57BgKK1IyZRMUc3DGjo/Mqq8ouKyI3tQVdqakYTUoZMaMZiT5g81bRNjafhYbw5piXpH5rXu0qrORAFr2JNreuxyelLYiq64m0sw3HVFkBH7eP8jAmE8au5Rnurnv0UpLWQzXa4wxjDW1VViC81SRgozEWYZ/4B73oSRgoeHFDI09vnlsSOJK1xXuki9/1UOtyokp8aKmH23ny5WzJnVzmSwXdXdJKoBQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=La02r7iDSl0K+Ye1JSWlC1Rmxy74LSkkNX0GKDsFOWrpsy1mcP5Gxy0WgYEj7oGuI6uIJODD2FSFvIqpA8wBNe1XEbvfYn/I8iFh3ngVnNGHzI02Zg6kCNH3ROM4KDMurQ4zVPldQFFgW51yJMHL7UDo3HKv117WlGp4GsX6sMRKiTmhYnpZaVC8R9Udn6SQ4zhJNSqDd/Tcm1V2fuKoSlWRyrkYV3LXVj825AnWblEER1+9uy3rD4qGer3ttr43pmX8O7escMLw+wzofyri23k5BqEBxfuvIscPmHCOxKZ3fRxDhfN+VeolzQDfC0xnh5Jup2kfgHzBZ5sdl8SpAQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Tue, 22 Aug 2023 16:07:16 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

(re-adding xen-devel@)

On 22.08.2023 17:09, Nicola Vetrini wrote:
> 
>>>> +         - Switch with a controlling value incompatible with labeled
>>>> +           statements
>>>
>>> What does this mean?
>>
>> I am not certain about this one actually. It could be when we have:
>>
>> switch (var) {
>>   case 1:
>>       something();
>>       break;
>>   case 2:
>>       something();
>>       break;
>> }
>>
>> and var could be 3 in theory?
>>
>> Nicola, please confirm.
>>
>>
> 
> This one is about case labels that are statically determined not to be 
> reachable (and hence
> saying that the code under that label is unreachable is not inaccurate) 
> because the
> controlling expression of the switch statement can never have such 
> value. An example below:
> 
> $ cat p.c
> int f(void) {
>    char c;
>    switch (c) {
>      case 260:
>        return 260;
>      case 4:
>        return 4;
>    }
> }
> 
> $ eclair_env -enable=MC3.R2.1,B.REPORT.TXT -- gcc -c p.c
> violation for rule MC3.R2.1: (required) A project shall not contain 
> unreachable code. (untagged)
> p.c:3.3-3.8: Loc #1 [culprit: `switch' statement has a controlling value 
> incompatible with labeled statement]
>    switch (c) {
>    <~~~~>
> p.c:5.14-5.16: Loc #2 [evidence: integer literal is unreachable]
>        return 260;
>               <~>
> 
> This is also true for things like
> 
> switch(sizeof(int)) {
>    case 2:
>      ...
>    case 4:
>      ...
> }

Ah yes, we certainly have quite a few of those. Not sure how to best
describe such for the doc, but what was suggested (still visible at
the top) doesn't get this across, I'm afraid,

Jan



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.