Messages in this thread | | | Date | Sat, 19 Dec 1998 19:03:44 +0100 (MET) | From | (Guest section DW) | Subject | Re: memory waste in fs/devices.c/kdevname() |
| |
From: Tigran Aivazian <tigran@aivazian.demon.co.uk>
The current (2.1.131) code is:
char * kdevname(kdev_t dev) { static char buffer[32]; sprintf(buffer, "%02x:%02x", MAJOR(dev), MINOR(dev)); return buffer; }
But the maximum length of "%02x:%02x" is 6 bytes (including '\0'). We can throw in a couple of bytes "for good measure" and have static char buffer[8] but why on earth do we declare it as [32]?
Probably it was me who wrote the 32. 1) I have 64-bit device numbers, with 32-bit major and minor. This may require 10+1+10+1=22 bytes. 2) For me kdevname() actually produces device names if the right field in struct devicestruct is non-NULL. This is a routine that is called with the device struct as argument and produces names like sda2 or pty1345. It is documented to produce a name that fits in a char[32].
Please do not introduce assumptions on the properties of kdev_t into the kernel source. The main reason for the large delay in getting large device numbers is the mixup in the NFS code between dev_t and kdev_t. We do not need other obscure places with knowledge about kdev_t.
Andries
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |