Re: [PATCH/RFC] rewrite `git_default_config()` using config-set API functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Tanay Abhra <tanayabh@xxxxxxxxx> writes:

>> 
>>> +	if > +	git_config_get_string("core.notesref", (const char**)&notes_ref_name);
>> 
>> This cast is needed only because notes_ref_name is declared as
>> non-const, but a better fix would be to make the variable const, and
>> remove the cast.
>
> Same casts had to be used in imap-send.c patch, I will have to use an
> intermediate variable there to remove the cast thus destroying the one
> liners or will have to update the variable declarations.

Updating the declaration like this should just work:

--- a/imap-send.c
+++ b/imap-send.c
@@ -1324,7 +1324,7 @@ static int split_msg(struct strbuf *all_msgs, struct strbuf *msg, int *ofs)
        return 1;
 }
 
-static char *imap_folder;
+static const char *imap_folder;
 
 static void git_imap_config(void)
 {
@@ -1332,7 +1332,7 @@ static void git_imap_config(void)
 
        git_config_get_bool("imap.sslverify", &server.ssl_verify);
        git_config_get_bool("imap.preformattedhtml", &server.use_html);
-       git_config_get_string("imap.folder", (const char**)&imap_folder);
+       git_config_get_string("imap.folder", &imap_folder);
 
        if (!git_config_get_value("imap.host", &val)) {
                if(!val)

In general, most strings one manipulates are "const char *", it's
frequent to modify a pointer to a string, but rather rare to modify the
string itself.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]