Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

misra: fix 9.x checking when string literals are used to initialize char arrays #5234

Merged
merged 1 commit into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions addons/misra_9.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,15 +346,9 @@ def parseInitializer(self, root, token):
parent = parent.parent
isDesignated = False

if self.token.isString:
if self.token == self.token.astParent.astOperand1 and self.token.astParent.astOperand2:
self.token = self.token.astParent.astOperand2
self.ed.markAsCurrent()
self.ed = self.root.getNextChild()
else:
self.unwindAndContinue()
else:
self.unwindAndContinue()
if self.token.isString and self.ed.parent.isArray:
self.ed = self.ed.parent
self.unwindAndContinue()

def pushToRootStackAndMarkAsDesignated(self):
new = self.ed.parent
Expand Down
10 changes: 10 additions & 0 deletions addons/test/misra/crash8.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

struct three_d_filter_t {
char name[16];
double elem[2];
};

static three_d_filter_t base_filters[] = {
{"Identity", { 1.0, 0.0 } },
{"Echo", { 0.4, 0.0 } }
};