projects
/
pulseview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
LogicSegment::pow2_ceil(): Fix potentіal integer overflow.
[pulseview.git]
/
pv
/
data
/
logicsegment.cpp
diff --git
a/pv/data/logicsegment.cpp
b/pv/data/logicsegment.cpp
index 58cf00e5dddbfcc6e1514cb0534084546fbe3dec..5d6faf8f8fe1a5333f8130cfcb17725db99a07ab 100644
(file)
--- a/
pv/data/logicsegment.cpp
+++ b/
pv/data/logicsegment.cpp
@@
-17,12
+17,15
@@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+#include "config.h" // For HAVE_UNALIGNED_LITTLE_ENDIAN_ACCESS
+
#include <extdef.h>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <extdef.h>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
+#include <cstdint>
#include "logic.hpp"
#include "logicsegment.hpp"
#include "logic.hpp"
#include "logicsegment.hpp"
@@
-62,7
+65,7
@@
LogicSegment::~LogicSegment()
free(l.data);
}
free(l.data);
}
-uint64_t LogicSegment::unpack_sample(const uint8_t *ptr) const
+
inline
uint64_t LogicSegment::unpack_sample(const uint8_t *ptr) const
{
#ifdef HAVE_UNALIGNED_LITTLE_ENDIAN_ACCESS
return *(uint64_t*)ptr;
{
#ifdef HAVE_UNALIGNED_LITTLE_ENDIAN_ACCESS
return *(uint64_t*)ptr;
@@
-100,7
+103,7
@@
uint64_t LogicSegment::unpack_sample(const uint8_t *ptr) const
#endif
}
#endif
}
-void LogicSegment::pack_sample(uint8_t *ptr, uint64_t value)
+
inline
void LogicSegment::pack_sample(uint8_t *ptr, uint64_t value)
{
#ifdef HAVE_UNALIGNED_LITTLE_ENDIAN_ACCESS
*(uint64_t*)ptr = value;
{
#ifdef HAVE_UNALIGNED_LITTLE_ENDIAN_ACCESS
*(uint64_t*)ptr = value;
@@
-478,7
+481,7
@@
uint64_t LogicSegment::get_subsample(int level, uint64_t offset) const
uint64_t LogicSegment::pow2_ceil(uint64_t x, unsigned int power)
{
uint64_t LogicSegment::pow2_ceil(uint64_t x, unsigned int power)
{
- const uint64_t p =
1
<< power;
+ const uint64_t p =
UINT64_C(1)
<< power;
return (x + p - 1) / p * p;
}
return (x + p - 1) / p * p;
}