@@ -1592,7 +1592,7 @@ static CFStringRef copy_printer_interface_deviceid(printer_interface_t printer,
15921592
15931593 request .wLength = HostToUSBWord (size );
15941594 request .pData = buffer ;
1595- berr = (* printer )-> ControlRequestTO (printer , ( UInt8 ) 0 , & request );
1595+ berr = (* printer )-> ControlRequestTO (printer , 0 , & request );
15961596 return berr ;
15971597 };
15981598
@@ -1655,7 +1655,7 @@ static CFStringRef copy_printer_interface_deviceid(printer_interface_t printer,
16551655 err = (* printer )-> ControlRequestTO (printer , 0 , & request );
16561656 if (err == kIOReturnSuccess )
16571657 {
1658- CFMutableStringRef extras = CFStringCreateMutable (NULL , 0 );
1658+ CFMutableStringRef extras = CFStringCreateMutable (kCFAllocatorDefault , 0 );
16591659 if (manufacturer == NULL )
16601660 {
16611661 manufacturer = copy_printer_interface_indexed_description (printer , desc .iManufacturer , kUSBLanguageEnglish );
@@ -1682,7 +1682,7 @@ static CFStringRef copy_printer_interface_deviceid(printer_interface_t printer,
16821682 {
16831683 // 1284 serial number doesn't match USB serial number, so replace the existing SERN: in device ID
16841684 CFRange range = CFStringFind (ret , serial , 0 );
1685- CFMutableStringRef deviceIDString = CFStringCreateMutableCopy (NULL , 0 , ret );
1685+ CFMutableStringRef deviceIDString = CFStringCreateMutableCopy (kCFAllocatorDefault , 0 , ret );
16861686 CFStringReplace (deviceIDString , range , userial );
16871687 CFRelease (ret );
16881688 ret = deviceIDString ;
@@ -1717,7 +1717,7 @@ static CFStringRef copy_printer_interface_deviceid(printer_interface_t printer,
17171717 {
17181718 range = CFStringFind (ret , serial , 0 );
17191719
1720- CFMutableStringRef deviceIDString = CFStringCreateMutableCopy (NULL , 0 , ret );
1720+ CFMutableStringRef deviceIDString = CFStringCreateMutableCopy (kCFAllocatorDefault , 0 , ret );
17211721 CFRelease (ret );
17221722
17231723 ret = deviceIDString ;
@@ -1749,7 +1749,7 @@ static CFStringRef copy_printer_interface_indexed_description(printer_interface_
17491749 UInt8 description [256 ]; // Max possible descriptor length
17501750 IOUSBDevRequestTO request ;
17511751
1752- memset ( description , 0 , 2 ) ;
1752+ description [ 0 ] = description [ 1 ] = 0 ;
17531753
17541754 request .bmRequestType = USBmakebmRequestType (kUSBIn , kUSBStandard , kUSBDevice );
17551755 request .bRequest = kUSBRqGetDescriptor ;
@@ -1758,7 +1758,7 @@ static CFStringRef copy_printer_interface_indexed_description(printer_interface_
17581758 request .wLength = 2 ;
17591759 request .pData = & description ;
17601760 request .completionTimeout = 0 ;
1761- request .noDataTimeout = 60L ;
1761+ request .noDataTimeout = 60U ;
17621762
17631763 err = (* printer )-> ControlRequestTO (printer , 0 , & request );
17641764 if (err != kIOReturnSuccess && err != kIOReturnOverrun )
@@ -1777,16 +1777,16 @@ static CFStringRef copy_printer_interface_indexed_description(printer_interface_
17771777 request .wLength = sizeof description ;
17781778 request .pData = & description ;
17791779 request .completionTimeout = 0 ;
1780- request .noDataTimeout = 60L ;
1780+ request .noDataTimeout = 60U ;
17811781
17821782 err = (* printer )-> ControlRequestTO (printer , 0 , & request );
17831783 if (err != kIOReturnSuccess && err != kIOReturnUnderrun )
17841784 return NULL ;
17851785 }
17861786
1787- unsigned int length = description [0 ];
1787+ UInt8 length = description [0 ];
17881788 if (length == 0 )
1789- return CFStringCreateWithCString ( NULL , "" , kCFStringEncodingUTF8 );
1789+ return CFSTR ( "" );
17901790
17911791 if (description [1 ] != kUSBStringDesc )
17921792 return NULL ;
@@ -1800,7 +1800,7 @@ static CFStringRef copy_printer_interface_indexed_description(printer_interface_
18001800 request .wLength = (UInt16 )length ;
18011801 request .pData = & description ;
18021802 request .completionTimeout = 0 ;
1803- request .noDataTimeout = 60L ;
1803+ request .noDataTimeout = 60U ;
18041804
18051805 err = (* printer )-> ControlRequestTO (printer , 0 , & request );
18061806 if (err != kIOReturnSuccess )
@@ -1810,24 +1810,21 @@ static CFStringRef copy_printer_interface_indexed_description(printer_interface_
18101810 return NULL ;
18111811
18121812 if ((description [0 ] & 1 ) != 0 )
1813- description [0 ] &= 0xfe ;
1813+ description [0 ] &= ~ 1 ;
18141814
1815- char buffer [258 ] = {0 };
1816- unsigned int maxLength = sizeof buffer ;
1817- if (description [0 ] > 1 )
1818- {
1819- length = (description [0 ]- 2 )/2 ;
1815+ if (description [0 ] < 2 )
1816+ return CFSTR ("" );
18201817
1821- if (length > maxLength - 1 )
1822- length = maxLength - 1 ;
1818+ char buffer [(sizeof (description ) - 2 ) / 2 ];
1819+ UInt8 maxLength = sizeof (buffer ) - 1 ;
1820+ length = (description [0 ] - 2 ) / 2 ;
18231821
1824- for (unsigned i = 0 ; i < length ; i ++ )
1825- buffer [i ] = (char ) description [2 * i + 2 ];
1822+ for (UInt8 i = 0 ; i < length ; i ++ )
1823+ buffer [i ] = (char ) description [2 * i + 2 ];
18261824
1827- buffer [length ] = 0 ;
1828- }
1825+ buffer [length ] = 0 ;
18291826
1830- return CFStringCreateWithCString (NULL , buffer , kCFStringEncodingUTF8 );
1827+ return CFStringCreateWithCString (kCFAllocatorDefault , buffer , kCFStringEncodingUTF8 );
18311828}
18321829
18331830/*
@@ -1906,18 +1903,18 @@ static CFStringRef copy_value_for_key(CFStringRef deviceID,
19061903 {
19071904 if (range .location != 0 )
19081905 {
1909- CFMutableStringRef theString = CFStringCreateMutableCopy (NULL , 0 , kvpair );
1906+ CFMutableStringRef theString = CFStringCreateMutableCopy (kCFAllocatorDefault , 0 , kvpair );
19101907 CFStringTrimWhitespace (theString );
19111908 range = CFStringFind (theString , keys [idxx ], kCFCompareCaseInsensitive );
19121909 if (range .location == 0 )
1913- value = CFStringCreateWithSubstring (NULL , theString , CFRangeMake (range .length , CFStringGetLength (theString ) - range .length ));
1910+ value = CFStringCreateWithSubstring (kCFAllocatorDefault , theString , CFRangeMake (range .length , CFStringGetLength (theString ) - range .length ));
19141911
19151912 CFRelease (theString );
19161913 }
19171914 else
19181915 {
1919- CFStringRef theString = CFStringCreateWithSubstring (NULL , kvpair , CFRangeMake (range .length , CFStringGetLength (kvpair ) - range .length ));
1920- CFMutableStringRef theString2 = CFStringCreateMutableCopy (NULL , 0 , theString );
1916+ CFStringRef theString = CFStringCreateWithSubstring (kCFAllocatorDefault , kvpair , CFRangeMake (range .length , CFStringGetLength (kvpair ) - range .length ));
1917+ CFMutableStringRef theString2 = CFStringCreateMutableCopy (kCFAllocatorDefault , 0 , theString );
19211918 CFRelease (theString );
19221919
19231920 CFStringTrimWhitespace (theString2 );
@@ -1944,9 +1941,9 @@ CFStringRef cfstr_create_trim(const char *cstr)
19441941 CFStringRef cfstr ;
19451942 CFMutableStringRef cfmutablestr = NULL ;
19461943
1947- if ((cfstr = CFStringCreateWithCString (NULL , cstr , kCFStringEncodingUTF8 )) != NULL )
1944+ if ((cfstr = CFStringCreateWithCString (kCFAllocatorDefault , cstr , kCFStringEncodingUTF8 )) != NULL )
19481945 {
1949- if ((cfmutablestr = CFStringCreateMutableCopy (NULL , 1024 , cfstr )) != NULL )
1946+ if ((cfmutablestr = CFStringCreateMutableCopy (kCFAllocatorDefault , 1024 , cfstr )) != NULL )
19501947 CFStringTrimWhitespace (cfmutablestr );
19511948
19521949 CFRelease (cfstr );
0 commit comments