Make muc_nick return a const char* const
In the documentation of the `muc_nick` function we can read: > The nickname is owned by the chat room and should not be modified or freed We should reflect that in the return type and `strdup` the value for the plugin API. Fixes: https://github.com/profanity-im/profanity/issues/2013
This commit is contained in:
@@ -426,7 +426,7 @@ muc_rooms(void)
|
||||
* Return current users nickname for the specified room
|
||||
* The nickname is owned by the chat room and should not be modified or freed
|
||||
*/
|
||||
char*
|
||||
const char* const
|
||||
muc_nick(const char* const room)
|
||||
{
|
||||
ChatRoom* chat_room = g_hash_table_lookup(rooms, room);
|
||||
|
||||
@@ -94,7 +94,7 @@ GList* muc_rooms(void);
|
||||
|
||||
void muc_set_features(const char* const room, GSList* features);
|
||||
|
||||
char* muc_nick(const char* const room);
|
||||
const char* const muc_nick(const char* const room);
|
||||
char* muc_password(const char* const room);
|
||||
|
||||
void muc_nick_change_start(const char* const room, const char* const new_nick);
|
||||
|
||||
@@ -259,7 +259,7 @@ _send_room_presence(xmpp_stanza_t* presence)
|
||||
GList* curr = rooms;
|
||||
while (curr) {
|
||||
const char* room = curr->data;
|
||||
const char* nick = muc_nick(room);
|
||||
const char* const nick = muc_nick(room);
|
||||
|
||||
if (nick) {
|
||||
auto_char char* full_room_jid = create_fulljid(room, nick);
|
||||
@@ -327,7 +327,7 @@ presence_leave_chat_room(const char* const room_jid)
|
||||
{
|
||||
assert(room_jid != NULL);
|
||||
|
||||
char* nick = muc_nick(room_jid);
|
||||
const char* const nick = muc_nick(room_jid);
|
||||
if (!nick) {
|
||||
log_error("Could not get nickname for room: %s", room_jid);
|
||||
return;
|
||||
|
||||
@@ -1384,7 +1384,7 @@ stanza_is_muc_self_presence(xmpp_stanza_t* const stanza,
|
||||
if (from) {
|
||||
auto_jid Jid* from_jid = jid_create(from);
|
||||
if (muc_active(from_jid->barejid)) {
|
||||
char* nick = muc_nick(from_jid->barejid);
|
||||
const char* const nick = muc_nick(from_jid->barejid);
|
||||
if (g_strcmp0(from_jid->resourcepart, nick) == 0) {
|
||||
return TRUE;
|
||||
}
|
||||
@@ -1394,7 +1394,7 @@ stanza_is_muc_self_presence(xmpp_stanza_t* const stanza,
|
||||
if (muc_nick_change_pending(from_jid->barejid)) {
|
||||
char* new_nick = from_jid->resourcepart;
|
||||
if (new_nick) {
|
||||
char* nick = muc_nick(from_jid->barejid);
|
||||
const char* const nick = muc_nick(from_jid->barejid);
|
||||
char* old_nick = muc_old_nick(from_jid->barejid, new_nick);
|
||||
if (g_strcmp0(old_nick, nick) == 0) {
|
||||
return TRUE;
|
||||
|
||||
Reference in New Issue
Block a user