Re: [libvirt] [PATCH 1 of 3] [LXC] Add functions to manage veth device pairs

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

 



Daniel Veillard <veillard@xxxxxxxxxx> wrote:
...
>> +int vethCreate(char* veth1, int veth1MaxLen,
>> +               char* veth2, int veth2MaxLen)
>> +{
>> +    int rc = -1;
>> +    const char *argv[] = {
>
> I think Jim insists on having const char const * [], but I bet he will explain
> this better than me :-)
>
>> +        "ip", "link", "add", veth1, "type", "veth", "peer", "name", veth2, NULL

You're right that I encourage the "const correct" approach ;-)

To tell the compiler (and more importantly, the reader) that you
have a const array of const strings, you'd declare it like this:

    const char *const argv[] = {

or, equivalently, the const can go after the type name of "char":

    char const *const argv[] = {

However, argv is one place where it pays to relax const-correctness
guidelines, at least in C, because so many interfaces require non-const
"char **argv" pointers.  IMHO, it's better to avoid const altogether in
this limited case than to be forced to litter the code with ugly and
dangerous const-adjusting casts to accommodate "correctness".

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]