Skip to content

Minor style changes to the code#439

Open
freddy77 wants to merge 7 commits into
xapi-project:masterfrom
freddy77:styles
Open

Minor style changes to the code#439
freddy77 wants to merge 7 commits into
xapi-project:masterfrom
freddy77:styles

Conversation

@freddy77

@freddy77 freddy77 commented Feb 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fix file guards spellings
  • Update definitions to use ANSI style
  • Check all required headers are present during configuration
  • Avoid crash calling safe_strncpy with zero size
  • Ignore warnings calling strncpy
  • Remove unused return value from safe_strncpy
  • Fix typo in comment

Mostly detected by a more recent compiler.

Make sure file guards macros are consistent.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
Some compiler nowadays complain about the old K&R syntax.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
Avoid surprises later, during the build phase.

The additional includes checking cmocka.h are needed as
cmocka.h file is not self-sufficient.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
The call to strncpy would crash as "n - 1" would be cause filling
unwanted memory with zero bytes.
There was already the check to avoid underflowing the
buffer for terminator, but not for the string.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
Avoid warnings/errors like:

   error: 'strncpy' output may be truncated copying 254 bytes
   from a string of length 255 [-Werror=stringop-truncation]

The function is already doing the correct checks to avoid
that condition.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
Never used.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
@freddy77

Copy link
Copy Markdown
Contributor Author

ping

@AnthoineB

AnthoineB commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

I agree with the modifications of safe_strncpy except with commit bbbc6ad.
It should be possible to fix those warnings properly.
Can you remove the patch in this PR and create a new PR with the stringop-truncation warnings fixed?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants