Remove casts made unneeded by the previous changeset.
[umurmur.git] / src / messagehandler.c
index a8472871ae86f38ad5c391266eedb2053c11e974..514949f7ba9f64fcd981c59d82b796680d309425 100644 (file)
@@ -306,7 +306,7 @@ void Mh_handle_message(client_t *client, message_t *msg)
                sendmsg->payload.userState->session = client->sessionId;
                sendmsg->payload.userState->name = strdup(client->username);
                sendmsg->payload.userState->has_channel_id = true;
-               sendmsg->payload.userState->channel_id = ((channel_t *)client->channel)->id;
+               sendmsg->payload.userState->channel_id = client->channel->id;
 
                if (defaultChan->silent) {
                        sendmsg->payload.userState->has_suppress = true;
@@ -324,11 +324,11 @@ void Mh_handle_message(client_t *client, message_t *msg)
                        sendmsg->payload.userState->session = client_itr->sessionId;
                        sendmsg->payload.userState->name = strdup(client_itr->username);
                        sendmsg->payload.userState->has_channel_id = true;
-                       sendmsg->payload.userState->channel_id = ((channel_t *)client_itr->channel)->id;
-                       sendmsg->payload.userState->has_suppress = ((channel_t *)client_itr->channel)->silent;
-                       sendmsg->payload.userState->suppress = ((channel_t *)client_itr->channel)->silent;
+                       sendmsg->payload.userState->channel_id = client_itr->channel->id;
+                       sendmsg->payload.userState->has_suppress = client_itr->channel->silent;
+                       sendmsg->payload.userState->suppress = client_itr->channel->silent;
 
-                       client_itr->isSuppressed = ((channel_t *)client_itr->channel)->silent;
+                       client_itr->isSuppressed = client_itr->channel->silent;
 
                        if (client_itr->self_deaf) {
                                sendmsg->payload.userState->has_self_deaf = true;
@@ -554,8 +554,7 @@ void Mh_handle_message(client_t *client, message_t *msg)
                        }
                }
                if (msg->payload.userState->has_plugin_context) {
-                       if (client->context)
-                               free(client->context);
+                       free(client->context);
                        client->context = Memory_safeMalloc(1, msg->payload.userState->plugin_context.len);
                        memcpy(client->context, msg->payload.userState->plugin_context.data,
                                   msg->payload.userState->plugin_context.len);
@@ -662,17 +661,17 @@ void Mh_handle_message(client_t *client, message_t *msg)
                        Log_debug("Client version 0x%x", client->version);
                }
                if (msg->payload.version->release) {
-                       if (client->release) free(client->release);
+                       free(client->release);
                        client->release = strdup(msg->payload.version->release);
                        Log_debug("Client release %s", client->release);
                }
                if (msg->payload.version->os) {
-                       if (client->os) free(client->os);
+                       free(client->os);
                        client->os = strdup(msg->payload.version->os);
                        Log_debug("Client OS %s", client->os);
                }
                if (msg->payload.version->os_version) {
-                       if (client->os_version) free(client->os_version);
+                       free(client->os_version);
                        client->os_version = strdup(msg->payload.version->os_version);
                        Log_debug("Client OS version %s", client->os_version);
                }
@@ -870,17 +869,21 @@ void Mh_handle_message(client_t *client, message_t *msg)
                        sendmsg->payload.userStats->opus = target->bOpus;
 
                        /* Address */
-                       sendmsg->payload.userStats->has_address = true;
-                       sendmsg->payload.userStats->address.data
-                               = Memory_safeMalloc(16, sizeof(uint8_t));
-                       memset(sendmsg->payload.userStats->address.data, 0, 16);
-                       /* ipv4 representation as ipv6 address. Supposedly correct. */
-                       memset(&sendmsg->payload.userStats->address.data[10], 0xff, 2); /* IPv4 */
-      if(target->remote_tcp.ss_family == AF_INET)
-        memcpy(&sendmsg->payload.userStats->address.data[12], &((struct sockaddr_in*)&target->remote_tcp)->sin_addr, 4);
-      else
-        memcpy(&sendmsg->payload.userStats->address.data[0], &((struct sockaddr_in6*)&target->remote_tcp)->sin6_addr, 16);
-                       sendmsg->payload.userStats->address.len = 16;
+                       if (getBoolConf(SHOW_ADDRESSES)) {
+                               sendmsg->payload.userStats->has_address = true;
+                               sendmsg->payload.userStats->address.data
+                                       = Memory_safeMalloc(16, sizeof(uint8_t));
+                               memset(sendmsg->payload.userStats->address.data, 0, 16);
+                               /* ipv4 representation as ipv6 address. Supposedly correct. */
+                               memset(&sendmsg->payload.userStats->address.data[10], 0xff, 2); /* IPv4 */
+                               if(target->remote_tcp.ss_family == AF_INET)
+                                       memcpy(&sendmsg->payload.userStats->address.data[12], &((struct sockaddr_in*)&target->remote_tcp)->sin_addr, 4);
+                               else
+                                       memcpy(&sendmsg->payload.userStats->address.data[0], &((struct sockaddr_in6*)&target->remote_tcp)->sin6_addr, 16);
+                               sendmsg->payload.userStats->address.len = 16;
+                       } else {
+                               sendmsg->payload.userStats->has_address = false;
+                       }
                }
                /* BW */
                sendmsg->payload.userStats->has_bandwidth = true;