Re: Mark bitrevX() functions as const

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

 



>> > Mark the bit reversal functions as being const as they always return the
>> > same output for any given input.
>> 
>> Well, we should mark the argument const too, no?
>
>The argument is just an integer; I'm not sure that marking it const actually
>achieves anything, except to tell the function that it can't modify it - and
>since it's effectively a copy, where's the fun in that.

I can just second this. What should be marked const is [1]the things 
pointed to, not [2]the local copy of a function argument.

This[2] is what I believe almost every other software project does, 
though they often fail at [1]. Or have you seen Glibc trying to pull a
int strtoul(const char *const nptr, char **const endptr, const int 
base)? It just makes the prototypes and headers longer without having 
too much benefit. And maybe the code author may even want to reuse the 
args directly as walking pointers or countdown integers, for example.


	-`J'
-- 
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux