[IdUtils] Fix aliasing warning
ClosedPublic

Authored by bruns on Jun 16 2019, 4:37 PM.

Details

Summary

memcpy with a small fixed size is optimized by all contemporary compilers
to a few assembly instructions, but contrary to the pointer casting it
lets the compiler do the right thing.

Test Plan

ctest

Diff Detail

Repository
R293 Baloo
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
bruns created this revision.Jun 16 2019, 4:37 PM
Restricted Application added projects: Frameworks, Baloo. · View Herald TranscriptJun 16 2019, 4:37 PM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
bruns requested review of this revision.Jun 16 2019, 4:37 PM
ngraham accepted this revision.Jun 16 2019, 5:41 PM
This revision is now accepted and ready to land.Jun 16 2019, 5:41 PM
This revision was automatically updated to reflect the committed changes.

+1

Thx for the confirmation!

Alternative: return (quint64(devId) << 32) | inode;

Not endian-dependent, like the memcpy solution. Make sure the other side is adapted to match.

Alternative: return (quint64(devId) << 32) | inode;

Not endian-dependent, like the memcpy solution. Make sure the other side is adapted to match.

Thats the problem here - the "other side" is an ondisk DB ...

But removing devId from the ID and just keeping inode is on the todo list, we are asking for trouble here anyway in case of 64bit inodes.