|
@@ -1625,25 +1625,28 @@ enum iscsi_root_path_component {
|
1625
|
1625
|
*/
|
1626
|
1626
|
static int iscsi_parse_lun ( struct iscsi_session *iscsi,
|
1627
|
1627
|
const char *lun_string ) {
|
1628
|
|
- char *p = ( char * ) lun_string;
|
1629
|
1628
|
union {
|
1630
|
1629
|
uint64_t u64;
|
1631
|
1630
|
uint16_t u16[4];
|
1632
|
1631
|
} lun;
|
|
1632
|
+ char *p;
|
1633
|
1633
|
int i;
|
1634
|
1634
|
|
1635
|
|
- /* Empty LUN; assume LUN 0 */
|
1636
|
|
- if ( ! *lun_string )
|
1637
|
|
- return 0;
|
1638
|
|
-
|
1639
|
|
- for ( i = 0 ; i < 4 ; i++ ) {
|
1640
|
|
- lun.u16[i] = strtoul ( p, &p, 16 );
|
1641
|
|
- if ( *p != '-' )
|
|
1635
|
+ memset ( &lun, 0, sizeof ( lun ) );
|
|
1636
|
+ if ( lun_string ) {
|
|
1637
|
+ p = ( char * ) lun_string;
|
|
1638
|
+
|
|
1639
|
+ for ( i = 0 ; i < 4 ; i++ ) {
|
|
1640
|
+ lun.u16[i] = htons ( strtoul ( p, &p, 16 ) );
|
|
1641
|
+ if ( *p == '\0' )
|
|
1642
|
+ break;
|
|
1643
|
+ if ( *p != '-' )
|
|
1644
|
+ return -EINVAL;
|
|
1645
|
+ p++;
|
|
1646
|
+ }
|
|
1647
|
+ if ( *p )
|
1642
|
1648
|
return -EINVAL;
|
1643
|
|
- p++;
|
1644
|
1649
|
}
|
1645
|
|
- if ( *p )
|
1646
|
|
- return -EINVAL;
|
1647
|
1650
|
|
1648
|
1651
|
iscsi->lun = lun.u64;
|
1649
|
1652
|
return 0;
|