Re: [PATCH] kbuild: implement modules.order

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

 



WANG Cong wrote:
>> +static inline unsigned int sdb_hash(const char *str)
>> +{
>> +        unsigned int hash = 0;
>> +        int c;
>> +
>> +        while ((c = *str++))
> 
> Maybe ` while ((c = *str++) != '\0') ` is better. ;)

Yeah, probably.  That hash function is copied & pasted mindlessly from web.

>> +		hash = c + (hash << 6) + (hash << 16) - hash;
>> +
>> +        return hash;
>> +}
>> +
>> +int main(int argc, char **argv)
>> +{
>> +	unsigned int nr_entries = 0;
>> +	struct hash_ent **hash_tbl;
>> +	char line[10240];
> 
> Needs to #define the magic number?

Or maybe write a wrapper function around fgets() to detect long lines
reliably.

>> +		while (fgets(line, sizeof(line), fp)) {
>> +			int len = strlen(line);
> 
> strlen returns 'size_t', which is unsigned.

It's capped by the magic number above but yeah size_t would be better.

> I think, you forgot to free(3) the memory you calloc(3)'ed and
> malloc(3)'ed above.

It's a simple program where whole body is in main().  Why bother?
What's the benefit of adding hash-table iterating free logic?

-- 
tejun
--
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