Project

General

Profile

Actions

Bug #4036

closed

fix blkdev uninitialized return values

Added by Dan McDonald almost 10 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Start date:
2013-08-12
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
needs-triage
Gerrit CR:
External Bug:

Description

These have been in illumos-nexenta for a while. One fixes an uninitialized-variable nit, the other sets the return value of an ioctl to 0 when it otherwise hasn't been touched. There's some small cstyle nits fixed as well.

This will likely be integrated alongside the sTec S112x "skd" driver.

--- /export/home/danmcd/ws/git-illumos/usr/src/uts/common/io/blkdev/blkdev.c    Wed Jul 10 15:49:27 2013
+++ ../../common/io/blkdev/blkdev.c    Mon Aug 12 13:32:00 2013
@@ -540,7 +540,7 @@
     int kmflag)
 {
     bd_xfer_impl_t        *xi;
-    int            rv;
+    int            rv = 0;
     int            status;
     unsigned        dir;
     int            (*cb)(caddr_t);
@@ -683,6 +683,7 @@
     int        rv;
     diskaddr_t    nblks;
     diskaddr_t    lba;
+    int        i;

     _NOTE(ARGUNUSED(credp));

@@ -755,7 +756,7 @@
             rv = EBUSY;
             goto done;
         }
-        for (int i = 0; i < OTYP_LYR; i++) {
+        for (i = 0; i < OTYP_LYR; i++) {
             if (bd->d_open_reg[i] & mask) {
                 rv = EBUSY;
                 goto done;
@@ -788,6 +789,7 @@
     minor_t        part;
     uint64_t    mask;
     boolean_t    last = B_TRUE;
+    int        i;

     _NOTE(ARGUNUSED(flag));
     _NOTE(ARGUNUSED(credp));
@@ -814,12 +816,12 @@
     } else {
         bd->d_open_reg[otyp] &= ~mask;
     }
-    for (int i = 0; i < 64; i++) {
+    for (i = 0; i < 64; i++) {
         if (bd->d_open_lyr[part]) {
             last = B_FALSE;
         }
     }
-    for (int i = 0; last && (i < OTYP_LYR); i++) {
+    for (i = 0; last && (i < OTYP_LYR); i++) {
         if (bd->d_open_reg[i]) {
             last = B_FALSE;
         }
@@ -1041,6 +1043,11 @@
     if (rv != ENOTTY)
         return (rv);

+    if (rvalp != NULL) {
+        /* the return value of the ioctl is 0 by default */
+        *rvalp = 0;
+    }
+
     switch (cmd) {
     case DKIOCGMEDIAINFO: {
         struct dk_minfo minfo;

Actions #1

Updated by Garrett D'Amore about 9 years ago

Dan, lets just go ahead and get these integrated.

Actions #2

Updated by Garrett D'Amore about 9 years ago

Btw, please don't rip out the C99isms localized int loop control variables. We have C99 in our kernel, and localizing the scope this way actually helps the optimizer with register scheduling. (This probably doesn't make a measurable difference, but I'd rather leave them there than rip them out out of some anti-C99 sentiment.)

Actions #3

Updated by Rich Lowe over 8 years ago

  • Subject changed from Small blkdev fixes from NexentaStor to fix blkdev uninitialized return values
Actions #4

Updated by Electric Monk over 8 years ago

  • Status changed from New to Closed
  • % Done changed from 0 to 100

git commit a0cb694bef8ce5b375d89d042945f0e24bbd4026

commit  a0cb694bef8ce5b375d89d042945f0e24bbd4026
Author: Steve Ma <steve.ma@nexenta.com>
Date:   2014-09-11T16:25:21.000Z

    4036 fix blkdev uninitialized return values
    Reviewed by: Dan McDonald <danmcd@omniti.com>
    Reviewed by: Garrett D'Amore <garrett@damore.org>
    Reviewed by: Hans Rosenfeld <hans.rosenfeld@nexenta.com>
    Approved by: Richard Lowe <richlowe@richlowe.net>

Actions #5

Updated by Electric Monk over 8 years ago

git commit 531aa4e241ba5493b8c232a85b0524302f7415f0

commit  531aa4e241ba5493b8c232a85b0524302f7415f0
Author: Hans Rosenfeld <hans.rosenfeld@nexenta.com>
Date:   2014-09-16T14:21:10.000Z

    4036 fix blkdev uninitialized return values (Makefile)

Actions

Also available in: Atom PDF