Skip to content

build: Fix build on MacOS#819

Open
alexmohr wants to merge 2 commits intoCOVESA:masterfrom
alexmohr:bugfix/apple-build
Open

build: Fix build on MacOS#819
alexmohr wants to merge 2 commits intoCOVESA:masterfrom
alexmohr:bugfix/apple-build

Conversation

@alexmohr
Copy link
Copy Markdown
Contributor

@alexmohr alexmohr commented Feb 5, 2026

this commit fixes the build on MacOS, when using GCC. Building through clang is still not supported.

Tested on Apple Silicon and GCC-15

Alexander Mohr alexander.m.mohr@mercedes-benz.com, Mercedes-Benz Tech Innovation GmbH
Provider Information

this commit fixes the build on MacOS, when using GCC.
Building through clang is still not supported.

Tested on Apple Silicon

Signed-off-by: Alexander Mohr <alexander.m.mohr@mercedes-benz.com>
@minminlittleshrimp
Copy link
Copy Markdown
Collaborator

Hi @alexmohr
nice to have you contributing back to dlt topics.

For this one I am new to it, and need sometimes to verify.
Thanks

Signed-off-by: Alexander Mohr <alexander.m.mohr@mercedes-benz.com>
@alexmohr
Copy link
Copy Markdown
Contributor Author

Hi @alexmohr nice to have you contributing back to dlt topics.

For this one I am new to it, and need sometimes to verify. Thanks

@minminlittleshrimp to make it easier to verify this and to prevent breaking it again in the future, I added a build stage similar to #816.

Comment thread src/console/dlt-convert.c
memset(tmp_filename, 0, FILENAME_SIZE);
#if defined(__GNUC__) && __GNUC__ >= 7
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wformat-truncation"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of ignore, can we perform a proper fix here for truncation instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could do something like this, so print an error, free files, then exit.
Optionally we could skip freeing, return -1 exits main anyway.

            int ret = snprintf(tmp_filename, FILENAME_SIZE, "%s%s",
                    DLT_CONVERT_WS, files[index - optind + 2]->d_name);
            if (ret < 0 || ret >= FILENAME_SIZE) {
                fprintf(stderr, "ERROR: Filename too long: %s%s\n",
                        DLT_CONVERT_WS, files[index - optind + 2]->d_name);
                if (ovalue) {
                    close(ohandle);
                    ohandle = -1;
                }
                dlt_file_free(&file, vflag);
                if (files) {
                    for (int i = 0; i < n ; i++)
                        if (files[i])
                            free(files[i]);
                    free(files);
                }
                return -1;
            }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, please rework on the approach, it is fine to truncate properly with snprintf + a ret value to keep compiler satisfied

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is fine to truncate properly

But that might lead to tmp_filename containing an invalid path. I'm not sure if it's a good idea to truncate and warn because it will lead to invalid files.
As this error is in dlt-convert I think it would be better to do an approach like above and exit with an error instead working with a truncated file name.

But if you prefer truncation I'm cool with that, then I will rework it so file names will be truncated but a warning printed.
Let me know what you think is best :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@minminlittleshrimp if you find the time, I would appreciate your input here :)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, no problem @alexmohr
My team member is working on this topic

Comment thread src/daemon/dlt-daemon.c
Comment thread src/console/dlt-convert.c
memset(tmp_filename, 0, FILENAME_SIZE);
#if defined(__GNUC__) && __GNUC__ >= 7
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wformat-truncation"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, please rework on the approach, it is fine to truncate properly with snprintf + a ret value to keep compiler satisfied

@minminlittleshrimp
Copy link
Copy Markdown
Collaborator

Team member who take this: we can make use of yaml file from alex to perform checking, we dont need virt setup for MacOS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants