Use sizeof instead of strlen on string constants. The compiler doesn't
optimise the strlen calls away with -ffreestanding.
This commit is contained in:
parent
4ffeccf1e8
commit
f3792e07f6
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=324628
@ -128,33 +128,32 @@ linux_driver_get_major_minor(const char *node, int *major, int *minor)
|
||||
{
|
||||
struct device_element *de;
|
||||
unsigned long devno;
|
||||
size_t sz;
|
||||
|
||||
if (node == NULL || major == NULL || minor == NULL)
|
||||
return 1;
|
||||
|
||||
if (strlen(node) > strlen("pts/") &&
|
||||
strncmp(node, "pts/", strlen("pts/")) == 0) {
|
||||
sz = sizeof("pts/") - 1;
|
||||
if (strncmp(node, "pts/", sz) == 0 && node[sz] != '\0') {
|
||||
/*
|
||||
* Linux checks major and minors of the slave device
|
||||
* to make sure it's a pty device, so let's make him
|
||||
* believe it is.
|
||||
*/
|
||||
devno = strtoul(node + strlen("pts/"), NULL, 10);
|
||||
devno = strtoul(node + sz, NULL, 10);
|
||||
*major = 136 + (devno / 256);
|
||||
*minor = devno % 256;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
if ((strlen(node) > strlen("drm/") &&
|
||||
strncmp(node, "drm/", strlen("drm/")) == 0) ) {
|
||||
devno = strtoul(node + strlen("drm/"), NULL, 10);
|
||||
sz = sizeof("drm/") - 1;
|
||||
if (strncmp(node, "drm/", sz) == 0 && node[sz] != '\0') {
|
||||
devno = strtoul(node + sz, NULL, 10);
|
||||
*major = 226 + (devno / 256);
|
||||
*minor = devno % 256;
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
TAILQ_FOREACH(de, &devices, list) {
|
||||
if (strcmp(node, de->entry.bsd_device_name) == 0) {
|
||||
*major = de->entry.linux_major;
|
||||
|
Loading…
Reference in New Issue
Block a user