Permalink
Browse files

windows splint errors fixed

  • Loading branch information...
maoserr committed Aug 28, 2010
1 parent cdaa14e commit b86fd98d8c1d11acea68e028be6189ca2deb8497
Showing with 194 additions and 103 deletions.
  1. +32 −35 CMakeLists.txt
  2. +14 −0 splint.xh
  3. +43 −12 src/backends/w32gdi.c
  4. +0 −15 src/backends/w32gdi.h
  5. +5 −2 src/common.h
  6. +1 −0 src/gamma.c
  7. +2 −0 src/gamma.h
  8. +3 −3 src/gui/iupgui.c
  9. +5 −4 src/gui/iupgui_gamma.c
  10. +49 −2 src/gui/iupgui_settings.c
  11. +16 −4 src/location.c
  12. +2 −2 src/netutils.c
  13. +2 −6 src/options.c
  14. +10 −10 src/redshiftgui.c
  15. +4 −2 src/solar.c
  16. +3 −3 src/systemtime.c
  17. +3 −3 src/thirdparty/logger.h
View
@@ -62,53 +62,59 @@ set(RSGNSRC
${RSG_SRC_DIR}/thirdparty/logger.h
${RSG_SRC_DIR}/thirdparty/logger.c
${RSG_SRC_DIR}/thirdparty/stb_image.h
- ${RSG_SRC_DIR}/thirdparty/stb_image.c)
-# Project Source files
-set(RSGSRC
+ ${RSG_SRC_DIR}/thirdparty/stb_image.c
${RSG_SRC_DIR}/common.h
${RSG_SRC_DIR}/gamma.h
- ${RSG_SRC_DIR}/gamma.c
${RSG_SRC_DIR}/location.h
+ ${RSG_SRC_DIR}/options.h
+ ${RSG_SRC_DIR}/solar.h
+ ${RSG_SRC_DIR}/systemtime.h
+ )
+# Project Source files
+set(RSGSRC
+ ${RSG_SRC_DIR}/gamma.c
${RSG_SRC_DIR}/location.c
- ${RSG_SRC_DIR}/netutils.h
${RSG_SRC_DIR}/netutils.c
- ${RSG_SRC_DIR}/options.h
${RSG_SRC_DIR}/options.c
${RSG_SRC_DIR}/redshiftgui.c
- ${RSG_SRC_DIR}/solar.h
${RSG_SRC_DIR}/solar.c
- ${RSG_SRC_DIR}/systemtime.h
${RSG_SRC_DIR}/systemtime.c
${RSG_SRC_DIR}/resources/redshift.c
${RSG_SRC_DIR}/resources/redshift-idle.c
${RSG_SRC_DIR}/resources/sun.c
${RSG_SRC_DIR}/resources/sunback.c
)
APPEND_IF_VAR(RSGSRC ENABLE_GTK
- ${RSG_SRC_DIR}/gui/gtkgui.c
+ ${RSG_SRC_DIR}/gui/gtkgui.c)
+APPEND_IF_VAR(RSGNSRC ENABLE_GTK
${RSG_SRC_DIR}/gui/gtkgui.h)
APPEND_IF_VAR(RSGSRC ENABLE_IUP
${RSG_SRC_DIR}/gui/iupgui.c
- ${RSG_SRC_DIR}/gui/iupgui.h
${RSG_SRC_DIR}/gui/iupgui_gamma.c
- ${RSG_SRC_DIR}/gui/iupgui_gamma.h
${RSG_SRC_DIR}/gui/iupgui_location.c
- ${RSG_SRC_DIR}/gui/iupgui_location.h
${RSG_SRC_DIR}/gui/iupgui_main.c
- ${RSG_SRC_DIR}/gui/iupgui_main.h
${RSG_SRC_DIR}/gui/iupgui_settings.c
+ )
+APPEND_IF_VAR(RSGNSRC ENABLE_IUP
+ ${RSG_SRC_DIR}/gui/iupgui.h
+ ${RSG_SRC_DIR}/gui/iupgui_gamma.h
+ ${RSG_SRC_DIR}/gui/iupgui_location.h
+ ${RSG_SRC_DIR}/gui/iupgui_main.h
${RSG_SRC_DIR}/gui/iupgui_settings.h
)
if(UNIX AND NOT APPLE)
APPEND_IF_VAR(RSGSRC ENABLE_RANDR
- ${RSG_SRC_DIR}/backends/randr.c
+ ${RSG_SRC_DIR}/backends/randr.c)
+ APPEND_IF_VAR(RSGNSRC ENABLE_RANDR
${RSG_SRC_DIR}/backends/randr.h)
APPEND_IF_VAR(RSGSRC ENABLE_VIDMODE
- ${RSG_SRC_DIR}/backends/vidmode.c
+ ${RSG_SRC_DIR}/backends/vidmode.c)
+ APPEND_IF_VAR(RSGNSRC ENABLE_VIDMODE
${RSG_SRC_DIR}/backends/vidmode.h)
elseif(WIN32)
APPEND_IF_VAR(RSGSRC ENABLE_WINGDI
- ${RSG_SRC_DIR}/backends/w32gdi.c
+ ${RSG_SRC_DIR}/backends/w32gdi.c)
+ APPEND_IF_VAR(RSGNSRC ENABLE_WINGDI
${RSG_SRC_DIR}/backends/w32gdi.h)
# Resource file
configure_file(${RSG_SRC_DIR}/win32/app.rc.in
@@ -118,7 +124,7 @@ elseif(WIN32)
configure_file(${RSG_SRC_DIR}/win32/app.64.manifest.in
${RSG_SRC_DIR}/win32/app.64.manifest)
include(AddMingwRC)
- ADD_RC_FILE(${RSG_SRC_DIR}/win32 app RSGSRC)
+ ADD_RC_FILE(${RSG_SRC_DIR}/win32 app RSGNSRC)
endif(UNIX AND NOT APPLE)
# 3rd party packages
@@ -209,10 +215,10 @@ endif(UNIX)
# Preprocessor definitions
unset(RSG_DEFINITIONS CACHE)
set(RSG_DEFS ${RSG_DEFS}
- PACKAGE="${APP_NAME}"
- PACKAGE_HOME="${RSG_HOMEPAGE}"
- PACKAGE_BUGREPORT="${RSG_BUGREPORT}"
- PACKAGE_VER="${RSG_VERSION}"
+ PACKAGE=${APP_NAME}
+ PACKAGE_HOME=${RSG_HOMEPAGE}
+ PACKAGE_BUGREPORT=${RSG_BUGREPORT}
+ PACKAGE_VER=${RSG_VERSION}
)
CHECK_INCLUDE_FILE(libintl.h ENABLE_NLS)
CHECK_INCLUDE_FILE(sys/signal.h HAVE_SYS_SIGNAL_H)
@@ -276,34 +282,25 @@ if(SPLINT_PATH)
)
elseif(MSVC)
set(SPLINT_PARAMS ${SPLINT_PARAMS}
+ -D__STDC__=1
+ -D_WIN32
-D_MSC_VER=1500
-D_M_IX86=400
- -DWIN32
- -D_NTSYSTEM
- -D_WIN32_WINNT=0x0400
- -DWINVER=600
-DNOGDI
- -DNOKERNEL
- -DNOUSER
-DWIN32_LEAN_AND_MEAN
-D__int64=long
- -D_int64=int
-D__w64=
-D__ptr64=
- -D_wtoi=atoi
- -DSTRICT
- -D__try=
-D__forceinline=inline
- "-D__except(x)="
- "-DGetExceptionCode()=1"
- -fileextensions
)
endif(UNIX)
set(SPLINT_PARAMS ${SPLINT_PARAMS}
+show-scan
+boolint
-mts ${PROJECT_SOURCE_DIR}/splint)
- set(SPLINT_PARAMS ${SPLINT_PARAMS} ${RSGSRC})
+ set(SPLINT_PARAMS ${SPLINT_PARAMS}
+ ${RSGSRC}
+ )
add_custom_target(splint ${SPLINT_PATH} ${SPLINT_PARAMS}
VERBATIM)
endif(SPLINT_PATH)
View
@@ -73,5 +73,19 @@ void *xcb_randr_get_crtc_gamma_reply(
void *conn,void cookie,
/*@out@*/ void *error);
+// Win32 additional annotations
+void GetSystemTimeAsFileTime(/*@out@*/ void *lpSystemTimeAsFileTime);
+
+void *GetDC(/*@nulL@*/ void *hWnd);
+
+int GetDeviceCaps(void *hdc,int nIndex);
+
+short GetDeviceGammaRamp(void *hDC,/*@out@*/ void *lpRamp);
+
+short SetDeviceGammaRamp(void *hDC,void*lpRamp);
+
+int ReleaseDC(/*@null@*/ void *hWnd,void *hDC);
+
+
// vim:ft=c
View
@@ -20,23 +20,30 @@
#include "common.h"
#include "gamma.h"
+#ifdef S_SPLINT_S
+# define COLORMGMTCAPS 1
+# define CM_GAMMA_RAMP 1
+#endif
+
/**\brief Win32 GDI state info */
-typedef struct {
+typedef /*@partial@*/ struct {
/**\brief HDC context */
- HDC hDC;
+ /*@null@*//*@partial@*/ HDC hDC;
/**\brief Saved ramps */
- WORD *saved_ramps;
+ /*@null@*//*@partial@*/ WORD *saved_ramps;
} w32gdi_state_t;
#define GAMMA_RAMP_SIZE 256
static w32gdi_state_t state={NULL,NULL};
-int w32gdi_init(int screen_num,int crtc_num)
+static int w32gdi_init(/*@unused@*/int screen_num,/*@unused@*/ int crtc_num)
{
int cmcap;
/* Open device context */
+ if(state.hDC)
+ (void)ReleaseDC(NULL, state.hDC);
state.hDC = GetDC(NULL);
if (state.hDC == NULL) {
LOG(LOGERR,_("Unable to open device context."));
@@ -51,45 +58,59 @@ int w32gdi_init(int screen_num,int crtc_num)
}
/* Allocate space for saved gamma ramps */
+ if(state.saved_ramps)
+ free(state.saved_ramps);
state.saved_ramps = malloc(3*GAMMA_RAMP_SIZE*sizeof(WORD));
if (state.saved_ramps == NULL) {
perror("malloc");
- ReleaseDC(NULL, state.hDC);
+ (void)ReleaseDC(NULL, state.hDC);
return RET_FUN_FAILED;
}
/* Save current gamma ramps so we can restore them at program exit */
if( !GetDeviceGammaRamp(state.hDC, state.saved_ramps) ){
LOG(LOGERR,_("Unable to save current gamma ramp."));
- ReleaseDC(NULL, state.hDC);
+ (void)ReleaseDC(NULL, state.hDC);
return RET_FUN_FAILED;
}
return RET_FUN_SUCCESS;
}
-int w32gdi_free(void)
+static int w32gdi_free(void)
{
/* Free saved ramps */
free(state.saved_ramps);
/* Release device context */
- ReleaseDC(NULL, state.hDC);
+ if( state.hDC )
+ (void)ReleaseDC(NULL, state.hDC);
return RET_FUN_SUCCESS;
}
-void w32gdi_restore(void)
+static int w32gdi_restore(void)
{
/* Restore gamma ramps */
- if( !SetDeviceGammaRamp(state.hDC, state.saved_ramps) )
+ if( (!state.hDC)||(!state.saved_ramps) ){
+ LOG(LOGERR,_("No device context or ramp."));
+ return RET_FUN_FAILED;
+ }
+ if( !SetDeviceGammaRamp(state.hDC, state.saved_ramps) ){
LOG(LOGERR,_("Unable to restore gamma ramps."));
+ return RET_FUN_FAILED;
+ }
+ return RET_FUN_SUCCESS;
}
-int w32gdi_set_temperature(int temp, gamma_s gamma)
+static int w32gdi_set_temperature(int temp, /*@unused@*/ gamma_s gamma)
{
gamma_ramp_s ramp=gamma_ramp_fill(GAMMA_RAMP_SIZE,temp);
/* Set new gamma ramps */
+ if( (!state.hDC)||(!ramp.all) ){
+ LOG(LOGERR,_("No device context or ramp."));
+ return RET_FUN_FAILED;
+ }
if( !SetDeviceGammaRamp(state.hDC,ramp.all)) {
LOG(LOGERR,_("Unable to set gamma ramps."));
return RET_FUN_FAILED;
@@ -98,14 +119,23 @@ int w32gdi_set_temperature(int temp, gamma_s gamma)
return RET_FUN_SUCCESS;
}
-int w32gdi_get_temperature(void){
+static int w32gdi_get_temperature(void){
gamma_ramp_s ramp=gamma_get_ramps(GAMMA_RAMP_SIZE);
float rb_ratio;
+ if( (!state.hDC)||(!ramp.all) ){
+ LOG(LOGERR,_("No device context or ramp."));
+ return RET_FUN_FAILED;
+ }
+
if( !GetDeviceGammaRamp(state.hDC,ramp.all) ){
LOG(LOGERR,_("Unable to get gamma ramps."));
return RET_FUN_FAILED;
}
+ if( (!ramp.r)||(!ramp.b) ){
+ LOG(LOGERR,_("No ramps found."));
+ return RET_FUN_FAILED;
+ }
rb_ratio = (float)ramp.r[255]/(float)ramp.b[255];
return gamma_find_temp(rb_ratio);
}
@@ -115,6 +145,7 @@ int w32gdi_load_funcs(gamma_method_s *method){
method->func_end = &w32gdi_free;
method->func_set_temp = &w32gdi_set_temperature;
method->func_get_temp = &w32gdi_get_temperature;
+ method->func_restore = &w32gdi_restore;
method->name = "WinGDI";
return RET_FUN_SUCCESS;
}
View
@@ -10,21 +10,6 @@
#include <wingdi.h>
-/**\brief Initialize windows GDI */
-int w32gdi_init(int screen_num,int crtc_num);
-
-/**\brief Frees the GDI context */
-int w32gdi_free(void);
-
-/**\brief Restores saved gamma ramps */
-void w32gdi_restore(void);
-
-/**\brief Sets the temperature */
-int w32gdi_set_temperature(int temp, gamma_s gamma);
-
-/**\brief Retrieves current temperature */
-int w32gdi_get_temperature(void);
-
/**\brief Load WinGDI functions into methods structure */
int w32gdi_load_funcs(gamma_method_s *method);
View
@@ -51,7 +51,7 @@
#define LOG(LVL,...) log_log(LVL,__FILE__,__FUNCTION__ ,__LINE__,__VA_ARGS__)
#else
/**\brief Logging macro, outputs function name */
-#define LOG(LVL,...) log_log(LVL,NULL,__FUNCTION__,0,__VA_ARGS__)
+#define LOG(LVL,...) (void)log_log(LVL,NULL,__FUNCTION__,0,__VA_ARGS__)
#endif
/*@end@*/
/**\brief Log level error */
@@ -81,6 +81,9 @@
#define RSG_RCFILE "redshiftg.ini"
#endif
+// Stringify
+#define STR(X) #X
+
// Math macros
#ifndef MIN
/**\brief Minimum of two values */
@@ -93,7 +96,7 @@
// MSVC round
#ifdef _MSC_VER
-#define round(X) floor(X + 0.5)
+#define round(X) floor((X) + 0.5)
#endif
#ifndef _WIN32
View
@@ -158,6 +158,7 @@ int gamma_load_methods(void){
methods[i].func_end = NULL;
methods[i].func_set_temp = NULL;
methods[i].func_get_temp = NULL;
+ methods[i].func_restore = NULL;
methods[i].name = NULL;
}
methods[GAMMA_METHOD_AUTO].name = "Auto";
View
@@ -75,6 +75,8 @@ typedef struct{
/*@null@*/ int (*func_set_temp)(int temp, gamma_s gamma);
/**\brief Function to get the temperature */
/*@null@*/ int (*func_get_temp)(void);
+ /**\brief Function to restore the saved ramps */
+ /*@null@*/ int (*func_restore)(void);
/**\brief Method name. */
/*@observer@*/ char *name;
} gamma_method_s;
View
@@ -68,13 +68,13 @@ static void _unload_icons(void){
// Home page callback
static int _btn_home(/*@unused@*/ Ihandle *ih){
- (void)IupHelp(PACKAGE_HOME);
+ (void)IupHelp(STR(PACKAGE_HOME));
return IUP_DEFAULT;
}
// Bug report callback
static int _btn_bug(/*@unused@*/ Ihandle *ih){
- (void)IupHelp(PACKAGE_BUGREPORT);
+ (void)IupHelp(STR(PACKAGE_BUGREPORT));
return IUP_DEFAULT;
}
@@ -97,7 +97,7 @@ int gui_about(/*@unused@*/ Ihandle *ih){
lbl_icon = IupLabel(NULL);
IupSetAttributeHandle(lbl_icon,"IMAGE",himg_redshift);
hbox_title = IupHbox(lbl_icon,IupLabel(_("RedshiftGUI ")),
- IupLabel(PACKAGE_VER),NULL);
+ IupLabel(STR(PACKAGE_VER)),NULL);
txt_area = IupSetAtt(NULL,IupText(NULL),
"EXPAND","YES","MULTILINE","YES",
Oops, something went wrong.

0 comments on commit b86fd98

Please sign in to comment.