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

Cppcheck fixes but its for rimage #46

Merged
merged 4 commits into from
May 19, 2021
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
30 changes: 30 additions & 0 deletions .github/workflows/cppcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
# SPDX-License-Identifier: BSD-3-Clause
# Tools that can save round-trips to github and a lot of time:
#
# yamllint -f parsable this.yml
# pip3 install ruamel.yaml.cmd
# yaml merge-expand this.yml exp.yml && diff -w -u this.yml exp.yml
#
# github.com also has a powerful web editor that can be used without
# committing.

name: cppcheck

# yamllint disable-line rule:truthy
on: [pull_request, push]

jobs:
cppcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with: {fetch-depth: 50, submodules: recursive}

- name: apt install cppcheck
run: sudo apt update && sudo apt-get -y install cppcheck

# TODO enable more types of checks as they are fixed
- name: run cppcheck
run: cppcheck --platform=unix32 --force --max-configs=1024
--inconclusive --quiet --inline-suppr .
25 changes: 25 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
# SPDX-License-Identifier: BSD-3-Clause
# Tools that can save round-trips to github and a lot of time:
#
# yamllint -f parsable this.yml
# pip3 install ruamel.yaml.cmd
# yaml merge-expand this.yml exp.yml && diff -w -u this.yml exp.yml
#
# github.com also has a powerful web editor that can be used without
# committing.

name: checkpatch

# yamllint disable-line rule:truthy
on: [pull_request]

jobs:
yamllint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with: {fetch-depth: 50, submodules: recursive}

- name: run yamllint
run: yamllint .github/workflows/*.yml
2 changes: 1 addition & 1 deletion src/adsp_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -1867,7 +1867,7 @@ static int parse_mod_config(const toml_table_t *mod_entry, struct parse_ctx *ctx
static void parse_uuid(char *buf, uint8_t *uuid)
{
struct uuid_t id;
uint32_t d[9];
uint32_t d[10];

sscanf(buf, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", &id.d0, &d[0],
&d[1], &d[2], &d[3], &d[4], &d[5], &d[6], &d[7], &d[8], &d[9]);
Expand Down
12 changes: 4 additions & 8 deletions src/ext_manifest.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ static int ext_man_build(const struct module *module,
{
struct ext_man_header ext_man;
const Elf32_Shdr *section;
uint8_t *buffer = NULL;
uint8_t *sec_buffer = NULL;
size_t offset;
int ret;
Expand All @@ -114,20 +113,17 @@ static int ext_man_build(const struct module *module,
goto out;
}

/* alloc buffer for ext_man */
buffer = calloc(1, ext_man.full_size);
if (!buffer) {
*dst_buff = calloc(1, ext_man.full_size);
if (!*dst_buff) {
ret = -ENOMEM;
goto out;
}

/* fill buffer with ext_man and section content */
memcpy(buffer, &ext_man, ext_man.header_size);
memcpy(*dst_buff, &ext_man, ext_man.header_size);
offset = ext_man.header_size;

memcpy(&buffer[offset], sec_buffer, section->size);

*dst_buff = (struct ext_man_header *)buffer;
memcpy(((char *)*dst_buff) + offset, sec_buffer, section->size);

out:
free(sec_buffer);
Expand Down
9 changes: 6 additions & 3 deletions src/manifest.c
Original file line number Diff line number Diff line change
Expand Up @@ -1383,19 +1383,22 @@ int verify_image(struct image *image)
if (ret < 0) {
fprintf(stderr, "error: unable to seek eof %s for reading %d\n",
image->verify_file, errno);
return -errno;
ret = -errno;
goto out;
}
size = ftell(in_file);
if (size < 0) {
fprintf(stderr, "error: unable to get file size for %s %d\n",
image->verify_file, errno);
return -errno;
ret = -errno;
goto out;
}
ret = fseek(in_file, 0, SEEK_SET);
if (ret < 0) {
fprintf(stderr, "error: unable to seek %s for reading %d\n",
image->verify_file, errno);
return -errno;
ret = -errno;
goto out;
}

/* allocate buffer for parsing */
Expand Down