You've already forked openvpn-gui
mirror of
https://github.com/OpenVPN/openvpn-gui.git
synced 2025-11-26 14:08:00 +08:00
TRY_GETPROP: make it more pretty for VOID callers
Because TRY_GETPROP(hwnd, cfgProp, c, ); looks a bit scary. Signed-off-by: Lev Stipakov <lev@openvpn.net>
This commit is contained in:
committed by
Gert Doering
parent
211cc8c5c2
commit
ecb548efea
11
openvpn.h
11
openvpn.h
@@ -35,8 +35,8 @@
|
||||
return false; \
|
||||
} while (0)
|
||||
|
||||
/* A macro to set lval = GetProp(hwnd, name) or log an error and return err_return */
|
||||
#define TRY_GETPROP(hwnd, name, lval, err_return) \
|
||||
/* A macro to set lval = GetProp(hwnd, name) or log and execute on_fail statement on error */
|
||||
#define TRY_GETPROP_IMPL(hwnd, name, lval, on_fail) \
|
||||
do \
|
||||
{ \
|
||||
HANDLE handle_##lval = GetProp(hwnd, name); \
|
||||
@@ -44,11 +44,16 @@
|
||||
{ \
|
||||
MsgToEventLog( \
|
||||
EVENTLOG_ERROR_TYPE, L"%hs:%d GetProp returned null", __func__, __LINE__); \
|
||||
return err_return; \
|
||||
on_fail; \
|
||||
} \
|
||||
lval = (__typeof__(lval))handle_##lval; \
|
||||
} while (0)
|
||||
|
||||
#define TRY_GETPROP(hwnd, name, lval, err_return) \
|
||||
TRY_GETPROP_IMPL(hwnd, name, lval, return err_return)
|
||||
|
||||
#define TRY_GETPROP_VOID(hwnd, name, lval) TRY_GETPROP_IMPL(hwnd, name, lval, return)
|
||||
|
||||
BOOL StartOpenVPN(connection_t *);
|
||||
|
||||
void StopOpenVPN(connection_t *);
|
||||
|
||||
4
pkcs11.c
4
pkcs11.c
@@ -477,7 +477,7 @@ static void CALLBACK
|
||||
pkcs11_listview_fill(HWND hwnd, UINT UNUSED msg, UINT_PTR id, DWORD UNUSED now)
|
||||
{
|
||||
connection_t *c;
|
||||
TRY_GETPROP(hwnd, cfgProp, c, );
|
||||
TRY_GETPROP_VOID(hwnd, cfgProp, c);
|
||||
|
||||
struct pkcs11_list *l = &c->pkcs11_list;
|
||||
|
||||
@@ -542,7 +542,7 @@ static void
|
||||
pkcs11_listview_reset(HWND parent)
|
||||
{
|
||||
connection_t *c;
|
||||
TRY_GETPROP(parent, cfgProp, c, );
|
||||
TRY_GETPROP_VOID(parent, cfgProp, c);
|
||||
struct pkcs11_list *l = &c->pkcs11_list;
|
||||
HWND lv = GetDlgItem(parent, ID_LVW_PKCS11);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user