History

block, char_dev: Use correct format specifier for unsigned ints

register_blkdev() and __register_chrdev_region() treat the major number as an unsigned int. So print it the same way to avoid absurd error statements such as: "... major requested (-1) is greater than the maximum (511) ..." (and also fix off-by-one bugs in the error prints). While at it, also update the comment describing register_blkdev().

Srivatsa S. Bhat committed 8 years ago

Commit f33ff111 parent 652d7032 files · +13 −10Browse files

Showing the changes to fs/char_dev.c (1 of 2 files). Show all

Unified · Split

fs/char_dev.c+2−2
@@ -121,8 +121,8 @@ __register_chrdev_region(unsigned int major, unsigned int baseminor, · 120 unmodified lines
121121 }
122122
123123 if (major >= CHRDEV_MAJOR_MAX) {
124− pr_err("CHRDEV \"%s\" major requested (%d) is greater than the maximum (%d)\n",
125− name, major, CHRDEV_MAJOR_MAX);
124+ pr_err("CHRDEV \"%s\" major requested (%u) is greater than the maximum (%u)\n",
125+ name, major, CHRDEV_MAJOR_MAX-1);
126126 ret = -EINVAL;
127127 goto out;
128128 }