aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-06-19 21:25:50 +0200
committerChristian Grothoff <christian@grothoff.org>2019-06-19 21:30:25 +0200
commit2111b3716776f2a1e6e6b38888c8dea42907c09d (patch)
tree325c76317c007e2af7533488a31e410518f0ab18 /src/core
parent9baf882d7642f8aeac734ffd16c8e94bd409a41b (diff)
downloadgnunet-2111b3716776f2a1e6e6b38888c8dea42907c09d.tar.gz
gnunet-2111b3716776f2a1e6e6b38888c8dea42907c09d.zip
fix compiler warnings about unused args
Diffstat (limited to 'src/core')
-rw-r--r--src/core/core_api.c5
-rw-r--r--src/core/core_api_monitor_peers.c34
-rw-r--r--src/core/gnunet-core.c80
3 files changed, 59 insertions, 60 deletions
diff --git a/src/core/core_api.c b/src/core/core_api.c
index 6381d9097..223677a5b 100644
--- a/src/core/core_api.c
+++ b/src/core/core_api.c
@@ -341,6 +341,7 @@ core_mq_cancel_impl (struct GNUNET_MQ_Handle *mq, void *impl_state)
341{ 341{
342 struct PeerRecord *pr = impl_state; 342 struct PeerRecord *pr = impl_state;
343 343
344 (void) mq;
344 GNUNET_assert (NULL != pr->env); 345 GNUNET_assert (NULL != pr->env);
345 GNUNET_MQ_discard (pr->env); 346 GNUNET_MQ_discard (pr->env);
346 pr->env = NULL; 347 pr->env = NULL;
@@ -359,7 +360,8 @@ static void
359core_mq_error_handler (void *cls, enum GNUNET_MQ_Error error) 360core_mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
360{ 361{
361 /* struct PeerRecord *pr = cls; */ 362 /* struct PeerRecord *pr = cls; */
362 363 (void) cls;
364 (void) error;
363 GNUNET_break_op (0); 365 GNUNET_break_op (0);
364} 366}
365 367
@@ -530,6 +532,7 @@ check_notify_inbound (void *cls, const struct NotifyTrafficMessage *ntm)
530 uint16_t msize; 532 uint16_t msize;
531 const struct GNUNET_MessageHeader *em; 533 const struct GNUNET_MessageHeader *em;
532 534
535 (void) cls;
533 msize = ntohs (ntm->header.size) - sizeof (struct NotifyTrafficMessage); 536 msize = ntohs (ntm->header.size) - sizeof (struct NotifyTrafficMessage);
534 if (msize < sizeof (struct GNUNET_MessageHeader)) 537 if (msize < sizeof (struct GNUNET_MessageHeader))
535 { 538 {
diff --git a/src/core/core_api_monitor_peers.c b/src/core/core_api_monitor_peers.c
index 0ebb94d7b..165f741d2 100644
--- a/src/core/core_api_monitor_peers.c
+++ b/src/core/core_api_monitor_peers.c
@@ -54,7 +54,6 @@ struct GNUNET_CORE_MonitorHandle
54 * Closure for @e peer_cb. 54 * Closure for @e peer_cb.
55 */ 55 */
56 void *peer_cb_cls; 56 void *peer_cb_cls;
57
58}; 57};
59 58
60 59
@@ -77,11 +76,11 @@ reconnect (struct GNUNET_CORE_MonitorHandle *mh);
77 * @param error error code 76 * @param error error code
78 */ 77 */
79static void 78static void
80handle_mq_error (void *cls, 79handle_mq_error (void *cls, enum GNUNET_MQ_Error error)
81 enum GNUNET_MQ_Error error)
82{ 80{
83 struct GNUNET_CORE_MonitorHandle *mh = cls; 81 struct GNUNET_CORE_MonitorHandle *mh = cls;
84 82
83 (void) error;
85 reconnect (mh); 84 reconnect (mh);
86} 85}
87 86
@@ -93,8 +92,7 @@ handle_mq_error (void *cls,
93 * @param mon_message monitor message 92 * @param mon_message monitor message
94 */ 93 */
95static void 94static void
96handle_receive_info (void *cls, 95handle_receive_info (void *cls, const struct MonitorNotifyMessage *mon_message)
97 const struct MonitorNotifyMessage *mon_message)
98{ 96{
99 struct GNUNET_CORE_MonitorHandle *mh = cls; 97 struct GNUNET_CORE_MonitorHandle *mh = cls;
100 98
@@ -114,24 +112,20 @@ handle_receive_info (void *cls,
114static void 112static void
115reconnect (struct GNUNET_CORE_MonitorHandle *mh) 113reconnect (struct GNUNET_CORE_MonitorHandle *mh)
116{ 114{
117 struct GNUNET_MQ_MessageHandler handlers[] = { 115 struct GNUNET_MQ_MessageHandler handlers[] =
118 GNUNET_MQ_hd_fixed_size (receive_info, 116 {GNUNET_MQ_hd_fixed_size (receive_info,
119 GNUNET_MESSAGE_TYPE_CORE_MONITOR_NOTIFY, 117 GNUNET_MESSAGE_TYPE_CORE_MONITOR_NOTIFY,
120 struct MonitorNotifyMessage, 118 struct MonitorNotifyMessage,
121 mh), 119 mh),
122 GNUNET_MQ_handler_end () 120 GNUNET_MQ_handler_end ()};
123 };
124 struct GNUNET_MQ_Envelope *env; 121 struct GNUNET_MQ_Envelope *env;
125 struct GNUNET_MessageHeader *msg; 122 struct GNUNET_MessageHeader *msg;
126 123
127 if (NULL != mh->mq) 124 if (NULL != mh->mq)
128 GNUNET_MQ_destroy (mh->mq); 125 GNUNET_MQ_destroy (mh->mq);
129 /* FIXME: use backoff? */ 126 /* FIXME: use backoff? */
130 mh->mq = GNUNET_CLIENT_connect (mh->cfg, 127 mh->mq =
131 "core", 128 GNUNET_CLIENT_connect (mh->cfg, "core", handlers, &handle_mq_error, mh);
132 handlers,
133 &handle_mq_error,
134 mh);
135 if (NULL == mh->mq) 129 if (NULL == mh->mq)
136 return; 130 return;
137 /* notify callback about reconnect */ 131 /* notify callback about reconnect */
@@ -140,10 +134,8 @@ reconnect (struct GNUNET_CORE_MonitorHandle *mh)
140 NULL, 134 NULL,
141 GNUNET_CORE_KX_CORE_DISCONNECT, 135 GNUNET_CORE_KX_CORE_DISCONNECT,
142 GNUNET_TIME_UNIT_FOREVER_ABS); 136 GNUNET_TIME_UNIT_FOREVER_ABS);
143 env = GNUNET_MQ_msg (msg, 137 env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_CORE_MONITOR_PEERS);
144 GNUNET_MESSAGE_TYPE_CORE_MONITOR_PEERS); 138 GNUNET_MQ_send (mh->mq, env);
145 GNUNET_MQ_send (mh->mq,
146 env);
147} 139}
148 140
149 141
diff --git a/src/core/gnunet-core.c b/src/core/gnunet-core.c
index 7180754a9..674da705a 100644
--- a/src/core/gnunet-core.c
+++ b/src/core/gnunet-core.c
@@ -48,6 +48,7 @@ static struct GNUNET_CORE_MonitorHandle *mh;
48static void 48static void
49shutdown_task (void *cls) 49shutdown_task (void *cls)
50{ 50{
51 (void) cls;
51 if (NULL != mh) 52 if (NULL != mh)
52 { 53 {
53 GNUNET_CORE_monitor_stop (mh); 54 GNUNET_CORE_monitor_stop (mh);
@@ -71,13 +72,13 @@ monitor_cb (void *cls,
71 enum GNUNET_CORE_KxState state, 72 enum GNUNET_CORE_KxState state,
72 struct GNUNET_TIME_Absolute timeout) 73 struct GNUNET_TIME_Absolute timeout)
73{ 74{
74 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get(); 75 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
75 const char *now_str; 76 const char *now_str;
76 const char *state_str; 77 const char *state_str;
77 78
78 if ( ( (NULL == peer) || 79 (void) cls;
79 (GNUNET_CORE_KX_ITERATION_FINISHED == state) ) && 80 if (((NULL == peer) || (GNUNET_CORE_KX_ITERATION_FINISHED == state)) &&
80 (GNUNET_NO == monitor_connections) ) 81 (GNUNET_NO == monitor_connections))
81 { 82 {
82 GNUNET_SCHEDULER_shutdown (); 83 GNUNET_SCHEDULER_shutdown ();
83 return; 84 return;
@@ -87,42 +88,43 @@ monitor_cb (void *cls,
87 { 88 {
88 case GNUNET_CORE_KX_STATE_DOWN: 89 case GNUNET_CORE_KX_STATE_DOWN:
89 /* should never happen, as we immediately send the key */ 90 /* should never happen, as we immediately send the key */
90 state_str = _("fresh connection"); 91 state_str = _ ("fresh connection");
91 break; 92 break;
92 case GNUNET_CORE_KX_STATE_KEY_SENT: 93 case GNUNET_CORE_KX_STATE_KEY_SENT:
93 state_str = _("key sent"); 94 state_str = _ ("key sent");
94 break; 95 break;
95 case GNUNET_CORE_KX_STATE_KEY_RECEIVED: 96 case GNUNET_CORE_KX_STATE_KEY_RECEIVED:
96 state_str = _("key received"); 97 state_str = _ ("key received");
97 break; 98 break;
98 case GNUNET_CORE_KX_STATE_UP: 99 case GNUNET_CORE_KX_STATE_UP:
99 state_str = _("connection established"); 100 state_str = _ ("connection established");
100 break; 101 break;
101 case GNUNET_CORE_KX_STATE_REKEY_SENT: 102 case GNUNET_CORE_KX_STATE_REKEY_SENT:
102 state_str = _("rekeying"); 103 state_str = _ ("rekeying");
103 break; 104 break;
104 case GNUNET_CORE_KX_PEER_DISCONNECT: 105 case GNUNET_CORE_KX_PEER_DISCONNECT:
105 state_str = _("disconnected"); 106 state_str = _ ("disconnected");
106 break; 107 break;
107 case GNUNET_CORE_KX_ITERATION_FINISHED: 108 case GNUNET_CORE_KX_ITERATION_FINISHED:
108 return; 109 return;
109 case GNUNET_CORE_KX_CORE_DISCONNECT: 110 case GNUNET_CORE_KX_CORE_DISCONNECT:
110 FPRINTF (stderr, 111 FPRINTF (stderr,
111 "%s\n", 112 "%s\n",
112 _("Connection to CORE service lost (reconnecting)")); 113 _ ("Connection to CORE service lost (reconnecting)"));
113 return; 114 return;
114 default: 115 default:
115 state_str = _("unknown state"); 116 state_str = _ ("unknown state");
116 break; 117 break;
117 } 118 }
118 now_str = GNUNET_STRINGS_absolute_time_to_string (now); 119 now_str = GNUNET_STRINGS_absolute_time_to_string (now);
119 FPRINTF (stdout, 120 FPRINTF (stdout,
120 _("%24s: %-30s %4s (timeout in %6s)\n"), 121 _ ("%24s: %-30s %4s (timeout in %6s)\n"),
121 now_str, 122 now_str,
122 state_str, 123 state_str,
123 GNUNET_i2s (peer), 124 GNUNET_i2s (peer),
124 GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_remaining (timeout), 125 GNUNET_STRINGS_relative_time_to_string (
125 GNUNET_YES)); 126 GNUNET_TIME_absolute_get_remaining (timeout),
127 GNUNET_YES));
126} 128}
127 129
128 130
@@ -135,24 +137,22 @@ monitor_cb (void *cls,
135 * @param cfg configuration 137 * @param cfg configuration
136 */ 138 */
137static void 139static void
138run (void *cls, char *const *args, const char *cfgfile, 140run (void *cls,
141 char *const *args,
142 const char *cfgfile,
139 const struct GNUNET_CONFIGURATION_Handle *cfg) 143 const struct GNUNET_CONFIGURATION_Handle *cfg)
140{ 144{
145 (void) cls;
146 (void) cfgfile;
141 if (NULL != args[0]) 147 if (NULL != args[0])
142 { 148 {
143 FPRINTF (stderr, 149 FPRINTF (stderr, _ ("Invalid command line argument `%s'\n"), args[0]);
144 _("Invalid command line argument `%s'\n"),
145 args[0]);
146 return; 150 return;
147 } 151 }
148 mh = GNUNET_CORE_monitor_start (cfg, 152 mh = GNUNET_CORE_monitor_start (cfg, &monitor_cb, NULL);
149 &monitor_cb,
150 NULL);
151 if (NULL == mh) 153 if (NULL == mh)
152 { 154 {
153 FPRINTF (stderr, 155 FPRINTF (stderr, "%s", _ ("Failed to connect to CORE service!\n"));
154 "%s",
155 _("Failed to connect to CORE service!\n"));
156 return; 156 return;
157 } 157 }
158 GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); 158 GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
@@ -167,24 +167,28 @@ run (void *cls, char *const *args, const char *cfgfile,
167 * @return 0 ok, 1 on error 167 * @return 0 ok, 1 on error
168 */ 168 */
169int 169int
170main (int argc, 170main (int argc, char *const *argv)
171 char *const *argv)
172{ 171{
173 int res; 172 int res;
174 struct GNUNET_GETOPT_CommandLineOption options[] = { 173 struct GNUNET_GETOPT_CommandLineOption options[] =
175 GNUNET_GETOPT_option_flag ('m', 174 {GNUNET_GETOPT_option_flag (
176 "monitor", 175 'm',
177 gettext_noop ("provide information about all current connections (continuously)"), 176 "monitor",
178 &monitor_connections), 177 gettext_noop (
179 GNUNET_GETOPT_OPTION_END 178 "provide information about all current connections (continuously)"),
180 }; 179 &monitor_connections),
180 GNUNET_GETOPT_OPTION_END};
181 181
182 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) 182 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
183 return 2; 183 return 2;
184 res = GNUNET_PROGRAM_run (argc, argv, "gnunet-core", 184 res = GNUNET_PROGRAM_run (argc,
185 gettext_noop 185 argv,
186 ("Print information about connected peers."), 186 "gnunet-core",
187 options, &run, NULL); 187 gettext_noop (
188 "Print information about connected peers."),
189 options,
190 &run,
191 NULL);
188 192
189 GNUNET_free ((void *) argv); 193 GNUNET_free ((void *) argv);
190 if (GNUNET_OK == res) 194 if (GNUNET_OK == res)