Ticket #7158: libs_libmythtv-constant-expression

File libs_libmythtv-constant-expression, 1.7 KB (added by Erik Hovland <erik@…>, 15 years ago)

Fix value manipulations that always end up evaluating a certain way

Line 
1Conditionals that hold values that always evaluate one way
2
3From: Erik Hovland <erik@hovland.org>
4
51. I am pretty sure that since this is checking a bit flag that & is
6   more appropriate here.
7
82. If length is left shifted by 8 and then masted w/ 0x0f, it will
9   always evaluate to 0. I am almost sure that what is wanted is
10   the mask and then the left shift.
11---
12
13 .../libs/libmythtv/channelscan/channelimporter.cpp |    2 +-
14 mythtv/libs/libmythtv/mpeg/mpegtables.h            |    2 +-
15 2 files changed, 2 insertions(+), 2 deletions(-)
16
17
18diff --git a/mythtv/libs/libmythtv/channelscan/channelimporter.cpp b/mythtv/libs/libmythtv/channelscan/channelimporter.cpp
19index 09ca16c..3cf3ab6 100644
20--- a/mythtv/libs/libmythtv/channelscan/channelimporter.cpp
21+++ b/mythtv/libs/libmythtv/channelscan/channelimporter.cpp
22@@ -54,7 +54,7 @@ void ChannelImporter::Process(const ScanDTVTransportList &_transports)
23     ScanDTVTransportList transports = _transports;
24 
25     // Print out each channel
26-    if (print_verbose_messages | VB_CHANSCAN)
27+    if (print_verbose_messages & VB_CHANSCAN)
28     {
29         cout << "Before processing: " << endl;
30         ChannelImporterBasicStats infoA = CollectStats(transports);
31diff --git a/mythtv/libs/libmythtv/mpeg/mpegtables.h b/mythtv/libs/libmythtv/mpeg/mpegtables.h
32index 34ff51c..05d56e5 100644
33--- a/mythtv/libs/libmythtv/mpeg/mpegtables.h
34+++ b/mythtv/libs/libmythtv/mpeg/mpegtables.h
35@@ -661,7 +661,7 @@ class ProgramMapTable : public PSIPTable
36 
37     void SetProgramInfoLength(uint length)
38     {
39-        psipdata()[2] = ((length<<8) & 0x0f) | (psipdata()[2] & 0xf0);
40+        psipdata()[2] = ((length & 0x0f) << 8) | (psipdata()[2] & 0xf0);
41         psipdata()[3] = length & 0xff;
42     }
43