Skip to content

PGPRO-5646: remove compiler warning (gcc 11.2.0) #11

New issue

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

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

Already on ? Sign in to your account

Merged
merged 1 commit into from
Oct 22, 2021
Merged

Conversation

MarinaPolyakova
Copy link
Contributor

In function ‘ptrack_write_chunk’,
inlined from ‘ptrackCheckpoint’ at engine.c:397:2:
engine.c:78:13: warning: ‘write’ reading 8 bytes from a region of size 4
[-Wstringop-overread]
78 | if (write(fd, chunk, size) != size)
| ^~~~~~~~~~~~~~~~~~~~~~
In file included from engine.c:47:
engine.c: In function ‘ptrackCheckpoint’:
engine.h:55:25: note: source object ‘magic’ of size 4
55 | char magic[PTRACK_MAGIC_SIZE];
| ^~~~~
In file included from engine.c:22:
/usr/include/unistd.h:378:16: note: in a call to function ‘write’ declared with
attribute ‘access (read_only, 2, 3)’
378 | extern ssize_t write (int __fd, const void *__buf, size_t __n) __wur
| ^~~~~

In C a pointer to the first field of a structure and a pointer to the structure
itself are always equal.

@codecov
Copy link

codecov bot commented Oct 8, 2021

Codecov Report

Merging #11 (3dbc4fa) into master (3d6ccc6) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #11   +/-   ##
=======================================
  Coverage   87.40%   87.40%           
=======================================
  Files           2        2           
  Lines         381      381           
=======================================
  Hits          333      333           
  Misses         48       48           
Impacted FilesCoverage Δ
engine.c84.64% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3d6ccc6...3dbc4fa. Read the comment docs.

In function ‘ptrack_write_chunk’,
    inlined from ‘ptrackCheckpoint’ at engine.c:397:2:
engine.c:78:13: warning: ‘write’ reading 8 bytes from a region of size 4
[-Wstringop-overread]
   78 |         if (write(fd, chunk, size) != size)
      |             ^~~~~~~~~~~~~~~~~~~~~~
In file included from engine.c:47:
engine.c: In function ‘ptrackCheckpoint’:
engine.h:55:25: note: source object ‘magic’ of size 4
   55 |         char            magic[PTRACK_MAGIC_SIZE];
      |                         ^~~~~
In file included from engine.c:22:
/usr/include/unistd.h:378:16: note: in a call to function ‘write’ declared with
attribute ‘access (read_only, 2, 3)’
  378 | extern ssize_t write (int __fd, const void *__buf, size_t __n) __wur
      |                ^~~~~

In C a pointer to the first field of a structure and a pointer to the structure
itself are always equal. Add a compile-time assertion check in case the field
magic is not the first field in the structure PtrackMapHdr in the future.

Thanks to Maksim Orlov for the review.
Sign up for free to join this conversation on . Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants