gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r25954 - in gnunet/src: exit vpn


From: gnunet
Subject: [GNUnet-SVN] r25954 - in gnunet/src: exit vpn
Date: Thu, 31 Jan 2013 10:11:41 +0100

Author: cfuchs
Date: 2013-01-31 10:11:41 +0100 (Thu, 31 Jan 2013)
New Revision: 25954

Modified:
   gnunet/src/exit/gnunet-helper-exit-windows.c
   gnunet/src/vpn/gnunet-helper-vpn-windows.c
Log:
some final code-beautification (coding style 4tw!)

removed a few obsolete variables



Modified: gnunet/src/exit/gnunet-helper-exit-windows.c
===================================================================
--- gnunet/src/exit/gnunet-helper-exit-windows.c        2013-01-31 08:52:46 UTC 
(rev 25953)
+++ gnunet/src/exit/gnunet-helper-exit-windows.c        2013-01-31 09:11:41 UTC 
(rev 25954)
@@ -444,7 +444,7 @@
   /** 
    * Bootstrap our device info using the drivers inf-file
    */
-  if (!SetupDiGetINFClassA (inf_file_path,
+  if ( ! SetupDiGetINFClassA (inf_file_path,
                             &class_guid,
                             class_name, sizeof (class_name) / sizeof (char),
                             NULL))
@@ -459,7 +459,7 @@
     return FALSE;
 
   DeviceNode.cbSize = sizeof (SP_DEVINFO_DATA);
-  if (!SetupDiCreateDeviceInfoA (DeviceInfo,
+  if ( ! SetupDiCreateDeviceInfoA (DeviceInfo,
                                  class_name,
                                  &class_guid,
                                  NULL,
@@ -469,7 +469,7 @@
     return FALSE;
 
   /* Deploy all the information collected into the registry */
-  if (!SetupDiSetDeviceRegistryPropertyA (DeviceInfo,
+  if ( ! SetupDiSetDeviceRegistryPropertyA (DeviceInfo,
                                           &DeviceNode,
                                           SPDRP_HARDWAREID,
                                           (LPBYTE) hwidlist,
@@ -477,14 +477,14 @@
     return FALSE;
 
   /* Install our new class(=device) into the system */
-  if (!SetupDiCallClassInstaller (DIF_REGISTERDEVICE,
+  if ( ! SetupDiCallClassInstaller (DIF_REGISTERDEVICE,
                                   DeviceInfo,
                                   &DeviceNode))
     return FALSE;
 
   /* This system call tends to take a while (several seconds!) on
      "modern" Windoze systems */
-  if (!UpdateDriverForPlugAndPlayDevicesA (NULL,
+  if ( ! UpdateDriverForPlugAndPlayDevicesA (NULL,
                                            secondary_hwid,
                                            inf_file_path,
                                            INSTALLFLAG_FORCE | 
INSTALLFLAG_NONINTERACTIVE,
@@ -518,7 +518,7 @@
    * 1. Prepare our existing device information set, and place the 
    *    uninstall related information into the structure
    */
-  if (!SetupDiSetClassInstallParamsA (DeviceInfo,
+  if ( ! SetupDiSetClassInstallParamsA (DeviceInfo,
                                       (PSP_DEVINFO_DATA) & DeviceNode,
                                       &remove.ClassInstallHeader,
                                       sizeof (remove)))
@@ -526,7 +526,7 @@
   /*
    * 2. Uninstall the virtual interface using the class installer
    */
-  if (!SetupDiCallClassInstaller (DIF_REMOVE,
+  if ( ! SetupDiCallClassInstaller (DIF_REMOVE,
                                   DeviceInfo,
                                   (PSP_DEVINFO_DATA) & DeviceNode))
     return FALSE;
@@ -623,14 +623,12 @@
                     instance_key);
 
           /* look inside instance_key\\Connection */
-          status = RegOpenKeyExA (
+          if (ERROR_SUCCESS != RegOpenKeyExA (
                                   HKEY_LOCAL_MACHINE,
                                   query_key,
                                   0,
                                   KEY_READ,
-                                  &instance_key_handle);
-
-          if (status != ERROR_SUCCESS)
+                                  &instance_key_handle))
             goto cleanup;
 
           /* now, read our PnpInstanceID */
@@ -696,7 +694,6 @@
   DWORD len;
   memset (&(version), 0, sizeof (version));
 
-
   if (DeviceIoControl (handle, TAP_WIN_IOCTL_GET_VERSION,
                        &version, sizeof (version),
                        &version, sizeof (version), &len, NULL))
@@ -705,7 +702,8 @@
                (int) version[1],
                (version[2] ? "(DEBUG)" : ""));
 
-  if (version[0] != TAP_WIN_MIN_MAJOR || version[1] < TAP_WIN_MIN_MINOR){
+  if ((version[0] != TAP_WIN_MIN_MAJOR) ||
+      (version[1] < TAP_WIN_MIN_MINOR )){
       fprintf (stderr, "FATAL:  This version of gnunet requires a TAP-Windows 
driver that is at least version %d.%d\n",
                TAP_WIN_MIN_MAJOR,
                TAP_WIN_MIN_MINOR);
@@ -755,7 +753,7 @@
                        0
                        );
 
-  if (handle == INVALID_HANDLE_VALUE)
+  if (INVALID_HANDLE_VALUE == handle)
     {
       fprintf (stderr, "FATAL: CreateFile failed on TAP device: %s\n", 
device_path);
       return handle;
@@ -799,7 +797,6 @@
   fprintf (stderr, "DEBUG: successfully set TAP device to UP\n");
 
   return TRUE;
-
 }
 
 
@@ -834,7 +831,6 @@
 {
   struct GNUNET_MessageHeader * hdr;
   unsigned short size;
-  BOOL status;
   
   switch (input_facility->facility_state)
     {
@@ -844,16 +840,15 @@
           {
             return FALSE;
           }
-        
+
         input_facility->buffer_size = 0;
-        status = ReadFile (input_facility->handle,
-                           input_facility->buffer,
-                           sizeof (input_facility->buffer) - sizeof (struct 
GNUNET_MessageHeader),
-                           &input_facility->buffer_size,
-                           &input_facility->overlapped);
 
         /* Check how the task is handled */
-        if (status)
+        if (ReadFile (input_facility->handle,
+                      input_facility->buffer,
+                      sizeof (input_facility->buffer) - sizeof (struct 
GNUNET_MessageHeader),
+                      &input_facility->buffer_size,
+                      &input_facility->overlapped))
           {/* async event processed immediately*/
 
             /* reset event manually*/
@@ -866,7 +861,7 @@
              * send it our via STDOUT. Is that possible at the moment? */
             if ((IOSTATE_READY == output_facility->facility_state ||
                  IOSTATE_WAITING == output_facility->facility_state)
-                && 0 < input_facility->buffer_size)
+                && (0 < input_facility->buffer_size))
               { /* hand over this buffers content and apply message header for 
gnunet */
                 hdr = (struct GNUNET_MessageHeader *) output_facility->buffer;
                 size = input_facility->buffer_size + sizeof (struct 
GNUNET_MessageHeader);
@@ -909,11 +904,11 @@
     case IOSTATE_QUEUED:
       {
         // there was an operation going on already, check if that has 
completed now.
-        status = GetOverlappedResult (input_facility->handle,
-                                      &input_facility->overlapped,
-                                      &input_facility->buffer_size,
-                                      FALSE);
-        if (status)
+
+        if (GetOverlappedResult (input_facility->handle,
+                                 &input_facility->overlapped,
+                                 &input_facility->buffer_size,
+                                 FALSE))
           {/* successful return for a queued operation */
             if (! ResetEvent (input_facility->overlapped.hEvent))
               return FALSE;
@@ -978,6 +973,7 @@
     }
 }
 
+
 /**
  * Attempts to read off an input facility (tap or named pipe) in overlapped 
mode.
  * 
@@ -1095,11 +1091,10 @@
     case IOSTATE_QUEUED:
       {
         // there was an operation going on already, check if that has 
completed now.
-        status = GetOverlappedResult (input_facility->handle,
-                                      &input_facility->overlapped,
-                                      &input_facility->buffer_size,
-                                      FALSE);
-        if (status)
+        if (GetOverlappedResult (input_facility->handle,
+                                 &input_facility->overlapped,
+                                 &input_facility->buffer_size,
+                                 FALSE))
           {/* successful return for a queued operation */
             hdr = (struct GNUNET_MessageHeader *) input_facility->buffer;
             
@@ -1166,6 +1161,7 @@
     }
 }
 
+
 /**
  * Attempts to write to an output facility (tap or named pipe) in overlapped 
mode.
  *

Modified: gnunet/src/vpn/gnunet-helper-vpn-windows.c
===================================================================
--- gnunet/src/vpn/gnunet-helper-vpn-windows.c  2013-01-31 08:52:46 UTC (rev 
25953)
+++ gnunet/src/vpn/gnunet-helper-vpn-windows.c  2013-01-31 09:11:41 UTC (rev 
25954)
@@ -444,7 +444,7 @@
   /** 
    * Bootstrap our device info using the drivers inf-file
    */
-  if (!SetupDiGetINFClassA (inf_file_path,
+  if ( ! SetupDiGetINFClassA (inf_file_path,
                             &class_guid,
                             class_name, sizeof (class_name) / sizeof (char),
                             NULL))
@@ -459,7 +459,7 @@
     return FALSE;
 
   DeviceNode.cbSize = sizeof (SP_DEVINFO_DATA);
-  if (!SetupDiCreateDeviceInfoA (DeviceInfo,
+  if ( ! SetupDiCreateDeviceInfoA (DeviceInfo,
                                  class_name,
                                  &class_guid,
                                  NULL,
@@ -469,7 +469,7 @@
     return FALSE;
 
   /* Deploy all the information collected into the registry */
-  if (!SetupDiSetDeviceRegistryPropertyA (DeviceInfo,
+  if ( ! SetupDiSetDeviceRegistryPropertyA (DeviceInfo,
                                           &DeviceNode,
                                           SPDRP_HARDWAREID,
                                           (LPBYTE) hwidlist,
@@ -477,14 +477,14 @@
     return FALSE;
 
   /* Install our new class(=device) into the system */
-  if (!SetupDiCallClassInstaller (DIF_REGISTERDEVICE,
+  if ( ! SetupDiCallClassInstaller (DIF_REGISTERDEVICE,
                                   DeviceInfo,
                                   &DeviceNode))
     return FALSE;
 
   /* This system call tends to take a while (several seconds!) on
      "modern" Windoze systems */
-  if (!UpdateDriverForPlugAndPlayDevicesA (NULL,
+  if ( ! UpdateDriverForPlugAndPlayDevicesA (NULL,
                                            secondary_hwid,
                                            inf_file_path,
                                            INSTALLFLAG_FORCE | 
INSTALLFLAG_NONINTERACTIVE,
@@ -518,7 +518,7 @@
    * 1. Prepare our existing device information set, and place the 
    *    uninstall related information into the structure
    */
-  if (!SetupDiSetClassInstallParamsA (DeviceInfo,
+  if ( ! SetupDiSetClassInstallParamsA (DeviceInfo,
                                       (PSP_DEVINFO_DATA) & DeviceNode,
                                       &remove.ClassInstallHeader,
                                       sizeof (remove)))
@@ -526,7 +526,7 @@
   /*
    * 2. Uninstall the virtual interface using the class installer
    */
-  if (!SetupDiCallClassInstaller (DIF_REMOVE,
+  if ( ! SetupDiCallClassInstaller (DIF_REMOVE,
                                   DeviceInfo,
                                   (PSP_DEVINFO_DATA) & DeviceNode))
     return FALSE;
@@ -623,14 +623,12 @@
                     instance_key);
 
           /* look inside instance_key\\Connection */
-          status = RegOpenKeyExA (
+          if (ERROR_SUCCESS != RegOpenKeyExA (
                                   HKEY_LOCAL_MACHINE,
                                   query_key,
                                   0,
                                   KEY_READ,
-                                  &instance_key_handle);
-
-          if (status != ERROR_SUCCESS)
+                                  &instance_key_handle))
             goto cleanup;
 
           /* now, read our PnpInstanceID */
@@ -696,7 +694,6 @@
   DWORD len;
   memset (&(version), 0, sizeof (version));
 
-
   if (DeviceIoControl (handle, TAP_WIN_IOCTL_GET_VERSION,
                        &version, sizeof (version),
                        &version, sizeof (version), &len, NULL))
@@ -705,7 +702,8 @@
                (int) version[1],
                (version[2] ? "(DEBUG)" : ""));
 
-  if (version[0] != TAP_WIN_MIN_MAJOR || version[1] < TAP_WIN_MIN_MINOR){
+  if ((version[0] != TAP_WIN_MIN_MAJOR) ||
+      (version[1] < TAP_WIN_MIN_MINOR )){
       fprintf (stderr, "FATAL:  This version of gnunet requires a TAP-Windows 
driver that is at least version %d.%d\n",
                TAP_WIN_MIN_MAJOR,
                TAP_WIN_MIN_MINOR);
@@ -755,7 +753,7 @@
                        0
                        );
 
-  if (handle == INVALID_HANDLE_VALUE)
+  if (INVALID_HANDLE_VALUE == handle)
     {
       fprintf (stderr, "FATAL: CreateFile failed on TAP device: %s\n", 
device_path);
       return handle;
@@ -799,7 +797,6 @@
   fprintf (stderr, "DEBUG: successfully set TAP device to UP\n");
 
   return TRUE;
-
 }
 
 
@@ -834,7 +831,6 @@
 {
   struct GNUNET_MessageHeader * hdr;
   unsigned short size;
-  BOOL status;
   
   switch (input_facility->facility_state)
     {
@@ -844,16 +840,15 @@
           {
             return FALSE;
           }
-        
+
         input_facility->buffer_size = 0;
-        status = ReadFile (input_facility->handle,
-                           input_facility->buffer,
-                           sizeof (input_facility->buffer) - sizeof (struct 
GNUNET_MessageHeader),
-                           &input_facility->buffer_size,
-                           &input_facility->overlapped);
 
         /* Check how the task is handled */
-        if (status)
+        if (ReadFile (input_facility->handle,
+                      input_facility->buffer,
+                      sizeof (input_facility->buffer) - sizeof (struct 
GNUNET_MessageHeader),
+                      &input_facility->buffer_size,
+                      &input_facility->overlapped))
           {/* async event processed immediately*/
 
             /* reset event manually*/
@@ -866,7 +861,7 @@
              * send it our via STDOUT. Is that possible at the moment? */
             if ((IOSTATE_READY == output_facility->facility_state ||
                  IOSTATE_WAITING == output_facility->facility_state)
-                && 0 < input_facility->buffer_size)
+                && (0 < input_facility->buffer_size))
               { /* hand over this buffers content and apply message header for 
gnunet */
                 hdr = (struct GNUNET_MessageHeader *) output_facility->buffer;
                 size = input_facility->buffer_size + sizeof (struct 
GNUNET_MessageHeader);
@@ -909,11 +904,11 @@
     case IOSTATE_QUEUED:
       {
         // there was an operation going on already, check if that has 
completed now.
-        status = GetOverlappedResult (input_facility->handle,
-                                      &input_facility->overlapped,
-                                      &input_facility->buffer_size,
-                                      FALSE);
-        if (status)
+
+        if (GetOverlappedResult (input_facility->handle,
+                                 &input_facility->overlapped,
+                                 &input_facility->buffer_size,
+                                 FALSE))
           {/* successful return for a queued operation */
             if (! ResetEvent (input_facility->overlapped.hEvent))
               return FALSE;
@@ -978,6 +973,7 @@
     }
 }
 
+
 /**
  * Attempts to read off an input facility (tap or named pipe) in overlapped 
mode.
  * 
@@ -1095,11 +1091,10 @@
     case IOSTATE_QUEUED:
       {
         // there was an operation going on already, check if that has 
completed now.
-        status = GetOverlappedResult (input_facility->handle,
-                                      &input_facility->overlapped,
-                                      &input_facility->buffer_size,
-                                      FALSE);
-        if (status)
+        if (GetOverlappedResult (input_facility->handle,
+                                 &input_facility->overlapped,
+                                 &input_facility->buffer_size,
+                                 FALSE))
           {/* successful return for a queued operation */
             hdr = (struct GNUNET_MessageHeader *) input_facility->buffer;
             
@@ -1166,6 +1161,7 @@
     }
 }
 
+
 /**
  * Attempts to write to an output facility (tap or named pipe) in overlapped 
mode.
  *




reply via email to

[Prev in Thread] Current Thread [Next in Thread]