gkdr / carbons

Experimental XEP-0280: Message Carbons plugin for libpurple (Pidgin, Finch, etc.)
GNU General Public License v2.0
82 stars 7 forks source link

Fix a crash when an OMEMO message is carboned from Conversations #28

Closed XRevan86 closed 6 years ago

gkdr commented 6 years ago

Thanks, shot myself in the foot there. I should stop setting the stanza to null in lurch. I might do some changes so that it fits more with my codestyle, though.

XRevan86 commented 6 years ago

I might do some changes so that it fits more with my codestyle, though.

If you mean g_strcmp0 () != 0, then it is recommended to have an explicit "0" there, because it is not a logical expression. After all, 0 (FALSE) is success for strcmp(), it's more like an exit code.

GTK+ C Coding Style:

The C language uses the value 0 for many purposes. As a numeric value, the end of a string, a null pointer and the FALSE boolean. To make the code clearer, you should write code that highlights the specific way 0 is used. So when reading a comparison, it is possible to know the variable type. For boolean variables, an implicit comparison is appropriate because it’s already a logical expression. Other variable types are not logical expressions by themselves, so an explicit comparison is better.

EionRobb commented 6 years ago

or use purple_strequal() (which is just a wrapper for g_strcmp0()) as it's slightly clearer about what's going on?

XRevan86 commented 6 years ago
gboolean
purple_strequal(const gchar *left, const gchar *right)
{
    return (g_strcmp0(left, right) == 0);
}

Interesting choice, Pidgin :-).

EionRobb commented 6 years ago

It used to be a lot more of a complicated function, before g_strcmp0() existed :)

XRevan86 commented 6 years ago

@EionRobb, ah, now it makes more historical sense :-).