[pisa-src] r1401 - in trunk: community-operator/co_client.c community-operator/pisa_cert.c include/global.h libpisa/debug.c pairing/accept.c pisacd/cdconf.c pisacd/cdderegister.c pisacd/cdheartbeat.c pisacd/c...

  • From: Thomas Jansen <mithi@xxxxxxxxx>
  • To: pisa-src@xxxxxxxxxxxxx
  • Date: Thu, 29 Oct 2009 14:11:39 +0100

Author: tjansen
Date: Thu Oct 29 14:11:38 2009
New Revision: 1401

Log:
Introduced and applied the UNUSED macro.

The UNUSED macro is useful for marking function arguments that are ignored.
This silences warnings for the argument. However it is not supposed to be
a generic remedy for bad API decisions. It's only supposed to be used in
cases where certain arguments are expected (e.g. a callback function
typedef), but are not used in the actual implementation of that specific
function.

Modified:
   trunk/community-operator/co_client.c
   trunk/community-operator/pisa_cert.c
   trunk/include/global.h
   trunk/libpisa/debug.c
   trunk/pairing/accept.c
   trunk/pisacd/cdconf.c
   trunk/pisacd/cdderegister.c
   trunk/pisacd/cdheartbeat.c
   trunk/pisacd/cdmain.c
   trunk/pisasd/pisasdconf.c
   trunk/pisasd/sdconf.c
   trunk/pisasd/sdderegister.c
   trunk/pisasd/sdheartbeat.c
   trunk/pisasd/sdmain.c
   trunk/pisasd/sdtun.c

Modified: trunk/community-operator/co_client.c
==============================================================================
--- trunk/community-operator/co_client.c        Thu Oct 29 13:05:06 2009        
(r1400)
+++ trunk/community-operator/co_client.c        Thu Oct 29 14:11:38 2009        
(r1401)
@@ -214,7 +214,7 @@
  * Terminate community-operator client by receiving signal
  * @param signal signal quit code
  */
-static void co_client_quit(int signal)
+static void co_client_quit(UNUSED int signal)
 {
        PISA_INFO("Shutting down Community-Operator client...\n");
        pisa_cfg_cleanup();
@@ -492,7 +492,7 @@
  * co_client_config.certs_dir expired.
  * @param signal signal code
  */
-static void co_client_check_certs(int signal)
+static void co_client_check_certs(UNUSED int signal)
 {
        if (co_client_config.save_certs) {
                PISA_INFO("Checking existing certificates...\n");

Modified: trunk/community-operator/pisa_cert.c
==============================================================================
--- trunk/community-operator/pisa_cert.c        Thu Oct 29 13:05:06 2009        
(r1400)
+++ trunk/community-operator/pisa_cert.c        Thu Oct 29 14:11:38 2009        
(r1401)
@@ -17,6 +17,8 @@
 #include <string.h>
 #include <stdio.h>
 
+#include "global.h"
+
 /**
  * Extract parts of a SPKI certificate.
  *
@@ -25,8 +27,8 @@
  * @param r pointer to a buffer that the search result will be copied to
  * @param size size of the buffer result
  * @return 0 on success
- */
-static char* pisa_cert_get_part(char *cert, char *name, char *r, size_t size)
+ */  /* TODO: Why is size unused? */
+static char* pisa_cert_get_part(char *cert, char *name, char *r, UNUSED size_t 
size)
 {
        int level = 0, len = 0;
        char *p = cert, *start = NULL;
@@ -99,8 +101,8 @@
  * @param r pointer to a buffer that the search result will be copied to
  * @param size size of the buffer result
  * @return 0 on success
- */
-static void pisa_cert_get_content(char *cert, char *name, char *r, size_t size)
+ */ /* TODO: Why is size unused? */
+static void pisa_cert_get_content(char *cert, char *name, char *r, UNUSED 
size_t size)
 {
        char *start = cert;
        int len = 0;

Modified: trunk/include/global.h
==============================================================================
--- trunk/include/global.h      Thu Oct 29 13:05:06 2009        (r1400)
+++ trunk/include/global.h      Thu Oct 29 14:11:38 2009        (r1401)
@@ -338,4 +338,19 @@
        return begin == HIT_PREFIX;
 }
 
+/**
+ * UNUSED macro is useful for marking function arguments that are ignored.
+ * This silences warnings for the argument. However it is not supposed to be
+ * a generic remedy for bad API decisions. It's only supposed to be used in
+ * cases where certain arguments are expected (e.g. a callback function
+ * typedef), but are not used in the actual implementation of that specific
+ * function.
+ */
+#ifdef UNUSED
+#elif defined(__GNUC__)
+#define UNUSED __attribute__((__unused__))
+#else
+#define UNUSED
+#endif
+
 #endif /* PISA_GLOBAL_H */

Modified: trunk/libpisa/debug.c
==============================================================================
--- trunk/libpisa/debug.c       Thu Oct 29 13:05:06 2009        (r1400)
+++ trunk/libpisa/debug.c       Thu Oct 29 14:11:38 2009        (r1401)
@@ -480,7 +480,7 @@
  * PISA_DEBUG_SOCKADDR macro instead. Currently this function supports
  * only INET and INET6 addresses. 
  */
-void pisa_print_sockaddr(const char *file, int line, const char *function,
+void pisa_print_sockaddr(UNUSED const char *file, UNUSED int line, UNUSED 
const char *function,
                        const char *prefix,
                        const struct sockaddr *sockaddr) {
       char *default_str = "<unknown>";

Modified: trunk/pairing/accept.c
==============================================================================
--- trunk/pairing/accept.c      Thu Oct 29 13:05:06 2009        (r1400)
+++ trunk/pairing/accept.c      Thu Oct 29 14:11:38 2009        (r1401)
@@ -134,7 +134,7 @@
     return 1;
 }
 
-void check_expiration_dates(int signr)
+void check_expiration_dates(UNUSED int signr)
 {
 
     pisa_hitlist *hitlist_allowed_hosts;

Modified: trunk/pisacd/cdconf.c
==============================================================================
--- trunk/pisacd/cdconf.c       Thu Oct 29 13:05:06 2009        (r1400)
+++ trunk/pisacd/cdconf.c       Thu Oct 29 14:11:38 2009        (r1401)
@@ -91,10 +91,8 @@
 
 /**
  * Read the debug type mask from the configuration file.
- *
- * @param cdconf  cd_conf structure where conf settings are stored
  */
-static void cdconf_read_debugtypemask(cd_conf *cdconf)
+static void cdconf_read_debugtypemask()
 {
        int mask = 0x7fffffff;
 
@@ -229,7 +227,7 @@
 {
        /* Read several configuration from pisacd.conf. */
        cdconf_read_debuglevel(cdconf);
-       cdconf_read_debugtypemask(cdconf);
+       cdconf_read_debugtypemask();
        cdconf_read_port_control(cdconf);
        cdconf_read_port_data(cdconf);
        cdconf_read_idle_disconnect_delay(cdconf);

Modified: trunk/pisacd/cdderegister.c
==============================================================================
--- trunk/pisacd/cdderegister.c Thu Oct 29 13:05:06 2009        (r1400)
+++ trunk/pisacd/cdderegister.c Thu Oct 29 14:11:38 2009        (r1401)
@@ -100,7 +100,7 @@
  *     for pisa_conmgr_iterate_connected.
  * @param entry conmgr entry for the server
  */
-void pisa_client_disconnect_from_server(void *data, pisa_conmgr_entry *entry)
+void pisa_client_disconnect_from_server(UNUSED void *data, pisa_conmgr_entry 
*entry)
 {
        pisa_pending *pend;
 
@@ -128,7 +128,7 @@
  * @param pkt original packet
  * @param addr HIT/port of the server
  */
-void pisa_recv_deregister_ack(pisa_packet *pkt, struct sockaddr_in6 *addr)
+void pisa_recv_deregister_ack(UNUSED pisa_packet *pkt, struct sockaddr_in6 
*addr)
 {
        char buffer[INET6_ADDRSTRLEN];
        pisa_conmgr_entry *entry = pisa_conmgr_findby_address(cd_ctx.conlist, 
&addr->sin6_addr);

Modified: trunk/pisacd/cdheartbeat.c
==============================================================================
--- trunk/pisacd/cdheartbeat.c  Thu Oct 29 13:05:06 2009        (r1400)
+++ trunk/pisacd/cdheartbeat.c  Thu Oct 29 14:11:38 2009        (r1401)
@@ -23,7 +23,7 @@
  * @param pkt original packet
  * @param addr HIT/port of the server
  */
-void pisa_recv_heartbeat_ack(pisa_packet *pkt, struct sockaddr_in6 *addr)
+void pisa_recv_heartbeat_ack(UNUSED pisa_packet *pkt, struct sockaddr_in6 
*addr)
 {
        char buffer[INET6_ADDRSTRLEN];
        pisa_conmgr_entry *entry = pisa_conmgr_findby_address(cd_ctx.conlist, 
&addr->sin6_addr);

Modified: trunk/pisacd/cdmain.c
==============================================================================
--- trunk/pisacd/cdmain.c       Thu Oct 29 13:05:06 2009        (r1400)
+++ trunk/pisacd/cdmain.c       Thu Oct 29 14:11:38 2009        (r1401)
@@ -304,10 +304,8 @@
 
 /**
  * Reload configurations
- *
- * @param quitcode   signal quit code
  */
-static void cd_reload_confs(int quitcode)
+static void cd_reload_confs(UNUSED int quitcode)
 {
        PISA_DEBUG(PL_GENERIC, "Received a HUP signal, reloading basic 
configurations...\n");
 

Modified: trunk/pisasd/pisasdconf.c
==============================================================================
--- trunk/pisasd/pisasdconf.c   Thu Oct 29 13:05:06 2009        (r1400)
+++ trunk/pisasd/pisasdconf.c   Thu Oct 29 14:11:38 2009        (r1401)
@@ -18,6 +18,7 @@
 #include <string.h>
 
 #include "debug.h"
+#include "global.h"
 #include "pisaconf.h"
 
 /**
@@ -26,7 +27,7 @@
  * @param argv array of arguments
  * @return 0 on success, 1 on general error, 2 on specific error.
  */
-static int pisa_sdconf_parse_reload(int argc, char *argv[])
+static int pisa_sdconf_parse_reload(int argc, UNUSED char *argv[])
 {
        pisa_conf_packet *packet;
 

Modified: trunk/pisasd/sdconf.c
==============================================================================
--- trunk/pisasd/sdconf.c       Thu Oct 29 13:05:06 2009        (r1400)
+++ trunk/pisasd/sdconf.c       Thu Oct 29 14:11:38 2009        (r1401)
@@ -111,7 +111,7 @@
  *
  * @param cdconf  cd_conf structure where conf settings are stored
  */
-static void sdconf_read_debugtypemask(sd_conf *sdconf)
+static void sdconf_read_debugtypemask(void)
 {
        int mask = 0x7fffffff;
 
@@ -315,7 +315,7 @@
 {
        /* Read several configuration from pisasd.conf. */
        sdconf_read_debuglevel(sdconf);
-       sdconf_read_debugtypemask(sdconf);
+       sdconf_read_debugtypemask();
        sdconf_read_ifname_eth(sdconf);
        sdconf_read_portnumber_control(sdconf);
        sdconf_read_portnumber_data(sdconf);

Modified: trunk/pisasd/sdderegister.c
==============================================================================
--- trunk/pisasd/sdderegister.c Thu Oct 29 13:05:06 2009        (r1400)
+++ trunk/pisasd/sdderegister.c Thu Oct 29 14:11:38 2009        (r1401)
@@ -21,7 +21,7 @@
  * @param pkt PISA control packet
  * @param addr HIT/port of the sender
  */
-void pisa_recv_deregister(pisa_packet *pkt, struct sockaddr_in6 *addr)
+void pisa_recv_deregister(UNUSED pisa_packet *pkt, struct sockaddr_in6 *addr)
 {
        char buffer[INET6_ADDRSTRLEN];
        pisa_conmgr_entry *e = pisa_conmgr_findby_address(sd_ctx.conlist, 
&addr->sin6_addr);

Modified: trunk/pisasd/sdheartbeat.c
==============================================================================
--- trunk/pisasd/sdheartbeat.c  Thu Oct 29 13:05:06 2009        (r1400)
+++ trunk/pisasd/sdheartbeat.c  Thu Oct 29 14:11:38 2009        (r1401)
@@ -49,7 +49,7 @@
  * @param pkt PISA control packet
  * @param addr HIT/port of the sender
  */
-void pisa_recv_heartbeat(pisa_packet *pkt, struct sockaddr_in6 *addr)
+void pisa_recv_heartbeat(UNUSED pisa_packet *pkt, struct sockaddr_in6 *addr)
 {
        char buffer[INET6_ADDRSTRLEN];
        pisa_conmgr_entry *e = pisa_conmgr_findby_address(sd_ctx.conlist, 
&addr->sin6_addr);

Modified: trunk/pisasd/sdmain.c
==============================================================================
--- trunk/pisasd/sdmain.c       Thu Oct 29 13:05:06 2009        (r1400)
+++ trunk/pisasd/sdmain.c       Thu Oct 29 14:11:38 2009        (r1401)
@@ -309,10 +309,8 @@
 
 /**
  * Reload configurations
- *
- * @param quitcode   signal quit code
  */
-static void sd_reload_confs(pisa_conf_packet *p)
+static void sd_reload_confs(UNUSED pisa_conf_packet *p)
 {
        PISA_DEBUG(PL_CONFIG, "Reloading basic configurations...\n");
 

Modified: trunk/pisasd/sdtun.c
==============================================================================
--- trunk/pisasd/sdtun.c        Thu Oct 29 13:05:06 2009        (r1400)
+++ trunk/pisasd/sdtun.c        Thu Oct 29 14:11:38 2009        (r1401)
@@ -31,7 +31,7 @@
  * @param pkt PISA control packet
  * @param addr HIT/port of the sender
  */
-void pisa_recv_data(pisa_packet *pkt, struct sockaddr_in6 *addr)
+void pisa_recv_data(UNUSED pisa_packet *pkt, UNUSED struct sockaddr_in6 *addr)
 {
        PISA_DEBUG(PL_STATEMACHINE, "Received obsolete PISA_PKTTYPE_TUN_DATA 
packet.\n");
 }

Other related posts:

  • » [pisa-src] r1401 - in trunk: community-operator/co_client.c community-operator/pisa_cert.c include/global.h libpisa/debug.c pairing/accept.c pisacd/cdconf.c pisacd/cdderegister.c pisacd/cdheartbeat.c pisacd/c... - Thomas Jansen