Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





  11.4 A cast should not be performed ...
Posted by: Frank Haug - 06-11-2007, 10:13 AM - Forum: 6.11 Pointer Type Conversions - Replies (1)

... between a pointer to object type and a different pointer to object type (advisory).

Additional comment: \" Conversions of this type may be invalid if the new pointer type requires a stricter alignment.\"

---

I think there can be further risks. I suppose - e.g. - casting a signed pointer onto an unsigned pointer (of the same bitwidth and alignment) itself is not risky. Dangerous can be to WORK with the casted pointer regarding its content, it is pointing onto. In this case the cast itself would not be dangerous, but the possibilities afterwards are.

example:

unsigned int foo (signed int* ps)
{
unsigned int* pu;

pu = (unsigned int*) ps; // assumed to be no problem itself
*pu = ... ; // assumed to be no problem itself
// but can be a problem later, when the content of the incoming pointer is used afterwards
}

Can anybody confirm ? I think it can be of interest to know the problems in more precision. Does anybody know other implications (not applying such casts) ?

Regards,
Frank

Print this item

  14.1 There shall be no unreachable code
Posted by: Frank Haug - 24-10-2007, 07:27 AM - Forum: 6.14 Control Flow - Replies (10)

The wording of 14.1 does not clarify the issue clear enough. I've discussed with several experienced persons and the common of these discussions is, that the questions only can be resolved, if someone ADDS personal interpretations. That cannot be the intension of a rule (text).

Firstly, \"defensive programming\" is not a misra rule. In my opinion this is a severe lack in/on the misra rule set. Although not explicitly defined its used in the rule text of 14.1 and its used in a confusing way: \"Code that can be reached but may never be executed is excluded from the rule (e.g. defensive programming)\".

In my tries to understand this, I refactored this sentence on following part (and nobody out of my discussions with Developers and QA Managers could give me an answer on that):

What is \"code, that can be reached but (may) never be executed\" ?

The provided example does not answer this question, because it shows code that \"exists but never will be reached\".

Maybe it helps to concretesize my intention when I re-word above sentence as follows: \"Is it possible, that code can be reached but not executed ?\"

Thanks in advance

Frank

Print this item

  Macros & 14.3 II
Posted by: gs - 22-10-2007, 02:51 PM - Forum: 6.14 Control Flow - Replies (1)

Since, according to http://www.misra-c2.com/forum/viewtopic.php?t=264, the following code is not permitted:

Code:
#if debugging
#define ASSERT(x)    asserttest(x)
#else
#define ASSERT(x)
#endif

void f(int *p)
    {
    ASSERT(p != 0);
    }

How would one make code well formed with respect to assertion macros?

Print this item

  Rule 19.9
Posted by: frankdelamarre - 08-10-2007, 12:38 PM - Forum: 6.19 Preprocessing Directives - Replies (1)

Can you please supply an example of a violation of rule 19.9? This would help to understand what the rule is really trying to enforce.

Print this item

  MISRA C:2004 rule 19.4 / extension
Posted by: Laessle - 26-09-2007, 05:59 AM - Forum: 6.19 Preprocessing Directives - Replies (1)

In our code we want to use generic macros of kind

#define macro(a) int array[2] = {a, a};

unfortunately a do-while-zero loop does not helps, cause defined objects are only known within the loop.

So we would like to ask for a further exception of the described kind.

In the attachment you will find an example to demostrate the intention of such macros.
The program reads values of an Analog Digital Converter (via SPI) and writes modified values to a Pulswidth Generator (also via SPI).
All transfers are coded in an array (Transfer_List). The contents of the array depends on the hardware (baudrate, data-format) and the tranfer-typ (read, write
number of values). The C-file has no hardware dependant function. All hardware specific settings are encapsulated in the macro Create_Transfer_List.
Modifying the hardware only needs to modify the macro. Further I/Os can be implemented very easily.

We would appreciate your positve response.

Mit freundlichen Grüßen/Best regards,

Hans-Peter Lässle
Control Systems
ETC-D

Continental Teves AG & Co. oHG
Guerickestr. 7, D-60488 Frankfurt am Main
P.O. Box 900120, D-60441 Frankfurt am Main

Telefon/Phone: 0049 69 7603-5418
Telefax: 0049 69 7603-3990
E-Mail: [email protected]
http://www.contautomotive.com
_____________________________________________________

Continental Teves AG & Co. oHG, Guerickestr. 7, D-60488 Frankfurt am Main
Sitz der Gesellschaft/Registered Office: Frankfurt am Main, Registergericht/Registered Court: Amtsgericht Frankfurt am Main HR A 27047, USt.-ID-Nr./VAT-ID-No. DE 112160365
Gesellschafter/Shareholders: Continental Aktiengesellschaft (geschäftsführend/managing)
Vorsitzender des Aufsichtsrats/Chairman of the Supervisory Board: Dr. Hubertus von Grünberg
Vorstand/Executive Board: Manfred Wennemer (Vorsitzender/Chairman), Dr. Alan Hippe, Gerhard Lerch, Dr. Karl-Thomas Neumann, Dr. Hans-Joachim Nikolin, Heinz-Gerhard Wente, William L. Kozyra (stv./Deputy)
Sitz der Gesellschaft/Registered Office: Hannover, Registergericht/Registered Court: Amtsgericht Hannover HR B 3527
Continental Teves UK Ltd., Company Number 00700225, Ebbw Vale, Wales, Großbritannien/Great Britain
_____________________________________________________
Proprietary and confidential. Distribution only by express authority of Continental AG or its subsidiaries.

Print this item

  Infinite loop
Posted by: JonM - 12-09-2007, 01:29 PM - Forum: 6.13 Control Statement Expressions - Replies (3)

What is the preferred implementation of an infinite loop?

Code:
for ( ; ; ) ...

or

Code:
while (1 == 1) ...

or

something else?

Thanks in advance.

Jonathan

Print this item

  why example suite not test suite
Posted by: MMouse - 27-07-2007, 08:14 AM - Forum: MISRA-C:2004 Exemplar Suite - No Replies

Why is it an example suite and not a test suite?

what can we use the example suite for?

Print this item

  New discussion topic - Exemplar Suite
Posted by: david ward - 26-07-2007, 02:52 PM - Forum: MISRA-C:2004 Exemplar Suite - Replies (3)

This topic is for questions and discussions related to the Exemplar Suite. For questions or discussions relating to the Rules which arise from using the Exemplar Suite, please post these in the appropriate Rule topic.

Print this item

  MISRA C TC1 and Exemplar Suite now available
Posted by: david ward - 20-07-2007, 01:44 PM - Forum: Announcements - No Replies

MISRA is pleased to announce the availability of the following resources for MISRA C:

  • Exemplar Suite
  • Technical Clarification 1 for MISRA-C:2004.
You can download the Exemplar Suite and TC from the "Resources" section of this Forum website which is visible when logged in as a registered user. Follow the link at the top of the page to register if you are not already a registered user.

July 2008: Note that a new edition of MISRA-C:2004 that incorporates the TC text is now available.

Print this item

  MISRA C:2004 Exemplar Suite
Posted by: david ward - 20-07-2007, 01:41 PM - Forum: MISRA C resources - No Replies

This suite of files is intended to illustrate issues addressed by the MISRA C rules as expressed in:

  1. MISRA-C:2004 Guidelines for the use of the C language in critical systems, ISBN 0 9524156 2 3 paperback and ISBN 0 9524156 4 X PDF.
  2. MISRA-C:2004 Technical Corrigendum 1
This Exemplar Suite is not exhaustive, but provides examples of key issues.

Please note that the Exemplar Suite is not a compliance or conformance test suite, since considerably more examples would also be needed in such a suite. Also MISRA does not offer compliance or conformance testing for tools or products.

Use of this Exemplar Suite is subject to the conditions in the enclose READ_ME file. In particular please note that a free license of these code examples is offered only for individual use. Redistribution of the code examples in any form is not permitted. If you wish to use the Exemplar Suite in this way, including distribution with a tool, please contact MISRA for licensing terms.

This suite will be updated from time to time. You can check you have the latest version by visiting this area of the MISRA Forum. There is an MD5 checksum provided in the file description that can be used to check that a copy of the archive is a genuine copy.  The date and version number of the latest release will always be listed at the end of this post.

Version history

Version number: 1.0
Date: 17 July 2007
Reason: Initial release

Latest release

Version number: 1.0
Date: 17 July 2007



Attached Files
.zip   MISRA-C_exemplar_suite_2007_07_17.zip (Size: 126.71 KB / Downloads: 18)
Print this item

Search Forums

(Advanced Search)

Forum Statistics
» Members: 6,171
» Latest member: stephanmuench
» Forum threads: 998
» Forum posts: 2,752

Full Statistics

Online Users
There are currently 84 online users.
» 0 Member(s) | 82 Guest(s)
Bing, Google

Latest Threads
Rule 6.2.1: non-inline co...
Forum: 4.6 Basic concepts
Last Post: cgpzs
22-11-2024, 10:11 AM
» Replies: 0
» Views: 37
Rule 0.1.2
Forum: 4.0 Language independent issues
Last Post: stephanmuench
21-11-2024, 01:12 PM
» Replies: 0
» Views: 47
A18-9-4
Forum: AUTOSAR C++:2014 rules
Last Post: cgpzs
23-10-2024, 12:04 PM
» Replies: 2
» Views: 399
A8-4-5: are partial moves...
Forum: AUTOSAR C++:2014 rules
Last Post: misra cpp
22-10-2024, 02:03 PM
» Replies: 1
» Views: 339
model information blocks ...
Forum: MISRA AC SLSF discussions
Last Post: misra-ac
22-10-2024, 01:27 PM
» Replies: 1
» Views: 4,459
MISRA AL SLSF - Rule 043I
Forum: MISRA AC SLSF discussions
Last Post: misra-ac
22-10-2024, 01:11 PM
» Replies: 1
» Views: 8,876
MISRA AC EC guidelines
Forum: MISRA AC SLSF discussions
Last Post: misra-ac
21-10-2024, 08:21 AM
» Replies: 4
» Views: 15,525
News on future releases
Forum: MISRA AC SLSF discussions
Last Post: misra-ac
21-10-2024, 08:05 AM
» Replies: 1
» Views: 5,707
Signal naming convention ...
Forum: MISRA AC SLSF discussions
Last Post: misra-ac
21-10-2024, 07:57 AM
» Replies: 1
» Views: 7,258
Rule 7.0.2: operator cons...
Forum: 4.7 Standard conversions
Last Post: karos
14-10-2024, 08:52 PM
» Replies: 2
» Views: 450