Skip to content

Commit

Permalink
fixes for non-conforming C compilers and Coverity
Browse files Browse the repository at this point in the history
  • Loading branch information
White-Tiger committed Aug 3, 2016
1 parent 9d1597f commit 2042b42
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
19 changes: 10 additions & 9 deletions src/DLL/Tclock.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ typedef struct MultiClock {
HWND worker;
HWND clock;
RECT workerRECT;
LONG clock_base_height;
LONG clock_base_width;
long clock_base_height;
long clock_base_width;
} MultiClock;
MultiClock m_multiClock[MAX_MULTIMON_CLOCKS];
int m_multiClocks=0;
Expand Down Expand Up @@ -85,8 +85,8 @@ union{
FillClockBG();\
} __pragma(warning(suppress:4127)) while(0)
/*** misc variables ***/
static uint16_t m_clock_base_width; ///< original clock's width used by taskbar calculation
static uint16_t m_clock_base_height; ///< original clock's height used by taskbar calculation
static long m_clock_base_width; ///< original clock's width used by taskbar calculation
static long m_clock_base_height; ///< original clock's height used by taskbar calculation
static HWND m_clock_active = NULL;
#define WPARAM_SUBCLOCK 0x8000
int m_TipState=0;
Expand Down Expand Up @@ -592,34 +592,35 @@ static LRESULT CALLBACK Window_ClockTooltip_Hooked(HWND hwnd, UINT uMsg, WPARAM
subclass procedure of the clock's tray to control clock size
---------------------------------------------------------------*/
static LRESULT CALLBACK Window_ClockTray_Hooked(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData) {
(void)dwRefData;
(void)uIdSubclass, (void)dwRefData;
switch(message) {
case(WM_USER+100):{// send by windows to get tray size
union {
struct{
uint16_t width;
uint16_t height;
};
} part;
LRESULT combined;
} size;
if(m_bNoClock)
break;
size.combined = DefSubclassProc(hwnd, message, wParam, lParam);
size.width += m_rcClock.right - m_clock_base_width;
size.part.width += (uint16_t)(m_rcClock.right - m_clock_base_width);
return size.combined;}
case WM_NOTIFY:{
LRESULT ret;
NMHDR* nmh = (NMHDR*)lParam;
RECT clock_rc;
POINT pos;
HWND child;
if(nmh->code != PGN_CALCSIZE || m_bNoClock)
break;
ret = DefSubclassProc(hwnd, message, wParam, lParam);
GetClientRect(gs_hwndClock, &clock_rc);
MapWindowPoints(gs_hwndClock, hwnd, (POINT*)&clock_rc, 1);
clock_rc.right = clock_rc.left + m_clock_base_width;
clock_rc.bottom = clock_rc.top + m_clock_base_height;
for(HWND child=GetWindow(hwnd,GW_CHILD); child; child=GetWindow(child, GW_HWNDNEXT)) {
for(child=GetWindow(hwnd,GW_CHILD); child; child=GetWindow(child, GW_HWNDNEXT)) {
pos.x = pos.y = 0;
MapWindowPoints(child, hwnd, &pos, 1);
if(pos.x >= clock_rc.right) {
Expand Down Expand Up @@ -1420,7 +1421,7 @@ void OnCopy(HWND hwnd, LPARAM lParam)
GetDisplayTime(&t, &beat100);
entry[0] = '0' + (wchar_t)LOWORD(lParam);
entry[1] = '0' + (wchar_t)HIWORD(lParam);
memcpy(entry+2, "Clip", 5*sizeof(wchar_t));
wcscpy(entry+2, L"Clip");
api.GetStr(REG_MOUSE, entry, fmt, _countof(fmt), L"");
if(!*fmt)
wcscpy(fmt, m_format);
Expand Down
9 changes: 5 additions & 4 deletions src/DLL/clock_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ static int ForceUTF_16(wchar_t* in_name, off_t file_size) {
FILE* in_fp,* out_fp;
size_t out_len, len;
wchar_t out_name[MAX_PATH];
int ret = 0;

in_fp = _wfopen(in_name, L"r+b");
if(in_fp) {
Expand All @@ -103,7 +104,7 @@ static int ForceUTF_16(wchar_t* in_name, off_t file_size) {
if(in_data && out) {
out->bom = 0xfeff;
rewind(in_fp);
fread(in_data, 1, file_size, in_fp);
file_size = (off_t)fread(in_data, 1, file_size, in_fp);
if(file_size && !IsTextUnicode(in_data,file_size,NULL)) {
in_data[file_size] = '\0';
out_len = MultiByteToWideChar(CP_ACP, 0, in_data, file_size, out->data, file_size*2);
Expand All @@ -122,7 +123,6 @@ static int ForceUTF_16(wchar_t* in_name, off_t file_size) {
out_name[len-1] = '$';
}
out_fp = _wfopen(out_name, L"wb");
fclose(in_fp);
if(out_fp) {
++out_len;
out_len ^= fwrite(out, sizeof(wchar_t), out_len, out_fp);
Expand All @@ -136,10 +136,11 @@ static int ForceUTF_16(wchar_t* in_name, off_t file_size) {
free(out);
free(in_data);
if(!in_data || !out)
return 2;
ret = 2;
}
fclose(in_fp);
}
return 0;
return ret;
}

DLL_EXPORT int SetupClockAPI(int version, TClockAPI* _api){
Expand Down
2 changes: 1 addition & 1 deletion src/DLL/format.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Last Modified by Stoic Joker: Friday, 12/16/2011 @ 3:36:00pm
#include "tcdll.h"

static WORD m_codepage = CP_ACP;
static DWORD m_codepage = CP_ACP;
static wchar_t m_MonthShort[11], m_MonthLong[31];
static wchar_t m_DayOfWeekShort[11], m_DayOfWeekLong[31];
static wchar_t* m_DayOfWeekEng[7] = { L"Sun", L"Mon", L"Tue", L"Wed", L"Thu", L"Fri", L"Sat" };
Expand Down

0 comments on commit 2042b42

Please sign in to comment.