Skip to content

Commit

Permalink
Convert gcc struct initializers in dvbci.cpp to C++ code (clang++)
Browse files Browse the repository at this point in the history
Note: The tTime struct also looks to be both endian unsafe and is used in a reinterpreting cast unsafely a couple lines later.
  • Loading branch information
daniel-kristjansson committed Dec 12, 2012
1 parent be8dd30 commit 45ecb6f
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions mythtv/libs/libmythtv/recorders/dvbdev/dvbci.cpp
Expand Up @@ -1102,13 +1102,13 @@ bool cCiDateTime::SendDateTime(void)
int MJD = 14956 + D + int((Y - L) * 365.25) + int((M + 1 + L * 12) * 30.6001);
#define DEC2BCD(d) (uint8_t(((d / 10) << 4) + (d % 10)))
struct tTime { unsigned short mjd; uint8_t h, m, s; short offset; };
tTime T = {
mjd : htons(MJD),
h : DEC2BCD(tm_gmt.tm_hour),
m : DEC2BCD(tm_gmt.tm_min),
s : DEC2BCD(tm_gmt.tm_sec),
offset : static_cast<short>(htons(tm_loc.tm_gmtoff / 60))
};
tTime T;
T.mjd = htons(MJD);
T.h = DEC2BCD(tm_gmt.tm_hour);
T.m = DEC2BCD(tm_gmt.tm_min);
T.s = DEC2BCD(tm_gmt.tm_sec);
T.offset = static_cast<short>(htons(tm_loc.tm_gmtoff / 60));

dbgprotocol("%d: ==> Date Time\n", SessionId());
SendData(AOT_DATE_TIME, 7, (uint8_t*)&T);
//XXX return value of all SendData() calls???
Expand Down Expand Up @@ -1245,7 +1245,9 @@ bool cCiMMI::Process(int Length, const uint8_t *Data)
case DCC_SET_MMI_MODE:
if (l == 2 && *++d == MM_HIGH_LEVEL) {
struct tDisplayReply { uint8_t id; uint8_t mode; };
tDisplayReply dr = { id : DRI_MMI_MODE_ACK, mode : MM_HIGH_LEVEL };
tDisplayReply dr;
dr.id = DRI_MMI_MODE_ACK;
dr.mode = MM_HIGH_LEVEL;
dbgprotocol("%d: ==> Display Reply\n", SessionId());
SendData(AOT_DISPLAY_REPLY, 2, (uint8_t *)&dr);
}
Expand Down

0 comments on commit 45ecb6f

Please sign in to comment.