Searched hist:0 (Results 1 - 25 of 7601) sorted by relevance
| /src/sys/arch/macppc/macppc/ | ||
| H A D | static_edid.c | 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. |
| H A D | static_edid.h | 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. 1.2 Mon Jan 28 02:25:01 GMT 2019 sevan Fake the EDID info for the clamshell iBook G3 so X11 works out of the box. Obtained from the 2nd (firewire) revision iBook, but it's applied to 1st gen also. [ 93.906] (II) R128(0): I2C bus "VGA-0" initialized. [ 93.907] (II) got 128 bytes worth of EDID from wsdisplay [ 93.908] (II) R128(0): EDID for output LVDS [ 93.908] (II) R128(0): Manufacturer: APP Model: 9c05 Serial#: 16843009 [ 93.908] (II) R128(0): Year: 1999 Week: 9 [ 93.908] (II) R128(0): EDID Version: 1.1 [ 93.908] (II) R128(0): Digital Display Input [ 93.908] (II) R128(0): Max Image Size [cm]: horiz.: 24 vert.: 18 [ 93.908] (II) R128(0): Gamma: 2.28 [ 93.908] (II) R128(0): DPMS capabilities: StandBy Suspend Off [ 93.909] (II) R128(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4 [ 93.909] (II) R128(0): redX: 0.594 redY: 0.345 greenX: 0.317 greenY: 0.494 [ 93.909] (II) R128(0): blueX: 0.155 blueY: 0.146 whiteX: 0.312 whiteY: 0.328 [ 93.909] (II) R128(0): Supported established timings: [ 93.909] (II) R128(0): 800x600@60Hz [ 93.909] (II) R128(0): Manufacturer's mask: 0 [ 93.910] (II) R128(0): Supported detailed timing: [ 93.910] (II) R128(0): clock: 60.0 MHz Image Size: 275 x 199 mm [ 93.910] (II) R128(0): h_active: 800 h_sync: 840 h_sync_end 968 h_blank_end 1056 h_border: 0 [ 93.910] (II) R128(0): v_active: 600 v_sync: 601 v_sync_end 605 v_blanking: 628 v_border: 0 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): LT121SU-121 [ 93.910] (II) R128(0): Monitor name: Color LCD [ 93.910] (II) R128(0): EDID (in hex): [ 93.910] (II) R128(0): 00ffffffffffff000610059c01010101 [ 93.910] (II) R128(0): 09090101a8181280e816e09858517e27 [ 93.910] (II) R128(0): 25505401000001010101010101010101 [ 93.911] (II) R128(0): 0101010101017017200031581c202880 [ 93.911] (II) R128(0): 140013c710000018000000fe004c5431 [ 93.911] (II) R128(0): 323153552d3132310a20000000fe004c [ 93.911] (II) R128(0): 5431323153552d3132310a20000000fc [ 93.911] (II) R128(0): 00436f6c6f72204c43440a2020200037 [ 93.912] (II) R128(0): I2C device "VGA-0:ddc2" registered at address 0xA0. |
| /src/sys/arch/riscv/riscv/ | ||
| H A D | db_interface.c | 1.1 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.1 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.1 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.1 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.1 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.1 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.1 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.1 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.1 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.1 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.1 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.1 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.1 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.1 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.1 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.1 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.1 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.1 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.1 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.1 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.1 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.1 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.1 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.1 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.1 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.1 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.1 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.1 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.1 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.1 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.1 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.1 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.1 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.1 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.1 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.1 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> |
| H A D | db_trace.c | 1.3 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.3 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.3 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.3 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.3 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.3 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.3 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.3 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.3 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.3 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.3 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.3 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.3 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.3 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.3 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.3 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.3 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.3 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.3 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.3 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.3 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.3 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.3 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.3 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.3 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.3 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.3 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.3 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.3 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.3 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.3 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.3 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.3 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.3 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.3 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.3 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> |
| H A D | db_machdep.c | 1.9 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.9 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.9 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.9 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.9 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.9 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.9 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.9 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.9 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.9 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.9 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.9 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.9 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.9 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.9 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.9 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.9 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.9 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.9 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.9 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.9 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.9 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.9 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.9 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.9 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.9 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.9 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.9 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.9 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.9 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.9 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.9 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.9 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.9 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.9 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.9 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> |
| /src/sys/arch/mips/mips/ | ||
| H A D | compat_13_machdep.c | 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 1.23 Thu Apr 24 00:54:43 GMT 2025 riastradh mips: Fix compat_13_sys_sigreturn locking. This had been broken back in rev. 1.13.20.1 (on the newlock2 branch, merged into HEAD as 1.14) in 2007. Should fix: lib/libc/setjmp/t_setjmp (261/985): 10 test cases _longjmp_zero: [0.078125s] Passed. _setjmp: [0.093750s] Passed. compat13_longjmp_zero: [ 7875.3945352] panic: kernel diagnostic assertion "mutex_owned(l->l_proc->p_lock)" failed: file "/tmp/build/2025.04.24.01.52.38-pmax/src/sys/kern/sys_sig.c", line 590 [ 7875.3984415] cpu0: Begin traceback... [ 7875.4062540] pid -2135532376 not found [ 7875.4140665] cpu0: End traceback... [ 7875.6093790] 0x80b65c90: cpu_reboot+0x3c (0x80b64000,0,0x866e5400,0x805b6440) ra 0x803197c0 sz 24 [ 7875.7109415] 0x80b65ca8: kern_reboot+0xb0 (0x80b64000,0,0x866e5400,0x805b6440) ra 0x80369c80 sz 40 [ 7875.7109415] 0x80b65cd0: vpanic+0x1dc (0x80b64000,0,0x866e5400,0x805b6440) ra 0x804c085c sz 48 [ 7875.7109415] 0x80b65d00: kern_assert+0x3c (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x8038df4c sz 32 [ 7875.7265665] 0x80b65d20: sigprocmask1+0x224 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800616f0 sz 48 [ 7875.7265665] 0x80b65d50: compat_13_sys_sigreturn+0x1f0 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x80055178 sz 376 [ 7875.7265665] 0x80b65ec8: syscall+0x158 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x800450ac sz 128 [ 7875.7265665] 0x80b65f48: mips1_systemcall+0xec (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0x7923d090 sz 0 [ 7875.7265665] PC 0x7923d090: not in kernel space [ 7875.7265665] 0x80b65f48: 0+0x7923d090 (0x80b64000,0x804e6a3c,0x8051f7a8,0x8052e330) ra 0 sz 0 [ 7875.7265665] User-level: pid 17290.17290 https://releng.netbsd.org/b5reports/pmax/2025/2025.04.24.01.52.38/test.log (Probably won't do anything about `pid -2135532376 not found', though!) Prompted by adding tests for compat13 for: PR port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1 PR port-mips/59342: compat_setjmp.S is confused about delay slots PR port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64 |
| /src/sys/rump/dev/lib/libpci_if_iwn/ | ||
| H A D | PCI_IF_IWN.ioconf | 1.1 Mon Apr 07 01:45:36 GMT 2014 pooka branches: 1.1.2; 1.1.4; 1.1.6; 1.1.10; Add a rump kernel component for the iwn wireless driver, tested with the one in my laptop: iwn0 at pci0 dev 19 function 0: vendor 0x8086 product 0x4237 (rev. 0x00) 1.1 Mon Apr 07 01:45:36 GMT 2014 pooka branches: 1.1.2; 1.1.4; 1.1.6; 1.1.10; Add a rump kernel component for the iwn wireless driver, tested with the one in my laptop: iwn0 at pci0 dev 19 function 0: vendor 0x8086 product 0x4237 (rev. 0x00) 1.1 Mon Apr 07 01:45:36 GMT 2014 pooka branches: 1.1.2; 1.1.4; 1.1.6; 1.1.10; Add a rump kernel component for the iwn wireless driver, tested with the one in my laptop: iwn0 at pci0 dev 19 function 0: vendor 0x8086 product 0x4237 (rev. 0x00) 1.1 Mon Apr 07 01:45:36 GMT 2014 pooka branches: 1.1.2; 1.1.4; 1.1.6; 1.1.10; Add a rump kernel component for the iwn wireless driver, tested with the one in my laptop: iwn0 at pci0 dev 19 function 0: vendor 0x8086 product 0x4237 (rev. 0x00) |
| /src/share/i18n/csmapper/GB/ | ||
| H A D | GB2312EXT%UCS.src | 1.2 Tue Aug 29 18:52:29 GMT 2006 tnozaki * updated 0xFE50-0xFEA0 mapping to Unicode3.0 later. * added fallback mapping of 0xA989-0xA995 <-> U+E7E7-U+E7F3. * some TTF - NSimSun(Microsoft GB18030 Support Package) and FZSongTi(Solaris GB18030 locale) - assign Vertical form(U+FE10-U+FE19) to UDA/PUA(0x2659-0x2673/U+E78D-U+E796), so comment about this. 1.2 Tue Aug 29 18:52:29 GMT 2006 tnozaki * updated 0xFE50-0xFEA0 mapping to Unicode3.0 later. * added fallback mapping of 0xA989-0xA995 <-> U+E7E7-U+E7F3. * some TTF - NSimSun(Microsoft GB18030 Support Package) and FZSongTi(Solaris GB18030 locale) - assign Vertical form(U+FE10-U+FE19) to UDA/PUA(0x2659-0x2673/U+E78D-U+E796), so comment about this. 1.2 Tue Aug 29 18:52:29 GMT 2006 tnozaki * updated 0xFE50-0xFEA0 mapping to Unicode3.0 later. * added fallback mapping of 0xA989-0xA995 <-> U+E7E7-U+E7F3. * some TTF - NSimSun(Microsoft GB18030 Support Package) and FZSongTi(Solaris GB18030 locale) - assign Vertical form(U+FE10-U+FE19) to UDA/PUA(0x2659-0x2673/U+E78D-U+E796), so comment about this. 1.2 Tue Aug 29 18:52:29 GMT 2006 tnozaki * updated 0xFE50-0xFEA0 mapping to Unicode3.0 later. * added fallback mapping of 0xA989-0xA995 <-> U+E7E7-U+E7F3. * some TTF - NSimSun(Microsoft GB18030 Support Package) and FZSongTi(Solaris GB18030 locale) - assign Vertical form(U+FE10-U+FE19) to UDA/PUA(0x2659-0x2673/U+E78D-U+E796), so comment about this. 1.2 Tue Aug 29 18:52:29 GMT 2006 tnozaki * updated 0xFE50-0xFEA0 mapping to Unicode3.0 later. * added fallback mapping of 0xA989-0xA995 <-> U+E7E7-U+E7F3. * some TTF - NSimSun(Microsoft GB18030 Support Package) and FZSongTi(Solaris GB18030 locale) - assign Vertical form(U+FE10-U+FE19) to UDA/PUA(0x2659-0x2673/U+E78D-U+E796), so comment about this. 1.2 Tue Aug 29 18:52:29 GMT 2006 tnozaki * updated 0xFE50-0xFEA0 mapping to Unicode3.0 later. * added fallback mapping of 0xA989-0xA995 <-> U+E7E7-U+E7F3. * some TTF - NSimSun(Microsoft GB18030 Support Package) and FZSongTi(Solaris GB18030 locale) - assign Vertical form(U+FE10-U+FE19) to UDA/PUA(0x2659-0x2673/U+E78D-U+E796), so comment about this. 1.2 Tue Aug 29 18:52:29 GMT 2006 tnozaki * updated 0xFE50-0xFEA0 mapping to Unicode3.0 later. * added fallback mapping of 0xA989-0xA995 <-> U+E7E7-U+E7F3. * some TTF - NSimSun(Microsoft GB18030 Support Package) and FZSongTi(Solaris GB18030 locale) - assign Vertical form(U+FE10-U+FE19) to UDA/PUA(0x2659-0x2673/U+E78D-U+E796), so comment about this. |
| H A D | GBKEXT%UCS.src | 1.2 Tue Aug 29 18:52:29 GMT 2006 tnozaki * updated 0xFE50-0xFEA0 mapping to Unicode3.0 later. * added fallback mapping of 0xA989-0xA995 <-> U+E7E7-U+E7F3. * some TTF - NSimSun(Microsoft GB18030 Support Package) and FZSongTi(Solaris GB18030 locale) - assign Vertical form(U+FE10-U+FE19) to UDA/PUA(0x2659-0x2673/U+E78D-U+E796), so comment about this. 1.2 Tue Aug 29 18:52:29 GMT 2006 tnozaki * updated 0xFE50-0xFEA0 mapping to Unicode3.0 later. * added fallback mapping of 0xA989-0xA995 <-> U+E7E7-U+E7F3. * some TTF - NSimSun(Microsoft GB18030 Support Package) and FZSongTi(Solaris GB18030 locale) - assign Vertical form(U+FE10-U+FE19) to UDA/PUA(0x2659-0x2673/U+E78D-U+E796), so comment about this. 1.2 Tue Aug 29 18:52:29 GMT 2006 tnozaki * updated 0xFE50-0xFEA0 mapping to Unicode3.0 later. * added fallback mapping of 0xA989-0xA995 <-> U+E7E7-U+E7F3. * some TTF - NSimSun(Microsoft GB18030 Support Package) and FZSongTi(Solaris GB18030 locale) - assign Vertical form(U+FE10-U+FE19) to UDA/PUA(0x2659-0x2673/U+E78D-U+E796), so comment about this. 1.2 Tue Aug 29 18:52:29 GMT 2006 tnozaki * updated 0xFE50-0xFEA0 mapping to Unicode3.0 later. * added fallback mapping of 0xA989-0xA995 <-> U+E7E7-U+E7F3. * some TTF - NSimSun(Microsoft GB18030 Support Package) and FZSongTi(Solaris GB18030 locale) - assign Vertical form(U+FE10-U+FE19) to UDA/PUA(0x2659-0x2673/U+E78D-U+E796), so comment about this. 1.2 Tue Aug 29 18:52:29 GMT 2006 tnozaki * updated 0xFE50-0xFEA0 mapping to Unicode3.0 later. * added fallback mapping of 0xA989-0xA995 <-> U+E7E7-U+E7F3. * some TTF - NSimSun(Microsoft GB18030 Support Package) and FZSongTi(Solaris GB18030 locale) - assign Vertical form(U+FE10-U+FE19) to UDA/PUA(0x2659-0x2673/U+E78D-U+E796), so comment about this. 1.2 Tue Aug 29 18:52:29 GMT 2006 tnozaki * updated 0xFE50-0xFEA0 mapping to Unicode3.0 later. * added fallback mapping of 0xA989-0xA995 <-> U+E7E7-U+E7F3. * some TTF - NSimSun(Microsoft GB18030 Support Package) and FZSongTi(Solaris GB18030 locale) - assign Vertical form(U+FE10-U+FE19) to UDA/PUA(0x2659-0x2673/U+E78D-U+E796), so comment about this. 1.2 Tue Aug 29 18:52:29 GMT 2006 tnozaki * updated 0xFE50-0xFEA0 mapping to Unicode3.0 later. * added fallback mapping of 0xA989-0xA995 <-> U+E7E7-U+E7F3. * some TTF - NSimSun(Microsoft GB18030 Support Package) and FZSongTi(Solaris GB18030 locale) - assign Vertical form(U+FE10-U+FE19) to UDA/PUA(0x2659-0x2673/U+E78D-U+E796), so comment about this. |
| H A D | UCS%GBKEXT.src | 1.2 Tue Aug 29 18:52:29 GMT 2006 tnozaki * updated 0xFE50-0xFEA0 mapping to Unicode3.0 later. * added fallback mapping of 0xA989-0xA995 <-> U+E7E7-U+E7F3. * some TTF - NSimSun(Microsoft GB18030 Support Package) and FZSongTi(Solaris GB18030 locale) - assign Vertical form(U+FE10-U+FE19) to UDA/PUA(0x2659-0x2673/U+E78D-U+E796), so comment about this. 1.2 Tue Aug 29 18:52:29 GMT 2006 tnozaki * updated 0xFE50-0xFEA0 mapping to Unicode3.0 later. * added fallback mapping of 0xA989-0xA995 <-> U+E7E7-U+E7F3. * some TTF - NSimSun(Microsoft GB18030 Support Package) and FZSongTi(Solaris GB18030 locale) - assign Vertical form(U+FE10-U+FE19) to UDA/PUA(0x2659-0x2673/U+E78D-U+E796), so comment about this. 1.2 Tue Aug 29 18:52:29 GMT 2006 tnozaki * updated 0xFE50-0xFEA0 mapping to Unicode3.0 later. * added fallback mapping of 0xA989-0xA995 <-> U+E7E7-U+E7F3. * some TTF - NSimSun(Microsoft GB18030 Support Package) and FZSongTi(Solaris GB18030 locale) - assign Vertical form(U+FE10-U+FE19) to UDA/PUA(0x2659-0x2673/U+E78D-U+E796), so comment about this. 1.2 Tue Aug 29 18:52:29 GMT 2006 tnozaki * updated 0xFE50-0xFEA0 mapping to Unicode3.0 later. * added fallback mapping of 0xA989-0xA995 <-> U+E7E7-U+E7F3. * some TTF - NSimSun(Microsoft GB18030 Support Package) and FZSongTi(Solaris GB18030 locale) - assign Vertical form(U+FE10-U+FE19) to UDA/PUA(0x2659-0x2673/U+E78D-U+E796), so comment about this. 1.2 Tue Aug 29 18:52:29 GMT 2006 tnozaki * updated 0xFE50-0xFEA0 mapping to Unicode3.0 later. * added fallback mapping of 0xA989-0xA995 <-> U+E7E7-U+E7F3. * some TTF - NSimSun(Microsoft GB18030 Support Package) and FZSongTi(Solaris GB18030 locale) - assign Vertical form(U+FE10-U+FE19) to UDA/PUA(0x2659-0x2673/U+E78D-U+E796), so comment about this. 1.2 Tue Aug 29 18:52:29 GMT 2006 tnozaki * updated 0xFE50-0xFEA0 mapping to Unicode3.0 later. * added fallback mapping of 0xA989-0xA995 <-> U+E7E7-U+E7F3. * some TTF - NSimSun(Microsoft GB18030 Support Package) and FZSongTi(Solaris GB18030 locale) - assign Vertical form(U+FE10-U+FE19) to UDA/PUA(0x2659-0x2673/U+E78D-U+E796), so comment about this. 1.2 Tue Aug 29 18:52:29 GMT 2006 tnozaki * updated 0xFE50-0xFEA0 mapping to Unicode3.0 later. * added fallback mapping of 0xA989-0xA995 <-> U+E7E7-U+E7F3. * some TTF - NSimSun(Microsoft GB18030 Support Package) and FZSongTi(Solaris GB18030 locale) - assign Vertical form(U+FE10-U+FE19) to UDA/PUA(0x2659-0x2673/U+E78D-U+E796), so comment about this. |
| H A D | GB2312UDA2%UCS.src | 1.3 Tue Aug 29 18:52:29 GMT 2006 tnozaki * updated 0xFE50-0xFEA0 mapping to Unicode3.0 later. * added fallback mapping of 0xA989-0xA995 <-> U+E7E7-U+E7F3. * some TTF - NSimSun(Microsoft GB18030 Support Package) and FZSongTi(Solaris GB18030 locale) - assign Vertical form(U+FE10-U+FE19) to UDA/PUA(0x2659-0x2673/U+E78D-U+E796), so comment about this. 1.3 Tue Aug 29 18:52:29 GMT 2006 tnozaki * updated 0xFE50-0xFEA0 mapping to Unicode3.0 later. * added fallback mapping of 0xA989-0xA995 <-> U+E7E7-U+E7F3. * some TTF - NSimSun(Microsoft GB18030 Support Package) and FZSongTi(Solaris GB18030 locale) - assign Vertical form(U+FE10-U+FE19) to UDA/PUA(0x2659-0x2673/U+E78D-U+E796), so comment about this. 1.3 Tue Aug 29 18:52:29 GMT 2006 tnozaki * updated 0xFE50-0xFEA0 mapping to Unicode3.0 later. * added fallback mapping of 0xA989-0xA995 <-> U+E7E7-U+E7F3. * some TTF - NSimSun(Microsoft GB18030 Support Package) and FZSongTi(Solaris GB18030 locale) - assign Vertical form(U+FE10-U+FE19) to UDA/PUA(0x2659-0x2673/U+E78D-U+E796), so comment about this. 1.3 Tue Aug 29 18:52:29 GMT 2006 tnozaki * updated 0xFE50-0xFEA0 mapping to Unicode3.0 later. * added fallback mapping of 0xA989-0xA995 <-> U+E7E7-U+E7F3. * some TTF - NSimSun(Microsoft GB18030 Support Package) and FZSongTi(Solaris GB18030 locale) - assign Vertical form(U+FE10-U+FE19) to UDA/PUA(0x2659-0x2673/U+E78D-U+E796), so comment about this. 1.3 Tue Aug 29 18:52:29 GMT 2006 tnozaki * updated 0xFE50-0xFEA0 mapping to Unicode3.0 later. * added fallback mapping of 0xA989-0xA995 <-> U+E7E7-U+E7F3. * some TTF - NSimSun(Microsoft GB18030 Support Package) and FZSongTi(Solaris GB18030 locale) - assign Vertical form(U+FE10-U+FE19) to UDA/PUA(0x2659-0x2673/U+E78D-U+E796), so comment about this. 1.3 Tue Aug 29 18:52:29 GMT 2006 tnozaki * updated 0xFE50-0xFEA0 mapping to Unicode3.0 later. * added fallback mapping of 0xA989-0xA995 <-> U+E7E7-U+E7F3. * some TTF - NSimSun(Microsoft GB18030 Support Package) and FZSongTi(Solaris GB18030 locale) - assign Vertical form(U+FE10-U+FE19) to UDA/PUA(0x2659-0x2673/U+E78D-U+E796), so comment about this. 1.3 Tue Aug 29 18:52:29 GMT 2006 tnozaki * updated 0xFE50-0xFEA0 mapping to Unicode3.0 later. * added fallback mapping of 0xA989-0xA995 <-> U+E7E7-U+E7F3. * some TTF - NSimSun(Microsoft GB18030 Support Package) and FZSongTi(Solaris GB18030 locale) - assign Vertical form(U+FE10-U+FE19) to UDA/PUA(0x2659-0x2673/U+E78D-U+E796), so comment about this. 1.2 Fri Aug 25 15:27:41 GMT 2006 tnozaki filled 0x577A-0x577E hole with PUA. 1.2 Fri Aug 25 15:27:41 GMT 2006 tnozaki filled 0x577A-0x577E hole with PUA. |
| /src/sys/external/gpl2/dts/dist/arch/arm/boot/dts/ | ||
| H A D | Makefile | 1.2 Sat May 04 02:21:49 GMT 2024 dyoung Add a device tree for the Red Pitaya SDRlab 122-16. To boot NetBSD on the 122-16, copy the .dtb built from zynq-red-pitays-122-16.dts, the first-stage bootloader (called boot.bin) and U-Boot that came with the 122-16 and a kernel image, netbsd.ub, built for earmv7hf to an MS-DOS partition on an MBR-partitioned SD card. At the U-Boot prompt, "Zynq> ", type these commands: i2c dev 0 eeprom read 0 0x50 0 0x1804 0x400 env import -b 0 0x400 hw_rev serial ethaddr setenv bootargs "root=ld0a" fatload mmc 0 0x01f00000 device~1.dtb fatload mmc 0 0x02000000 netbsd.ub fdt addr 0x01f00000 fdt set /axi/ethernet@e000b000 local-mac-address $ethaddr bootm 0x02000000 - 0x01f00000 Note that the ethernet PHY will not attach unless you have applied the patches from Lloyd Parkes in kern/58083. 1.2 Sat May 04 02:21:49 GMT 2024 dyoung Add a device tree for the Red Pitaya SDRlab 122-16. To boot NetBSD on the 122-16, copy the .dtb built from zynq-red-pitays-122-16.dts, the first-stage bootloader (called boot.bin) and U-Boot that came with the 122-16 and a kernel image, netbsd.ub, built for earmv7hf to an MS-DOS partition on an MBR-partitioned SD card. At the U-Boot prompt, "Zynq> ", type these commands: i2c dev 0 eeprom read 0 0x50 0 0x1804 0x400 env import -b 0 0x400 hw_rev serial ethaddr setenv bootargs "root=ld0a" fatload mmc 0 0x01f00000 device~1.dtb fatload mmc 0 0x02000000 netbsd.ub fdt addr 0x01f00000 fdt set /axi/ethernet@e000b000 local-mac-address $ethaddr bootm 0x02000000 - 0x01f00000 Note that the ethernet PHY will not attach unless you have applied the patches from Lloyd Parkes in kern/58083. 1.2 Sat May 04 02:21:49 GMT 2024 dyoung Add a device tree for the Red Pitaya SDRlab 122-16. To boot NetBSD on the 122-16, copy the .dtb built from zynq-red-pitays-122-16.dts, the first-stage bootloader (called boot.bin) and U-Boot that came with the 122-16 and a kernel image, netbsd.ub, built for earmv7hf to an MS-DOS partition on an MBR-partitioned SD card. At the U-Boot prompt, "Zynq> ", type these commands: i2c dev 0 eeprom read 0 0x50 0 0x1804 0x400 env import -b 0 0x400 hw_rev serial ethaddr setenv bootargs "root=ld0a" fatload mmc 0 0x01f00000 device~1.dtb fatload mmc 0 0x02000000 netbsd.ub fdt addr 0x01f00000 fdt set /axi/ethernet@e000b000 local-mac-address $ethaddr bootm 0x02000000 - 0x01f00000 Note that the ethernet PHY will not attach unless you have applied the patches from Lloyd Parkes in kern/58083. 1.2 Sat May 04 02:21:49 GMT 2024 dyoung Add a device tree for the Red Pitaya SDRlab 122-16. To boot NetBSD on the 122-16, copy the .dtb built from zynq-red-pitays-122-16.dts, the first-stage bootloader (called boot.bin) and U-Boot that came with the 122-16 and a kernel image, netbsd.ub, built for earmv7hf to an MS-DOS partition on an MBR-partitioned SD card. At the U-Boot prompt, "Zynq> ", type these commands: i2c dev 0 eeprom read 0 0x50 0 0x1804 0x400 env import -b 0 0x400 hw_rev serial ethaddr setenv bootargs "root=ld0a" fatload mmc 0 0x01f00000 device~1.dtb fatload mmc 0 0x02000000 netbsd.ub fdt addr 0x01f00000 fdt set /axi/ethernet@e000b000 local-mac-address $ethaddr bootm 0x02000000 - 0x01f00000 Note that the ethernet PHY will not attach unless you have applied the patches from Lloyd Parkes in kern/58083. 1.2 Sat May 04 02:21:49 GMT 2024 dyoung Add a device tree for the Red Pitaya SDRlab 122-16. To boot NetBSD on the 122-16, copy the .dtb built from zynq-red-pitays-122-16.dts, the first-stage bootloader (called boot.bin) and U-Boot that came with the 122-16 and a kernel image, netbsd.ub, built for earmv7hf to an MS-DOS partition on an MBR-partitioned SD card. At the U-Boot prompt, "Zynq> ", type these commands: i2c dev 0 eeprom read 0 0x50 0 0x1804 0x400 env import -b 0 0x400 hw_rev serial ethaddr setenv bootargs "root=ld0a" fatload mmc 0 0x01f00000 device~1.dtb fatload mmc 0 0x02000000 netbsd.ub fdt addr 0x01f00000 fdt set /axi/ethernet@e000b000 local-mac-address $ethaddr bootm 0x02000000 - 0x01f00000 Note that the ethernet PHY will not attach unless you have applied the patches from Lloyd Parkes in kern/58083. 1.2 Sat May 04 02:21:49 GMT 2024 dyoung Add a device tree for the Red Pitaya SDRlab 122-16. To boot NetBSD on the 122-16, copy the .dtb built from zynq-red-pitays-122-16.dts, the first-stage bootloader (called boot.bin) and U-Boot that came with the 122-16 and a kernel image, netbsd.ub, built for earmv7hf to an MS-DOS partition on an MBR-partitioned SD card. At the U-Boot prompt, "Zynq> ", type these commands: i2c dev 0 eeprom read 0 0x50 0 0x1804 0x400 env import -b 0 0x400 hw_rev serial ethaddr setenv bootargs "root=ld0a" fatload mmc 0 0x01f00000 device~1.dtb fatload mmc 0 0x02000000 netbsd.ub fdt addr 0x01f00000 fdt set /axi/ethernet@e000b000 local-mac-address $ethaddr bootm 0x02000000 - 0x01f00000 Note that the ethernet PHY will not attach unless you have applied the patches from Lloyd Parkes in kern/58083. 1.2 Sat May 04 02:21:49 GMT 2024 dyoung Add a device tree for the Red Pitaya SDRlab 122-16. To boot NetBSD on the 122-16, copy the .dtb built from zynq-red-pitays-122-16.dts, the first-stage bootloader (called boot.bin) and U-Boot that came with the 122-16 and a kernel image, netbsd.ub, built for earmv7hf to an MS-DOS partition on an MBR-partitioned SD card. At the U-Boot prompt, "Zynq> ", type these commands: i2c dev 0 eeprom read 0 0x50 0 0x1804 0x400 env import -b 0 0x400 hw_rev serial ethaddr setenv bootargs "root=ld0a" fatload mmc 0 0x01f00000 device~1.dtb fatload mmc 0 0x02000000 netbsd.ub fdt addr 0x01f00000 fdt set /axi/ethernet@e000b000 local-mac-address $ethaddr bootm 0x02000000 - 0x01f00000 Note that the ethernet PHY will not attach unless you have applied the patches from Lloyd Parkes in kern/58083. 1.2 Sat May 04 02:21:49 GMT 2024 dyoung Add a device tree for the Red Pitaya SDRlab 122-16. To boot NetBSD on the 122-16, copy the .dtb built from zynq-red-pitays-122-16.dts, the first-stage bootloader (called boot.bin) and U-Boot that came with the 122-16 and a kernel image, netbsd.ub, built for earmv7hf to an MS-DOS partition on an MBR-partitioned SD card. At the U-Boot prompt, "Zynq> ", type these commands: i2c dev 0 eeprom read 0 0x50 0 0x1804 0x400 env import -b 0 0x400 hw_rev serial ethaddr setenv bootargs "root=ld0a" fatload mmc 0 0x01f00000 device~1.dtb fatload mmc 0 0x02000000 netbsd.ub fdt addr 0x01f00000 fdt set /axi/ethernet@e000b000 local-mac-address $ethaddr bootm 0x02000000 - 0x01f00000 Note that the ethernet PHY will not attach unless you have applied the patches from Lloyd Parkes in kern/58083. 1.2 Sat May 04 02:21:49 GMT 2024 dyoung Add a device tree for the Red Pitaya SDRlab 122-16. To boot NetBSD on the 122-16, copy the .dtb built from zynq-red-pitays-122-16.dts, the first-stage bootloader (called boot.bin) and U-Boot that came with the 122-16 and a kernel image, netbsd.ub, built for earmv7hf to an MS-DOS partition on an MBR-partitioned SD card. At the U-Boot prompt, "Zynq> ", type these commands: i2c dev 0 eeprom read 0 0x50 0 0x1804 0x400 env import -b 0 0x400 hw_rev serial ethaddr setenv bootargs "root=ld0a" fatload mmc 0 0x01f00000 device~1.dtb fatload mmc 0 0x02000000 netbsd.ub fdt addr 0x01f00000 fdt set /axi/ethernet@e000b000 local-mac-address $ethaddr bootm 0x02000000 - 0x01f00000 Note that the ethernet PHY will not attach unless you have applied the patches from Lloyd Parkes in kern/58083. 1.2 Sat May 04 02:21:49 GMT 2024 dyoung Add a device tree for the Red Pitaya SDRlab 122-16. To boot NetBSD on the 122-16, copy the .dtb built from zynq-red-pitays-122-16.dts, the first-stage bootloader (called boot.bin) and U-Boot that came with the 122-16 and a kernel image, netbsd.ub, built for earmv7hf to an MS-DOS partition on an MBR-partitioned SD card. At the U-Boot prompt, "Zynq> ", type these commands: i2c dev 0 eeprom read 0 0x50 0 0x1804 0x400 env import -b 0 0x400 hw_rev serial ethaddr setenv bootargs "root=ld0a" fatload mmc 0 0x01f00000 device~1.dtb fatload mmc 0 0x02000000 netbsd.ub fdt addr 0x01f00000 fdt set /axi/ethernet@e000b000 local-mac-address $ethaddr bootm 0x02000000 - 0x01f00000 Note that the ethernet PHY will not attach unless you have applied the patches from Lloyd Parkes in kern/58083. 1.2 Sat May 04 02:21:49 GMT 2024 dyoung Add a device tree for the Red Pitaya SDRlab 122-16. To boot NetBSD on the 122-16, copy the .dtb built from zynq-red-pitays-122-16.dts, the first-stage bootloader (called boot.bin) and U-Boot that came with the 122-16 and a kernel image, netbsd.ub, built for earmv7hf to an MS-DOS partition on an MBR-partitioned SD card. At the U-Boot prompt, "Zynq> ", type these commands: i2c dev 0 eeprom read 0 0x50 0 0x1804 0x400 env import -b 0 0x400 hw_rev serial ethaddr setenv bootargs "root=ld0a" fatload mmc 0 0x01f00000 device~1.dtb fatload mmc 0 0x02000000 netbsd.ub fdt addr 0x01f00000 fdt set /axi/ethernet@e000b000 local-mac-address $ethaddr bootm 0x02000000 - 0x01f00000 Note that the ethernet PHY will not attach unless you have applied the patches from Lloyd Parkes in kern/58083. 1.2 Sat May 04 02:21:49 GMT 2024 dyoung Add a device tree for the Red Pitaya SDRlab 122-16. To boot NetBSD on the 122-16, copy the .dtb built from zynq-red-pitays-122-16.dts, the first-stage bootloader (called boot.bin) and U-Boot that came with the 122-16 and a kernel image, netbsd.ub, built for earmv7hf to an MS-DOS partition on an MBR-partitioned SD card. At the U-Boot prompt, "Zynq> ", type these commands: i2c dev 0 eeprom read 0 0x50 0 0x1804 0x400 env import -b 0 0x400 hw_rev serial ethaddr setenv bootargs "root=ld0a" fatload mmc 0 0x01f00000 device~1.dtb fatload mmc 0 0x02000000 netbsd.ub fdt addr 0x01f00000 fdt set /axi/ethernet@e000b000 local-mac-address $ethaddr bootm 0x02000000 - 0x01f00000 Note that the ethernet PHY will not attach unless you have applied the patches from Lloyd Parkes in kern/58083. 1.2 Sat May 04 02:21:49 GMT 2024 dyoung Add a device tree for the Red Pitaya SDRlab 122-16. To boot NetBSD on the 122-16, copy the .dtb built from zynq-red-pitays-122-16.dts, the first-stage bootloader (called boot.bin) and U-Boot that came with the 122-16 and a kernel image, netbsd.ub, built for earmv7hf to an MS-DOS partition on an MBR-partitioned SD card. At the U-Boot prompt, "Zynq> ", type these commands: i2c dev 0 eeprom read 0 0x50 0 0x1804 0x400 env import -b 0 0x400 hw_rev serial ethaddr setenv bootargs "root=ld0a" fatload mmc 0 0x01f00000 device~1.dtb fatload mmc 0 0x02000000 netbsd.ub fdt addr 0x01f00000 fdt set /axi/ethernet@e000b000 local-mac-address $ethaddr bootm 0x02000000 - 0x01f00000 Note that the ethernet PHY will not attach unless you have applied the patches from Lloyd Parkes in kern/58083. 1.2 Sat May 04 02:21:49 GMT 2024 dyoung Add a device tree for the Red Pitaya SDRlab 122-16. To boot NetBSD on the 122-16, copy the .dtb built from zynq-red-pitays-122-16.dts, the first-stage bootloader (called boot.bin) and U-Boot that came with the 122-16 and a kernel image, netbsd.ub, built for earmv7hf to an MS-DOS partition on an MBR-partitioned SD card. At the U-Boot prompt, "Zynq> ", type these commands: i2c dev 0 eeprom read 0 0x50 0 0x1804 0x400 env import -b 0 0x400 hw_rev serial ethaddr setenv bootargs "root=ld0a" fatload mmc 0 0x01f00000 device~1.dtb fatload mmc 0 0x02000000 netbsd.ub fdt addr 0x01f00000 fdt set /axi/ethernet@e000b000 local-mac-address $ethaddr bootm 0x02000000 - 0x01f00000 Note that the ethernet PHY will not attach unless you have applied the patches from Lloyd Parkes in kern/58083. 1.2 Sat May 04 02:21:49 GMT 2024 dyoung Add a device tree for the Red Pitaya SDRlab 122-16. To boot NetBSD on the 122-16, copy the .dtb built from zynq-red-pitays-122-16.dts, the first-stage bootloader (called boot.bin) and U-Boot that came with the 122-16 and a kernel image, netbsd.ub, built for earmv7hf to an MS-DOS partition on an MBR-partitioned SD card. At the U-Boot prompt, "Zynq> ", type these commands: i2c dev 0 eeprom read 0 0x50 0 0x1804 0x400 env import -b 0 0x400 hw_rev serial ethaddr setenv bootargs "root=ld0a" fatload mmc 0 0x01f00000 device~1.dtb fatload mmc 0 0x02000000 netbsd.ub fdt addr 0x01f00000 fdt set /axi/ethernet@e000b000 local-mac-address $ethaddr bootm 0x02000000 - 0x01f00000 Note that the ethernet PHY will not attach unless you have applied the patches from Lloyd Parkes in kern/58083. |
| /src/sys/arch/arm/dts/ | ||
| H A D | zynq-red-pitaya-122-16.dts | 1.1 Sat May 04 02:21:48 GMT 2024 dyoung Add a device tree for the Red Pitaya SDRlab 122-16. To boot NetBSD on the 122-16, copy the .dtb built from zynq-red-pitays-122-16.dts, the first-stage bootloader (called boot.bin) and U-Boot that came with the 122-16 and a kernel image, netbsd.ub, built for earmv7hf to an MS-DOS partition on an MBR-partitioned SD card. At the U-Boot prompt, "Zynq> ", type these commands: i2c dev 0 eeprom read 0 0x50 0 0x1804 0x400 env import -b 0 0x400 hw_rev serial ethaddr setenv bootargs "root=ld0a" fatload mmc 0 0x01f00000 device~1.dtb fatload mmc 0 0x02000000 netbsd.ub fdt addr 0x01f00000 fdt set /axi/ethernet@e000b000 local-mac-address $ethaddr bootm 0x02000000 - 0x01f00000 Note that the ethernet PHY will not attach unless you have applied the patches from Lloyd Parkes in kern/58083. 1.1 Sat May 04 02:21:48 GMT 2024 dyoung Add a device tree for the Red Pitaya SDRlab 122-16. To boot NetBSD on the 122-16, copy the .dtb built from zynq-red-pitays-122-16.dts, the first-stage bootloader (called boot.bin) and U-Boot that came with the 122-16 and a kernel image, netbsd.ub, built for earmv7hf to an MS-DOS partition on an MBR-partitioned SD card. At the U-Boot prompt, "Zynq> ", type these commands: i2c dev 0 eeprom read 0 0x50 0 0x1804 0x400 env import -b 0 0x400 hw_rev serial ethaddr setenv bootargs "root=ld0a" fatload mmc 0 0x01f00000 device~1.dtb fatload mmc 0 0x02000000 netbsd.ub fdt addr 0x01f00000 fdt set /axi/ethernet@e000b000 local-mac-address $ethaddr bootm 0x02000000 - 0x01f00000 Note that the ethernet PHY will not attach unless you have applied the patches from Lloyd Parkes in kern/58083. 1.1 Sat May 04 02:21:48 GMT 2024 dyoung Add a device tree for the Red Pitaya SDRlab 122-16. To boot NetBSD on the 122-16, copy the .dtb built from zynq-red-pitays-122-16.dts, the first-stage bootloader (called boot.bin) and U-Boot that came with the 122-16 and a kernel image, netbsd.ub, built for earmv7hf to an MS-DOS partition on an MBR-partitioned SD card. At the U-Boot prompt, "Zynq> ", type these commands: i2c dev 0 eeprom read 0 0x50 0 0x1804 0x400 env import -b 0 0x400 hw_rev serial ethaddr setenv bootargs "root=ld0a" fatload mmc 0 0x01f00000 device~1.dtb fatload mmc 0 0x02000000 netbsd.ub fdt addr 0x01f00000 fdt set /axi/ethernet@e000b000 local-mac-address $ethaddr bootm 0x02000000 - 0x01f00000 Note that the ethernet PHY will not attach unless you have applied the patches from Lloyd Parkes in kern/58083. 1.1 Sat May 04 02:21:48 GMT 2024 dyoung Add a device tree for the Red Pitaya SDRlab 122-16. To boot NetBSD on the 122-16, copy the .dtb built from zynq-red-pitays-122-16.dts, the first-stage bootloader (called boot.bin) and U-Boot that came with the 122-16 and a kernel image, netbsd.ub, built for earmv7hf to an MS-DOS partition on an MBR-partitioned SD card. At the U-Boot prompt, "Zynq> ", type these commands: i2c dev 0 eeprom read 0 0x50 0 0x1804 0x400 env import -b 0 0x400 hw_rev serial ethaddr setenv bootargs "root=ld0a" fatload mmc 0 0x01f00000 device~1.dtb fatload mmc 0 0x02000000 netbsd.ub fdt addr 0x01f00000 fdt set /axi/ethernet@e000b000 local-mac-address $ethaddr bootm 0x02000000 - 0x01f00000 Note that the ethernet PHY will not attach unless you have applied the patches from Lloyd Parkes in kern/58083. 1.1 Sat May 04 02:21:48 GMT 2024 dyoung Add a device tree for the Red Pitaya SDRlab 122-16. To boot NetBSD on the 122-16, copy the .dtb built from zynq-red-pitays-122-16.dts, the first-stage bootloader (called boot.bin) and U-Boot that came with the 122-16 and a kernel image, netbsd.ub, built for earmv7hf to an MS-DOS partition on an MBR-partitioned SD card. At the U-Boot prompt, "Zynq> ", type these commands: i2c dev 0 eeprom read 0 0x50 0 0x1804 0x400 env import -b 0 0x400 hw_rev serial ethaddr setenv bootargs "root=ld0a" fatload mmc 0 0x01f00000 device~1.dtb fatload mmc 0 0x02000000 netbsd.ub fdt addr 0x01f00000 fdt set /axi/ethernet@e000b000 local-mac-address $ethaddr bootm 0x02000000 - 0x01f00000 Note that the ethernet PHY will not attach unless you have applied the patches from Lloyd Parkes in kern/58083. 1.1 Sat May 04 02:21:48 GMT 2024 dyoung Add a device tree for the Red Pitaya SDRlab 122-16. To boot NetBSD on the 122-16, copy the .dtb built from zynq-red-pitays-122-16.dts, the first-stage bootloader (called boot.bin) and U-Boot that came with the 122-16 and a kernel image, netbsd.ub, built for earmv7hf to an MS-DOS partition on an MBR-partitioned SD card. At the U-Boot prompt, "Zynq> ", type these commands: i2c dev 0 eeprom read 0 0x50 0 0x1804 0x400 env import -b 0 0x400 hw_rev serial ethaddr setenv bootargs "root=ld0a" fatload mmc 0 0x01f00000 device~1.dtb fatload mmc 0 0x02000000 netbsd.ub fdt addr 0x01f00000 fdt set /axi/ethernet@e000b000 local-mac-address $ethaddr bootm 0x02000000 - 0x01f00000 Note that the ethernet PHY will not attach unless you have applied the patches from Lloyd Parkes in kern/58083. 1.1 Sat May 04 02:21:48 GMT 2024 dyoung Add a device tree for the Red Pitaya SDRlab 122-16. To boot NetBSD on the 122-16, copy the .dtb built from zynq-red-pitays-122-16.dts, the first-stage bootloader (called boot.bin) and U-Boot that came with the 122-16 and a kernel image, netbsd.ub, built for earmv7hf to an MS-DOS partition on an MBR-partitioned SD card. At the U-Boot prompt, "Zynq> ", type these commands: i2c dev 0 eeprom read 0 0x50 0 0x1804 0x400 env import -b 0 0x400 hw_rev serial ethaddr setenv bootargs "root=ld0a" fatload mmc 0 0x01f00000 device~1.dtb fatload mmc 0 0x02000000 netbsd.ub fdt addr 0x01f00000 fdt set /axi/ethernet@e000b000 local-mac-address $ethaddr bootm 0x02000000 - 0x01f00000 Note that the ethernet PHY will not attach unless you have applied the patches from Lloyd Parkes in kern/58083. 1.1 Sat May 04 02:21:48 GMT 2024 dyoung Add a device tree for the Red Pitaya SDRlab 122-16. To boot NetBSD on the 122-16, copy the .dtb built from zynq-red-pitays-122-16.dts, the first-stage bootloader (called boot.bin) and U-Boot that came with the 122-16 and a kernel image, netbsd.ub, built for earmv7hf to an MS-DOS partition on an MBR-partitioned SD card. At the U-Boot prompt, "Zynq> ", type these commands: i2c dev 0 eeprom read 0 0x50 0 0x1804 0x400 env import -b 0 0x400 hw_rev serial ethaddr setenv bootargs "root=ld0a" fatload mmc 0 0x01f00000 device~1.dtb fatload mmc 0 0x02000000 netbsd.ub fdt addr 0x01f00000 fdt set /axi/ethernet@e000b000 local-mac-address $ethaddr bootm 0x02000000 - 0x01f00000 Note that the ethernet PHY will not attach unless you have applied the patches from Lloyd Parkes in kern/58083. 1.1 Sat May 04 02:21:48 GMT 2024 dyoung Add a device tree for the Red Pitaya SDRlab 122-16. To boot NetBSD on the 122-16, copy the .dtb built from zynq-red-pitays-122-16.dts, the first-stage bootloader (called boot.bin) and U-Boot that came with the 122-16 and a kernel image, netbsd.ub, built for earmv7hf to an MS-DOS partition on an MBR-partitioned SD card. At the U-Boot prompt, "Zynq> ", type these commands: i2c dev 0 eeprom read 0 0x50 0 0x1804 0x400 env import -b 0 0x400 hw_rev serial ethaddr setenv bootargs "root=ld0a" fatload mmc 0 0x01f00000 device~1.dtb fatload mmc 0 0x02000000 netbsd.ub fdt addr 0x01f00000 fdt set /axi/ethernet@e000b000 local-mac-address $ethaddr bootm 0x02000000 - 0x01f00000 Note that the ethernet PHY will not attach unless you have applied the patches from Lloyd Parkes in kern/58083. 1.1 Sat May 04 02:21:48 GMT 2024 dyoung Add a device tree for the Red Pitaya SDRlab 122-16. To boot NetBSD on the 122-16, copy the .dtb built from zynq-red-pitays-122-16.dts, the first-stage bootloader (called boot.bin) and U-Boot that came with the 122-16 and a kernel image, netbsd.ub, built for earmv7hf to an MS-DOS partition on an MBR-partitioned SD card. At the U-Boot prompt, "Zynq> ", type these commands: i2c dev 0 eeprom read 0 0x50 0 0x1804 0x400 env import -b 0 0x400 hw_rev serial ethaddr setenv bootargs "root=ld0a" fatload mmc 0 0x01f00000 device~1.dtb fatload mmc 0 0x02000000 netbsd.ub fdt addr 0x01f00000 fdt set /axi/ethernet@e000b000 local-mac-address $ethaddr bootm 0x02000000 - 0x01f00000 Note that the ethernet PHY will not attach unless you have applied the patches from Lloyd Parkes in kern/58083. 1.1 Sat May 04 02:21:48 GMT 2024 dyoung Add a device tree for the Red Pitaya SDRlab 122-16. To boot NetBSD on the 122-16, copy the .dtb built from zynq-red-pitays-122-16.dts, the first-stage bootloader (called boot.bin) and U-Boot that came with the 122-16 and a kernel image, netbsd.ub, built for earmv7hf to an MS-DOS partition on an MBR-partitioned SD card. At the U-Boot prompt, "Zynq> ", type these commands: i2c dev 0 eeprom read 0 0x50 0 0x1804 0x400 env import -b 0 0x400 hw_rev serial ethaddr setenv bootargs "root=ld0a" fatload mmc 0 0x01f00000 device~1.dtb fatload mmc 0 0x02000000 netbsd.ub fdt addr 0x01f00000 fdt set /axi/ethernet@e000b000 local-mac-address $ethaddr bootm 0x02000000 - 0x01f00000 Note that the ethernet PHY will not attach unless you have applied the patches from Lloyd Parkes in kern/58083. 1.1 Sat May 04 02:21:48 GMT 2024 dyoung Add a device tree for the Red Pitaya SDRlab 122-16. To boot NetBSD on the 122-16, copy the .dtb built from zynq-red-pitays-122-16.dts, the first-stage bootloader (called boot.bin) and U-Boot that came with the 122-16 and a kernel image, netbsd.ub, built for earmv7hf to an MS-DOS partition on an MBR-partitioned SD card. At the U-Boot prompt, "Zynq> ", type these commands: i2c dev 0 eeprom read 0 0x50 0 0x1804 0x400 env import -b 0 0x400 hw_rev serial ethaddr setenv bootargs "root=ld0a" fatload mmc 0 0x01f00000 device~1.dtb fatload mmc 0 0x02000000 netbsd.ub fdt addr 0x01f00000 fdt set /axi/ethernet@e000b000 local-mac-address $ethaddr bootm 0x02000000 - 0x01f00000 Note that the ethernet PHY will not attach unless you have applied the patches from Lloyd Parkes in kern/58083. 1.1 Sat May 04 02:21:48 GMT 2024 dyoung Add a device tree for the Red Pitaya SDRlab 122-16. To boot NetBSD on the 122-16, copy the .dtb built from zynq-red-pitays-122-16.dts, the first-stage bootloader (called boot.bin) and U-Boot that came with the 122-16 and a kernel image, netbsd.ub, built for earmv7hf to an MS-DOS partition on an MBR-partitioned SD card. At the U-Boot prompt, "Zynq> ", type these commands: i2c dev 0 eeprom read 0 0x50 0 0x1804 0x400 env import -b 0 0x400 hw_rev serial ethaddr setenv bootargs "root=ld0a" fatload mmc 0 0x01f00000 device~1.dtb fatload mmc 0 0x02000000 netbsd.ub fdt addr 0x01f00000 fdt set /axi/ethernet@e000b000 local-mac-address $ethaddr bootm 0x02000000 - 0x01f00000 Note that the ethernet PHY will not attach unless you have applied the patches from Lloyd Parkes in kern/58083. 1.1 Sat May 04 02:21:48 GMT 2024 dyoung Add a device tree for the Red Pitaya SDRlab 122-16. To boot NetBSD on the 122-16, copy the .dtb built from zynq-red-pitays-122-16.dts, the first-stage bootloader (called boot.bin) and U-Boot that came with the 122-16 and a kernel image, netbsd.ub, built for earmv7hf to an MS-DOS partition on an MBR-partitioned SD card. At the U-Boot prompt, "Zynq> ", type these commands: i2c dev 0 eeprom read 0 0x50 0 0x1804 0x400 env import -b 0 0x400 hw_rev serial ethaddr setenv bootargs "root=ld0a" fatload mmc 0 0x01f00000 device~1.dtb fatload mmc 0 0x02000000 netbsd.ub fdt addr 0x01f00000 fdt set /axi/ethernet@e000b000 local-mac-address $ethaddr bootm 0x02000000 - 0x01f00000 Note that the ethernet PHY will not attach unless you have applied the patches from Lloyd Parkes in kern/58083. 1.1 Sat May 04 02:21:48 GMT 2024 dyoung Add a device tree for the Red Pitaya SDRlab 122-16. To boot NetBSD on the 122-16, copy the .dtb built from zynq-red-pitays-122-16.dts, the first-stage bootloader (called boot.bin) and U-Boot that came with the 122-16 and a kernel image, netbsd.ub, built for earmv7hf to an MS-DOS partition on an MBR-partitioned SD card. At the U-Boot prompt, "Zynq> ", type these commands: i2c dev 0 eeprom read 0 0x50 0 0x1804 0x400 env import -b 0 0x400 hw_rev serial ethaddr setenv bootargs "root=ld0a" fatload mmc 0 0x01f00000 device~1.dtb fatload mmc 0 0x02000000 netbsd.ub fdt addr 0x01f00000 fdt set /axi/ethernet@e000b000 local-mac-address $ethaddr bootm 0x02000000 - 0x01f00000 Note that the ethernet PHY will not attach unless you have applied the patches from Lloyd Parkes in kern/58083. |
| /src/tests/lib/libc/stdlib/ | ||
| H A D | t_strtoi.c | 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } 1.4 Wed Jul 24 08:59:11 GMT 2024 kre /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include <sys/cdefs.h> __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include <atf-c.h> #include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <limits.h> struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, " "&rstatus) failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus)" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", &end, %d, %jd, %jd, &rstatus), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "111010110111100110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "20130035113", 123456789, 6, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "3026236221", 123456789, 7, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "726746425", 123456789, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "277266780", 123456789, 9, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "63762A05", 123456789, 11, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "35418A99", 123456789, 12, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1C767471", 123456789, 13, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "12579781", 123456789, 14, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "AC89BC9", 123456789, 15, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "75BCD15", 123456789, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "1234567", 342391, 8, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "01234567", 342391, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0123456789", 123456789, 10, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0x75bcd15", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, }; struct test f[] = { { "1", 0, 1, "1", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "2", 0, -1, "2", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "3", 0, 37, "3", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "4", 0, -1, "4", INTMAX_MIN, INTMAX_MAX, EINVAL }, { "0x", 0, 0, "x", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } for (i = 0; i < __arraycount(f); i++) { end = NULL; errno = 0; e = -99; rv = strtoi(f[i].str, &end, f[i].base, f[i].lo, f[i].hi, &e); check_errno(errno); check(&f[i], rv, end, e); } } ATF_TC(strtoi_case); ATF_TC_HEAD(strtoi_case, tc) { atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)"); } ATF_TC_BODY(strtoi_case, tc) { struct test t[] = { { "abcd", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " dcba", 0xdcba, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "abcd dcba", 0xabcd, 16, " dcba", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abc0x123", 0xabc0, 16, "x123", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "abcd\0x123", 0xabcd, 16, "\0x123", INTMAX_MIN, INTMAX_MAX, 0 }, { "ABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "aBcD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCD", 0xabcd, 16, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "0xABCDX", 0xabcd, 16, "X", INTMAX_MIN, INTMAX_MAX, ENOTSUP}, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range); ATF_TC_HEAD(strtoi_range, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)"); } ATF_TC_BODY(strtoi_range, tc) { struct test t[] = { #if INTMAX_MAX == 0x7fffffffffffffff { "1000000000000000000000", INTMAX_MAX, 8, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "9223372036854775808", INTMAX_MAX, 10, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, { "8000000000000000", INTMAX_MAX, 16, NULL, INTMAX_MIN, INTMAX_MAX, ERANGE }, #else #error extend this test to your platform! #endif { "10", 1, 10, NULL, -1, 1, ERANGE }, { "10", 11, 10, NULL, 11, 20, ERANGE }, { "7", 7, 0, NULL, 7, 7, 0 }, { "6", 7, 0, NULL, 7, 7, ERANGE }, { "8", 7, 0, NULL, 7, 7, ERANGE }, { "7x", 7, 0, "x", 7, 7, ENOTSUP }, { "8x", 7, 0, "x", 7, 7, ERANGE }, { "Z", 11, 10, "Z", 11, 20, ECANCELED }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); if (errno != 0) atf_tc_fail("Range test %zd set errno=%d", i, errno); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_range_trail); ATF_TC_HEAD(strtoi_range_trail, tc) { atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3) " "with trailing characters"); } ATF_TC_BODY(strtoi_range_trail, tc) { struct test t[] = { { "11x", 9, 10, "x", 0, 9, ERANGE }, { " -3y", -2, 10, "y", -2, 1, ERANGE }, { "11111z", 9, 10, "z", 0, 9, ERANGE }, { "+0xAq", 9, 16, "q", 0, 9, ERANGE }, { "-0xBAr", 0, 16, "r", 0, 9, ERANGE }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TC(strtoi_signed); ATF_TC_HEAD(strtoi_signed, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)"); } ATF_TC_BODY(strtoi_signed, tc) { struct test t[] = { { "1", 1, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 2", 2, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " 3", 3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { " -3", -3, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "--1", 0, 0, "--1", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+-2", 0, 0, "+-2", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "++3", 0, 0, "++3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+9", 9, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "+123", 123, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "-1 3", -1, 0, " 3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "-1.3", -1, 0, ".3", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "- 3", 0, 0, "- 3", INTMAX_MIN, INTMAX_MAX, ECANCELED }, { "+33.", 33, 0, ".", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, { "30x0", 30, 0, "x0", INTMAX_MIN, INTMAX_MAX, ENOTSUP }, }; intmax_t rv; char *end; int e; size_t i; for (i = 0; i < __arraycount(t); i++) { errno = 0; rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e); check_errno(errno); check(&t[i], rv, end, e); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtoi_base); ATF_TP_ADD_TC(tp, strtoi_case); ATF_TP_ADD_TC(tp, strtoi_range); ATF_TP_ADD_TC(tp, strtoi_range_trail); ATF_TP_ADD_TC(tp, strtoi_signed); return atf_no_error(); } |
| /src/sys/arch/i386/i386/ | ||
| H A D | db_machdep.c | 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) 1.5 Sat Jan 11 17:11:50 GMT 2014 christos branches: 1.5.6; stop ddb backtrace at Xsoftintr() (Richard Hansen) Stop unwinding frames when db_stack_trace_print() encouters Xsoftintr(). This avoids a recursive panic() due to an invalid pointer dereference when a software interrupt panic()s. Here's what happens without this change: When db_stack_trace_print() runs during a panic() and db_nextframe() encounters the Xsoftintr() frame, db_nextframe() does the following at db_machdep.c:292: 1. checks to see if there's a Xsoftintr() symbol (there is) 2. checks to see if the frame corresponds to an interrupt (the symbol name begins with "Xsoft" so it does) If both of the above are true (they are), db_nextframe() at db_machdep.c:303 tries to get a pointer to a struct intrframe. According to the comment at line 300, the second argument passed to Xsoftintr() is a pointer to a struct intrframe. However, the comment and the corresponding code are not correct -- Xsoftintr() doesn't take any arguments[1]. Attempting to fetch the second argument only yields stack garbage, not a struct intrframe. This causes db_machdep.c:307 to dereference a bad pointer, triggering the recursive panic(). [1] Xsoftintr() is called by Xspllower() which is called by splx() a.k.a. spllower(). Neither Xspllower() nor Xsoftintr() set up a standard frame when called (they don't do 'pushl %ebp; movl %esp, %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp. This makes splx()'s arguments look like Xsoftintr()'s arguments, and splx() does not take any arguments. You can reproduce the recursive panic by reverting this change and adding a call to panic() inside ipintr(). The backtrace will look like the following (the line numbers you see might differ from these line numbers -- this backtrace was generated from a slightly modified version of the NetBSD 6.1 kernel): #0 vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211 #1 0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205 #2 0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396 #3 0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983 #4 0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72 #5 0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308 #6 0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275 #7 0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296 #8 0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205 #9 0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369 #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543 #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825 #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390 #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615 #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164 #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821 #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371 #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350 #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61 #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179 #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160 Backtrace stopped: previous frame inner to this frame (corrupt stack?) |
| /src/sys/arch/riscv/conf/ | ||
| H A D | files.riscv | 1.10 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.10 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.10 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.10 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.10 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.10 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.10 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.10 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.10 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.10 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.10 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.10 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.10 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.10 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.10 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.10 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.10 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.10 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.10 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.10 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.10 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.10 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.10 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.10 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.10 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.10 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.10 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.10 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.10 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.10 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.10 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.10 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.10 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.10 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.10 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.10 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> |
| /src/sys/arch/riscv/include/ | ||
| H A D | db_machdep.h | 1.6 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.6 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.6 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.6 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.6 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.6 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.6 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.6 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.6 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.6 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.6 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.6 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.6 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.6 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.6 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.6 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.6 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.6 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.6 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.6 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.6 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.6 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.6 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.6 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.6 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.6 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.6 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.6 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.6 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.6 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.6 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.6 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.6 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.6 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.6 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> 1.6 Tue Sep 27 08:18:21 GMT 2022 skrll Basic ddb and backtrace support. [ 1.0000000] panic: kernel diagnostic assertion "msgbufaddr != 0" failed: file "/home/nick/netbsd/nbcvs/src/sys/arch/riscv/riscv/riscv_machdep.c", line 564 [ 1.0000000] cpu0: Begin traceback... [ 1.0000000] trace fp ffffffc000801dd0 [ 1.0000000] fp ffffffc000801e10 ?() at ffffffc0001eee98 [ 1.0000000] fp ffffffc000801e30 ?() at ffffffc0002ad984 [ 1.0000000] fp ffffffc000801ee0 ?() at ffffffc000005430 [ 1.0000000] cpu0: End traceback... [ 1.0000000] Trapframe @ 0xffffffc000801cb0 (cause=3 (breakpoint), status=0x100, pc=0xffffffc0000007e4, va=0): [ 1.0000000] ra =0xffffffc0001eee9c, sp =0xffffffc000801dd0, gp =0xffffffc0006a8f40, tp = 0 [ 1.0000000] s0 =0xffffffc000600ac0, s1 = 0x1000, s2 =0xffffffc000438df0, s3 =0xffffffc000801d80 [ 1.0000000] s4 =0xffffffc0001eed78, s5 =0xffffffc0006d55f8, s6 =0xffffffc000801d88, s7 =0xffffffc0006dfdb8 [ 1.0000000] s8 =0xffffffc000428c18, s9 =0xffffffc000801dd0, s10=0xffffffc0000a3822, s11=0xffffffc0006d55f8 [ 1.0000000] a0 = 0x17, a1 = 0xa, a2 = 0, a3 =0xffffffc00041f658 [ 1.0000000] a4 = 0, a5 = 0x1, a5 = 0, a7 = 0x1 [ 1.0000000] t0 =0xffffffc0006dfe30, t1 =0xffffffc000801bb8, t2 =0xffffffc000803000, t3 = 0x75 [ 1.0000000] t4 = 0, t5 = 0x63, t6 = 0x1 [ 1.0000000] kernel: breakpoint Stopped in pid 0.0 (system) at ffffffc0000007e4: c.ebreak db> |
| /src/sys/dev/pci/ | ||
| H A D | ppbvar.h | 1.2 Tue Apr 18 05:21:34 GMT 2017 msaitoh branches: 1.2.2; 1.2.4; 1.2.12; 1.2.16; 1.2.32; Enable PCIe's interrupt as much as possilbe in ppb(4) to detect and count status change event. HotPlug function itself have not implemented yet. - Interrupt and each event are counted by evcnt(9). Example: ppb0 Interrupt 0 0 intr ppb0 Attention Button Pressed 0 0 misc ppb0 Power Fault Detected 0 0 misc ppb0 MRL Sensor Changed 0 0 misc ppb0 Presence Detect Changed 0 0 misc ppb0 Command Completed 0 0 misc ppb0 Data Link Layer State Changed 0 0 misc - Print message if ppb_printevent is not zero. The default vaule is 0. The output messages: Attention Button Pressed Power Fault Detected MRL Sensor Changed Presence Detect Changed Command Completed Data Link Layer State Changed - Remove workaround code to disable interrupt (ppb.c rev. 1.35). Tested with Dell Latitude 2120 without if_bge.c rev. 1.304's workaround. dmesg when bge's device timeout occured: ppb3: Presence Detect Changed ppb3: Data Link Layer State Changed ppb3: Presence Detect Changed vmstat -e |grep ppb ppb3 Interrupt 2 0 intr ppb3 Presence Detect Changed 2 0 misc ppb3 Data Link Layer State Changed 1 0 misc 1.2 Tue Apr 18 05:21:34 GMT 2017 msaitoh branches: 1.2.2; 1.2.4; 1.2.12; 1.2.16; 1.2.32; Enable PCIe's interrupt as much as possilbe in ppb(4) to detect and count status change event. HotPlug function itself have not implemented yet. - Interrupt and each event are counted by evcnt(9). Example: ppb0 Interrupt 0 0 intr ppb0 Attention Button Pressed 0 0 misc ppb0 Power Fault Detected 0 0 misc ppb0 MRL Sensor Changed 0 0 misc ppb0 Presence Detect Changed 0 0 misc ppb0 Command Completed 0 0 misc ppb0 Data Link Layer State Changed 0 0 misc - Print message if ppb_printevent is not zero. The default vaule is 0. The output messages: Attention Button Pressed Power Fault Detected MRL Sensor Changed Presence Detect Changed Command Completed Data Link Layer State Changed - Remove workaround code to disable interrupt (ppb.c rev. 1.35). Tested with Dell Latitude 2120 without if_bge.c rev. 1.304's workaround. dmesg when bge's device timeout occured: ppb3: Presence Detect Changed ppb3: Data Link Layer State Changed ppb3: Presence Detect Changed vmstat -e |grep ppb ppb3 Interrupt 2 0 intr ppb3 Presence Detect Changed 2 0 misc ppb3 Data Link Layer State Changed 1 0 misc 1.2 Tue Apr 18 05:21:34 GMT 2017 msaitoh branches: 1.2.2; 1.2.4; 1.2.12; 1.2.16; 1.2.32; Enable PCIe's interrupt as much as possilbe in ppb(4) to detect and count status change event. HotPlug function itself have not implemented yet. - Interrupt and each event are counted by evcnt(9). Example: ppb0 Interrupt 0 0 intr ppb0 Attention Button Pressed 0 0 misc ppb0 Power Fault Detected 0 0 misc ppb0 MRL Sensor Changed 0 0 misc ppb0 Presence Detect Changed 0 0 misc ppb0 Command Completed 0 0 misc ppb0 Data Link Layer State Changed 0 0 misc - Print message if ppb_printevent is not zero. The default vaule is 0. The output messages: Attention Button Pressed Power Fault Detected MRL Sensor Changed Presence Detect Changed Command Completed Data Link Layer State Changed - Remove workaround code to disable interrupt (ppb.c rev. 1.35). Tested with Dell Latitude 2120 without if_bge.c rev. 1.304's workaround. dmesg when bge's device timeout occured: ppb3: Presence Detect Changed ppb3: Data Link Layer State Changed ppb3: Presence Detect Changed vmstat -e |grep ppb ppb3 Interrupt 2 0 intr ppb3 Presence Detect Changed 2 0 misc ppb3 Data Link Layer State Changed 1 0 misc 1.2 Tue Apr 18 05:21:34 GMT 2017 msaitoh branches: 1.2.2; 1.2.4; 1.2.12; 1.2.16; 1.2.32; Enable PCIe's interrupt as much as possilbe in ppb(4) to detect and count status change event. HotPlug function itself have not implemented yet. - Interrupt and each event are counted by evcnt(9). Example: ppb0 Interrupt 0 0 intr ppb0 Attention Button Pressed 0 0 misc ppb0 Power Fault Detected 0 0 misc ppb0 MRL Sensor Changed 0 0 misc ppb0 Presence Detect Changed 0 0 misc ppb0 Command Completed 0 0 misc ppb0 Data Link Layer State Changed 0 0 misc - Print message if ppb_printevent is not zero. The default vaule is 0. The output messages: Attention Button Pressed Power Fault Detected MRL Sensor Changed Presence Detect Changed Command Completed Data Link Layer State Changed - Remove workaround code to disable interrupt (ppb.c rev. 1.35). Tested with Dell Latitude 2120 without if_bge.c rev. 1.304's workaround. dmesg when bge's device timeout occured: ppb3: Presence Detect Changed ppb3: Data Link Layer State Changed ppb3: Presence Detect Changed vmstat -e |grep ppb ppb3 Interrupt 2 0 intr ppb3 Presence Detect Changed 2 0 misc ppb3 Data Link Layer State Changed 1 0 misc 1.2 Tue Apr 18 05:21:34 GMT 2017 msaitoh branches: 1.2.2; 1.2.4; 1.2.12; 1.2.16; 1.2.32; Enable PCIe's interrupt as much as possilbe in ppb(4) to detect and count status change event. HotPlug function itself have not implemented yet. - Interrupt and each event are counted by evcnt(9). Example: ppb0 Interrupt 0 0 intr ppb0 Attention Button Pressed 0 0 misc ppb0 Power Fault Detected 0 0 misc ppb0 MRL Sensor Changed 0 0 misc ppb0 Presence Detect Changed 0 0 misc ppb0 Command Completed 0 0 misc ppb0 Data Link Layer State Changed 0 0 misc - Print message if ppb_printevent is not zero. The default vaule is 0. The output messages: Attention Button Pressed Power Fault Detected MRL Sensor Changed Presence Detect Changed Command Completed Data Link Layer State Changed - Remove workaround code to disable interrupt (ppb.c rev. 1.35). Tested with Dell Latitude 2120 without if_bge.c rev. 1.304's workaround. dmesg when bge's device timeout occured: ppb3: Presence Detect Changed ppb3: Data Link Layer State Changed ppb3: Presence Detect Changed vmstat -e |grep ppb ppb3 Interrupt 2 0 intr ppb3 Presence Detect Changed 2 0 misc ppb3 Data Link Layer State Changed 1 0 misc 1.2 Tue Apr 18 05:21:34 GMT 2017 msaitoh branches: 1.2.2; 1.2.4; 1.2.12; 1.2.16; 1.2.32; Enable PCIe's interrupt as much as possilbe in ppb(4) to detect and count status change event. HotPlug function itself have not implemented yet. - Interrupt and each event are counted by evcnt(9). Example: ppb0 Interrupt 0 0 intr ppb0 Attention Button Pressed 0 0 misc ppb0 Power Fault Detected 0 0 misc ppb0 MRL Sensor Changed 0 0 misc ppb0 Presence Detect Changed 0 0 misc ppb0 Command Completed 0 0 misc ppb0 Data Link Layer State Changed 0 0 misc - Print message if ppb_printevent is not zero. The default vaule is 0. The output messages: Attention Button Pressed Power Fault Detected MRL Sensor Changed Presence Detect Changed Command Completed Data Link Layer State Changed - Remove workaround code to disable interrupt (ppb.c rev. 1.35). Tested with Dell Latitude 2120 without if_bge.c rev. 1.304's workaround. dmesg when bge's device timeout occured: ppb3: Presence Detect Changed ppb3: Data Link Layer State Changed ppb3: Presence Detect Changed vmstat -e |grep ppb ppb3 Interrupt 2 0 intr ppb3 Presence Detect Changed 2 0 misc ppb3 Data Link Layer State Changed 1 0 misc 1.2 Tue Apr 18 05:21:34 GMT 2017 msaitoh branches: 1.2.2; 1.2.4; 1.2.12; 1.2.16; 1.2.32; Enable PCIe's interrupt as much as possilbe in ppb(4) to detect and count status change event. HotPlug function itself have not implemented yet. - Interrupt and each event are counted by evcnt(9). Example: ppb0 Interrupt 0 0 intr ppb0 Attention Button Pressed 0 0 misc ppb0 Power Fault Detected 0 0 misc ppb0 MRL Sensor Changed 0 0 misc ppb0 Presence Detect Changed 0 0 misc ppb0 Command Completed 0 0 misc ppb0 Data Link Layer State Changed 0 0 misc - Print message if ppb_printevent is not zero. The default vaule is 0. The output messages: Attention Button Pressed Power Fault Detected MRL Sensor Changed Presence Detect Changed Command Completed Data Link Layer State Changed - Remove workaround code to disable interrupt (ppb.c rev. 1.35). Tested with Dell Latitude 2120 without if_bge.c rev. 1.304's workaround. dmesg when bge's device timeout occured: ppb3: Presence Detect Changed ppb3: Data Link Layer State Changed ppb3: Presence Detect Changed vmstat -e |grep ppb ppb3 Interrupt 2 0 intr ppb3 Presence Detect Changed 2 0 misc ppb3 Data Link Layer State Changed 1 0 misc 1.2 Tue Apr 18 05:21:34 GMT 2017 msaitoh branches: 1.2.2; 1.2.4; 1.2.12; 1.2.16; 1.2.32; Enable PCIe's interrupt as much as possilbe in ppb(4) to detect and count status change event. HotPlug function itself have not implemented yet. - Interrupt and each event are counted by evcnt(9). Example: ppb0 Interrupt 0 0 intr ppb0 Attention Button Pressed 0 0 misc ppb0 Power Fault Detected 0 0 misc ppb0 MRL Sensor Changed 0 0 misc ppb0 Presence Detect Changed 0 0 misc ppb0 Command Completed 0 0 misc ppb0 Data Link Layer State Changed 0 0 misc - Print message if ppb_printevent is not zero. The default vaule is 0. The output messages: Attention Button Pressed Power Fault Detected MRL Sensor Changed Presence Detect Changed Command Completed Data Link Layer State Changed - Remove workaround code to disable interrupt (ppb.c rev. 1.35). Tested with Dell Latitude 2120 without if_bge.c rev. 1.304's workaround. dmesg when bge's device timeout occured: ppb3: Presence Detect Changed ppb3: Data Link Layer State Changed ppb3: Presence Detect Changed vmstat -e |grep ppb ppb3 Interrupt 2 0 intr ppb3 Presence Detect Changed 2 0 misc ppb3 Data Link Layer State Changed 1 0 misc 1.2 Tue Apr 18 05:21:34 GMT 2017 msaitoh branches: 1.2.2; 1.2.4; 1.2.12; 1.2.16; 1.2.32; Enable PCIe's interrupt as much as possilbe in ppb(4) to detect and count status change event. HotPlug function itself have not implemented yet. - Interrupt and each event are counted by evcnt(9). Example: ppb0 Interrupt 0 0 intr ppb0 Attention Button Pressed 0 0 misc ppb0 Power Fault Detected 0 0 misc ppb0 MRL Sensor Changed 0 0 misc ppb0 Presence Detect Changed 0 0 misc ppb0 Command Completed 0 0 misc ppb0 Data Link Layer State Changed 0 0 misc - Print message if ppb_printevent is not zero. The default vaule is 0. The output messages: Attention Button Pressed Power Fault Detected MRL Sensor Changed Presence Detect Changed Command Completed Data Link Layer State Changed - Remove workaround code to disable interrupt (ppb.c rev. 1.35). Tested with Dell Latitude 2120 without if_bge.c rev. 1.304's workaround. dmesg when bge's device timeout occured: ppb3: Presence Detect Changed ppb3: Data Link Layer State Changed ppb3: Presence Detect Changed vmstat -e |grep ppb ppb3 Interrupt 2 0 intr ppb3 Presence Detect Changed 2 0 misc ppb3 Data Link Layer State Changed 1 0 misc 1.2 Tue Apr 18 05:21:34 GMT 2017 msaitoh branches: 1.2.2; 1.2.4; 1.2.12; 1.2.16; 1.2.32; Enable PCIe's interrupt as much as possilbe in ppb(4) to detect and count status change event. HotPlug function itself have not implemented yet. - Interrupt and each event are counted by evcnt(9). Example: ppb0 Interrupt 0 0 intr ppb0 Attention Button Pressed 0 0 misc ppb0 Power Fault Detected 0 0 misc ppb0 MRL Sensor Changed 0 0 misc ppb0 Presence Detect Changed 0 0 misc ppb0 Command Completed 0 0 misc ppb0 Data Link Layer State Changed 0 0 misc - Print message if ppb_printevent is not zero. The default vaule is 0. The output messages: Attention Button Pressed Power Fault Detected MRL Sensor Changed Presence Detect Changed Command Completed Data Link Layer State Changed - Remove workaround code to disable interrupt (ppb.c rev. 1.35). Tested with Dell Latitude 2120 without if_bge.c rev. 1.304's workaround. dmesg when bge's device timeout occured: ppb3: Presence Detect Changed ppb3: Data Link Layer State Changed ppb3: Presence Detect Changed vmstat -e |grep ppb ppb3 Interrupt 2 0 intr ppb3 Presence Detect Changed 2 0 misc ppb3 Data Link Layer State Changed 1 0 misc 1.2 Tue Apr 18 05:21:34 GMT 2017 msaitoh branches: 1.2.2; 1.2.4; 1.2.12; 1.2.16; 1.2.32; Enable PCIe's interrupt as much as possilbe in ppb(4) to detect and count status change event. HotPlug function itself have not implemented yet. - Interrupt and each event are counted by evcnt(9). Example: ppb0 Interrupt 0 0 intr ppb0 Attention Button Pressed 0 0 misc ppb0 Power Fault Detected 0 0 misc ppb0 MRL Sensor Changed 0 0 misc ppb0 Presence Detect Changed 0 0 misc ppb0 Command Completed 0 0 misc ppb0 Data Link Layer State Changed 0 0 misc - Print message if ppb_printevent is not zero. The default vaule is 0. The output messages: Attention Button Pressed Power Fault Detected MRL Sensor Changed Presence Detect Changed Command Completed Data Link Layer State Changed - Remove workaround code to disable interrupt (ppb.c rev. 1.35). Tested with Dell Latitude 2120 without if_bge.c rev. 1.304's workaround. dmesg when bge's device timeout occured: ppb3: Presence Detect Changed ppb3: Data Link Layer State Changed ppb3: Presence Detect Changed vmstat -e |grep ppb ppb3 Interrupt 2 0 intr ppb3 Presence Detect Changed 2 0 misc ppb3 Data Link Layer State Changed 1 0 misc 1.2 Tue Apr 18 05:21:34 GMT 2017 msaitoh branches: 1.2.2; 1.2.4; 1.2.12; 1.2.16; 1.2.32; Enable PCIe's interrupt as much as possilbe in ppb(4) to detect and count status change event. HotPlug function itself have not implemented yet. - Interrupt and each event are counted by evcnt(9). Example: ppb0 Interrupt 0 0 intr ppb0 Attention Button Pressed 0 0 misc ppb0 Power Fault Detected 0 0 misc ppb0 MRL Sensor Changed 0 0 misc ppb0 Presence Detect Changed 0 0 misc ppb0 Command Completed 0 0 misc ppb0 Data Link Layer State Changed 0 0 misc - Print message if ppb_printevent is not zero. The default vaule is 0. The output messages: Attention Button Pressed Power Fault Detected MRL Sensor Changed Presence Detect Changed Command Completed Data Link Layer State Changed - Remove workaround code to disable interrupt (ppb.c rev. 1.35). Tested with Dell Latitude 2120 without if_bge.c rev. 1.304's workaround. dmesg when bge's device timeout occured: ppb3: Presence Detect Changed ppb3: Data Link Layer State Changed ppb3: Presence Detect Changed vmstat -e |grep ppb ppb3 Interrupt 2 0 intr ppb3 Presence Detect Changed 2 0 misc ppb3 Data Link Layer State Changed 1 0 misc 1.2 Tue Apr 18 05:21:34 GMT 2017 msaitoh branches: 1.2.2; 1.2.4; 1.2.12; 1.2.16; 1.2.32; Enable PCIe's interrupt as much as possilbe in ppb(4) to detect and count status change event. HotPlug function itself have not implemented yet. - Interrupt and each event are counted by evcnt(9). Example: ppb0 Interrupt 0 0 intr ppb0 Attention Button Pressed 0 0 misc ppb0 Power Fault Detected 0 0 misc ppb0 MRL Sensor Changed 0 0 misc ppb0 Presence Detect Changed 0 0 misc ppb0 Command Completed 0 0 misc ppb0 Data Link Layer State Changed 0 0 misc - Print message if ppb_printevent is not zero. The default vaule is 0. The output messages: Attention Button Pressed Power Fault Detected MRL Sensor Changed Presence Detect Changed Command Completed Data Link Layer State Changed - Remove workaround code to disable interrupt (ppb.c rev. 1.35). Tested with Dell Latitude 2120 without if_bge.c rev. 1.304's workaround. dmesg when bge's device timeout occured: ppb3: Presence Detect Changed ppb3: Data Link Layer State Changed ppb3: Presence Detect Changed vmstat -e |grep ppb ppb3 Interrupt 2 0 intr ppb3 Presence Detect Changed 2 0 misc ppb3 Data Link Layer State Changed 1 0 misc 1.2 Tue Apr 18 05:21:34 GMT 2017 msaitoh branches: 1.2.2; 1.2.4; 1.2.12; 1.2.16; 1.2.32; Enable PCIe's interrupt as much as possilbe in ppb(4) to detect and count status change event. HotPlug function itself have not implemented yet. - Interrupt and each event are counted by evcnt(9). Example: ppb0 Interrupt 0 0 intr ppb0 Attention Button Pressed 0 0 misc ppb0 Power Fault Detected 0 0 misc ppb0 MRL Sensor Changed 0 0 misc ppb0 Presence Detect Changed 0 0 misc ppb0 Command Completed 0 0 misc ppb0 Data Link Layer State Changed 0 0 misc - Print message if ppb_printevent is not zero. The default vaule is 0. The output messages: Attention Button Pressed Power Fault Detected MRL Sensor Changed Presence Detect Changed Command Completed Data Link Layer State Changed - Remove workaround code to disable interrupt (ppb.c rev. 1.35). Tested with Dell Latitude 2120 without if_bge.c rev. 1.304's workaround. dmesg when bge's device timeout occured: ppb3: Presence Detect Changed ppb3: Data Link Layer State Changed ppb3: Presence Detect Changed vmstat -e |grep ppb ppb3 Interrupt 2 0 intr ppb3 Presence Detect Changed 2 0 misc ppb3 Data Link Layer State Changed 1 0 misc 1.2 Tue Apr 18 05:21:34 GMT 2017 msaitoh branches: 1.2.2; 1.2.4; 1.2.12; 1.2.16; 1.2.32; Enable PCIe's interrupt as much as possilbe in ppb(4) to detect and count status change event. HotPlug function itself have not implemented yet. - Interrupt and each event are counted by evcnt(9). Example: ppb0 Interrupt 0 0 intr ppb0 Attention Button Pressed 0 0 misc ppb0 Power Fault Detected 0 0 misc ppb0 MRL Sensor Changed 0 0 misc ppb0 Presence Detect Changed 0 0 misc ppb0 Command Completed 0 0 misc ppb0 Data Link Layer State Changed 0 0 misc - Print message if ppb_printevent is not zero. The default vaule is 0. The output messages: Attention Button Pressed Power Fault Detected MRL Sensor Changed Presence Detect Changed Command Completed Data Link Layer State Changed - Remove workaround code to disable interrupt (ppb.c rev. 1.35). Tested with Dell Latitude 2120 without if_bge.c rev. 1.304's workaround. dmesg when bge's device timeout occured: ppb3: Presence Detect Changed ppb3: Data Link Layer State Changed ppb3: Presence Detect Changed vmstat -e |grep ppb ppb3 Interrupt 2 0 intr ppb3 Presence Detect Changed 2 0 misc ppb3 Data Link Layer State Changed 1 0 misc 1.2 Tue Apr 18 05:21:34 GMT 2017 msaitoh branches: 1.2.2; 1.2.4; 1.2.12; 1.2.16; 1.2.32; Enable PCIe's interrupt as much as possilbe in ppb(4) to detect and count status change event. HotPlug function itself have not implemented yet. - Interrupt and each event are counted by evcnt(9). Example: ppb0 Interrupt 0 0 intr ppb0 Attention Button Pressed 0 0 misc ppb0 Power Fault Detected 0 0 misc ppb0 MRL Sensor Changed 0 0 misc ppb0 Presence Detect Changed 0 0 misc ppb0 Command Completed 0 0 misc ppb0 Data Link Layer State Changed 0 0 misc - Print message if ppb_printevent is not zero. The default vaule is 0. The output messages: Attention Button Pressed Power Fault Detected MRL Sensor Changed Presence Detect Changed Command Completed Data Link Layer State Changed - Remove workaround code to disable interrupt (ppb.c rev. 1.35). Tested with Dell Latitude 2120 without if_bge.c rev. 1.304's workaround. dmesg when bge's device timeout occured: ppb3: Presence Detect Changed ppb3: Data Link Layer State Changed ppb3: Presence Detect Changed vmstat -e |grep ppb ppb3 Interrupt 2 0 intr ppb3 Presence Detect Changed 2 0 misc ppb3 Data Link Layer State Changed 1 0 misc 1.2 Tue Apr 18 05:21:34 GMT 2017 msaitoh branches: 1.2.2; 1.2.4; 1.2.12; 1.2.16; 1.2.32; Enable PCIe's interrupt as much as possilbe in ppb(4) to detect and count status change event. HotPlug function itself have not implemented yet. - Interrupt and each event are counted by evcnt(9). Example: ppb0 Interrupt 0 0 intr ppb0 Attention Button Pressed 0 0 misc ppb0 Power Fault Detected 0 0 misc ppb0 MRL Sensor Changed 0 0 misc ppb0 Presence Detect Changed 0 0 misc ppb0 Command Completed 0 0 misc ppb0 Data Link Layer State Changed 0 0 misc - Print message if ppb_printevent is not zero. The default vaule is 0. The output messages: Attention Button Pressed Power Fault Detected MRL Sensor Changed Presence Detect Changed Command Completed Data Link Layer State Changed - Remove workaround code to disable interrupt (ppb.c rev. 1.35). Tested with Dell Latitude 2120 without if_bge.c rev. 1.304's workaround. dmesg when bge's device timeout occured: ppb3: Presence Detect Changed ppb3: Data Link Layer State Changed ppb3: Presence Detect Changed vmstat -e |grep ppb ppb3 Interrupt 2 0 intr ppb3 Presence Detect Changed 2 0 misc ppb3 Data Link Layer State Changed 1 0 misc 1.2 Tue Apr 18 05:21:34 GMT 2017 msaitoh branches: 1.2.2; 1.2.4; 1.2.12; 1.2.16; 1.2.32; Enable PCIe's interrupt as much as possilbe in ppb(4) to detect and count status change event. HotPlug function itself have not implemented yet. - Interrupt and each event are counted by evcnt(9). Example: ppb0 Interrupt 0 0 intr ppb0 Attention Button Pressed 0 0 misc ppb0 Power Fault Detected 0 0 misc ppb0 MRL Sensor Changed 0 0 misc ppb0 Presence Detect Changed 0 0 misc ppb0 Command Completed 0 0 misc ppb0 Data Link Layer State Changed 0 0 misc - Print message if ppb_printevent is not zero. The default vaule is 0. The output messages: Attention Button Pressed Power Fault Detected MRL Sensor Changed Presence Detect Changed Command Completed Data Link Layer State Changed - Remove workaround code to disable interrupt (ppb.c rev. 1.35). Tested with Dell Latitude 2120 without if_bge.c rev. 1.304's workaround. dmesg when bge's device timeout occured: ppb3: Presence Detect Changed ppb3: Data Link Layer State Changed ppb3: Presence Detect Changed vmstat -e |grep ppb ppb3 Interrupt 2 0 intr ppb3 Presence Detect Changed 2 0 misc ppb3 Data Link Layer State Changed 1 0 misc |
| H A D | usb_pci.h | 1.6 Sat Dec 11 17:58:41 GMT 2010 matt branches: 1.6.98; Make ehci deal with pci devices that have multiple companion functions and ehci functions. We can't assume that there will only be one ehci per device. The existing code could not deal with: Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 0 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 1 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 2 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 3 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 4 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 5 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 6 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 7 not configured 1.6 Sat Dec 11 17:58:41 GMT 2010 matt branches: 1.6.98; Make ehci deal with pci devices that have multiple companion functions and ehci functions. We can't assume that there will only be one ehci per device. The existing code could not deal with: Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 0 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 1 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 2 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 3 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 4 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 5 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 6 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 7 not configured 1.6 Sat Dec 11 17:58:41 GMT 2010 matt branches: 1.6.98; Make ehci deal with pci devices that have multiple companion functions and ehci functions. We can't assume that there will only be one ehci per device. The existing code could not deal with: Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 0 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 1 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 2 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 3 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 4 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 5 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 6 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 7 not configured 1.6 Sat Dec 11 17:58:41 GMT 2010 matt branches: 1.6.98; Make ehci deal with pci devices that have multiple companion functions and ehci functions. We can't assume that there will only be one ehci per device. The existing code could not deal with: Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 0 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 1 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 2 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 3 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 4 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 5 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 6 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 7 not configured 1.6 Sat Dec 11 17:58:41 GMT 2010 matt branches: 1.6.98; Make ehci deal with pci devices that have multiple companion functions and ehci functions. We can't assume that there will only be one ehci per device. The existing code could not deal with: Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 0 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 1 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 2 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 3 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 4 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 5 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 6 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 7 not configured 1.6 Sat Dec 11 17:58:41 GMT 2010 matt branches: 1.6.98; Make ehci deal with pci devices that have multiple companion functions and ehci functions. We can't assume that there will only be one ehci per device. The existing code could not deal with: Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 0 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 1 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 2 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 3 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 4 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 5 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 6 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 7 not configured 1.6 Sat Dec 11 17:58:41 GMT 2010 matt branches: 1.6.98; Make ehci deal with pci devices that have multiple companion functions and ehci functions. We can't assume that there will only be one ehci per device. The existing code could not deal with: Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 0 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 1 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 2 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 3 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 4 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 5 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 6 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 7 not configured 1.6 Sat Dec 11 17:58:41 GMT 2010 matt branches: 1.6.98; Make ehci deal with pci devices that have multiple companion functions and ehci functions. We can't assume that there will only be one ehci per device. The existing code could not deal with: Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 0 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 1 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 2 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 3 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 4 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 5 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 6 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 7 not configured 1.6 Sat Dec 11 17:58:41 GMT 2010 matt branches: 1.6.98; Make ehci deal with pci devices that have multiple companion functions and ehci functions. We can't assume that there will only be one ehci per device. The existing code could not deal with: Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 0 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 1 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 2 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 3 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 4 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 5 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 6 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 7 not configured 1.6 Sat Dec 11 17:58:41 GMT 2010 matt branches: 1.6.98; Make ehci deal with pci devices that have multiple companion functions and ehci functions. We can't assume that there will only be one ehci per device. The existing code could not deal with: Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 0 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 1 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 2 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 3 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 4 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 5 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 6 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 7 not configured 1.6 Sat Dec 11 17:58:41 GMT 2010 matt branches: 1.6.98; Make ehci deal with pci devices that have multiple companion functions and ehci functions. We can't assume that there will only be one ehci per device. The existing code could not deal with: Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 0 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 1 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 2 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 3 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 4 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 5 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 6 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 7 not configured 1.6 Sat Dec 11 17:58:41 GMT 2010 matt branches: 1.6.98; Make ehci deal with pci devices that have multiple companion functions and ehci functions. We can't assume that there will only be one ehci per device. The existing code could not deal with: Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 0 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 1 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 2 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 3 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 4 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 5 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 6 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 7 not configured 1.6 Sat Dec 11 17:58:41 GMT 2010 matt branches: 1.6.98; Make ehci deal with pci devices that have multiple companion functions and ehci functions. We can't assume that there will only be one ehci per device. The existing code could not deal with: Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 0 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 1 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 2 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 3 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 4 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 5 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 6 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 7 not configured 1.6 Sat Dec 11 17:58:41 GMT 2010 matt branches: 1.6.98; Make ehci deal with pci devices that have multiple companion functions and ehci functions. We can't assume that there will only be one ehci per device. The existing code could not deal with: Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 0 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 1 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 2 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 3 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 4 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 5 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 6 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 7 not configured 1.6 Sat Dec 11 17:58:41 GMT 2010 matt branches: 1.6.98; Make ehci deal with pci devices that have multiple companion functions and ehci functions. We can't assume that there will only be one ehci per device. The existing code could not deal with: Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 0 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 1 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 2 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 3 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 4 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 5 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 6 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 7 not configured 1.6 Sat Dec 11 17:58:41 GMT 2010 matt branches: 1.6.98; Make ehci deal with pci devices that have multiple companion functions and ehci functions. We can't assume that there will only be one ehci per device. The existing code could not deal with: Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 0 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 1 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 2 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 3 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 4 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 5 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 6 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 7 not configured 1.6 Sat Dec 11 17:58:41 GMT 2010 matt branches: 1.6.98; Make ehci deal with pci devices that have multiple companion functions and ehci functions. We can't assume that there will only be one ehci per device. The existing code could not deal with: Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 0 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 1 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 2 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 3 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 4 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 5 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 6 not configured Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 7 not configured |
| /src/sys/arch/arm/sunxi/ | ||
| H A D | sunxi_fb.c | 1.6 Sun Dec 19 11:25:25 GMT 2021 riastradh Defer call to drmfb_attach, otherwise we lock against ourselves Mutex error: mutex_vector_enter,542: locking against myself lockdebug_abort() at ffffffc0004ba3ec netbsd:lockdebug_abort+0xcc mutex_enter() at ffffffc000476af4 netbsd:mutex_enter+0x3d4 drm_fb_helper_restore_fbdev_mode_unlocked() at ffffffc0003432a8 netbsd:drm_fb_helper_restore_fbdev_mode_unlocked+0x60 drmfb_genfb_setmode() at ffffffc00031c428 netbsd:drmfb_genfb_setmode+0x18 genfb_attach() at ffffffc000377b04 netbsd:genfb_attach+0x10c drmfb_attach() at ffffffc00031c808 netbsd:drmfb_attach+0x1d0 sunxi_fb_attach() at ffffffc00005a648 netbsd:sunxi_fb_attach+0xd0 config_attach_loc() at ffffffc0004a7174 netbsd:config_attach_loc+0x184 config_found_sm_loc() at ffffffc0004a72a0 netbsd:config_found_sm_loc+0x58 sunxi_drm_fb_probe() at ffffffc00005a078 netbsd:sunxi_drm_fb_probe+0x250 __drm_fb_helper_initial_config_and_unlock() at ffffffc000342bdc netbsd:__drm_fb_helper_initial_config_and_unlock+0x2a4 sunxi_drm_load() at ffffffc00005a384 netbsd:sunxi_drm_load+0x154 drm_dev_register() at ffffffc00033b728 netbsd:drm_dev_register+0xe0 sunxi_drm_init() at ffffffc000059d40 netbsd:sunxi_drm_init+0x20 config_process_deferred() at ffffffc0004a6efc netbsd:config_process_deferred+0xac config_attach_loc() at ffffffc0004a7190 netbsd:config_attach_loc+0x1a0 config_found_sm_loc() at ffffffc0004a72a0 netbsd:config_found_sm_loc+0x58 arm_fdt_attach() at ffffffc000061e34 netbsd:arm_fdt_attach+0x64 config_attach_loc() at ffffffc0004a7174 netbsd:config_attach_loc+0x184 cpu_configure() at ffffffc00005dab4 netbsd:cpu_configure+0x44 main() at ffffffc000605284 netbsd:main+0x2b4 aarch64_start() at ffffffc000001854 netbsd:aarch64_start+0x1054 Author: Maya Rashish <maya@NetBSD.org> Committer: Taylor R Campbell <riastradh@NetBSD.org> 1.6 Sun Dec 19 11:25:25 GMT 2021 riastradh Defer call to drmfb_attach, otherwise we lock against ourselves Mutex error: mutex_vector_enter,542: locking against myself lockdebug_abort() at ffffffc0004ba3ec netbsd:lockdebug_abort+0xcc mutex_enter() at ffffffc000476af4 netbsd:mutex_enter+0x3d4 drm_fb_helper_restore_fbdev_mode_unlocked() at ffffffc0003432a8 netbsd:drm_fb_helper_restore_fbdev_mode_unlocked+0x60 drmfb_genfb_setmode() at ffffffc00031c428 netbsd:drmfb_genfb_setmode+0x18 genfb_attach() at ffffffc000377b04 netbsd:genfb_attach+0x10c drmfb_attach() at ffffffc00031c808 netbsd:drmfb_attach+0x1d0 sunxi_fb_attach() at ffffffc00005a648 netbsd:sunxi_fb_attach+0xd0 config_attach_loc() at ffffffc0004a7174 netbsd:config_attach_loc+0x184 config_found_sm_loc() at ffffffc0004a72a0 netbsd:config_found_sm_loc+0x58 sunxi_drm_fb_probe() at ffffffc00005a078 netbsd:sunxi_drm_fb_probe+0x250 __drm_fb_helper_initial_config_and_unlock() at ffffffc000342bdc netbsd:__drm_fb_helper_initial_config_and_unlock+0x2a4 sunxi_drm_load() at ffffffc00005a384 netbsd:sunxi_drm_load+0x154 drm_dev_register() at ffffffc00033b728 netbsd:drm_dev_register+0xe0 sunxi_drm_init() at ffffffc000059d40 netbsd:sunxi_drm_init+0x20 config_process_deferred() at ffffffc0004a6efc netbsd:config_process_deferred+0xac config_attach_loc() at ffffffc0004a7190 netbsd:config_attach_loc+0x1a0 config_found_sm_loc() at ffffffc0004a72a0 netbsd:config_found_sm_loc+0x58 arm_fdt_attach() at ffffffc000061e34 netbsd:arm_fdt_attach+0x64 config_attach_loc() at ffffffc0004a7174 netbsd:config_attach_loc+0x184 cpu_configure() at ffffffc00005dab4 netbsd:cpu_configure+0x44 main() at ffffffc000605284 netbsd:main+0x2b4 aarch64_start() at ffffffc000001854 netbsd:aarch64_start+0x1054 Author: Maya Rashish <maya@NetBSD.org> Committer: Taylor R Campbell <riastradh@NetBSD.org> 1.6 Sun Dec 19 11:25:25 GMT 2021 riastradh Defer call to drmfb_attach, otherwise we lock against ourselves Mutex error: mutex_vector_enter,542: locking against myself lockdebug_abort() at ffffffc0004ba3ec netbsd:lockdebug_abort+0xcc mutex_enter() at ffffffc000476af4 netbsd:mutex_enter+0x3d4 drm_fb_helper_restore_fbdev_mode_unlocked() at ffffffc0003432a8 netbsd:drm_fb_helper_restore_fbdev_mode_unlocked+0x60 drmfb_genfb_setmode() at ffffffc00031c428 netbsd:drmfb_genfb_setmode+0x18 genfb_attach() at ffffffc000377b04 netbsd:genfb_attach+0x10c drmfb_attach() at ffffffc00031c808 netbsd:drmfb_attach+0x1d0 sunxi_fb_attach() at ffffffc00005a648 netbsd:sunxi_fb_attach+0xd0 config_attach_loc() at ffffffc0004a7174 netbsd:config_attach_loc+0x184 config_found_sm_loc() at ffffffc0004a72a0 netbsd:config_found_sm_loc+0x58 sunxi_drm_fb_probe() at ffffffc00005a078 netbsd:sunxi_drm_fb_probe+0x250 __drm_fb_helper_initial_config_and_unlock() at ffffffc000342bdc netbsd:__drm_fb_helper_initial_config_and_unlock+0x2a4 sunxi_drm_load() at ffffffc00005a384 netbsd:sunxi_drm_load+0x154 drm_dev_register() at ffffffc00033b728 netbsd:drm_dev_register+0xe0 sunxi_drm_init() at ffffffc000059d40 netbsd:sunxi_drm_init+0x20 config_process_deferred() at ffffffc0004a6efc netbsd:config_process_deferred+0xac config_attach_loc() at ffffffc0004a7190 netbsd:config_attach_loc+0x1a0 config_found_sm_loc() at ffffffc0004a72a0 netbsd:config_found_sm_loc+0x58 arm_fdt_attach() at ffffffc000061e34 netbsd:arm_fdt_attach+0x64 config_attach_loc() at ffffffc0004a7174 netbsd:config_attach_loc+0x184 cpu_configure() at ffffffc00005dab4 netbsd:cpu_configure+0x44 main() at ffffffc000605284 netbsd:main+0x2b4 aarch64_start() at ffffffc000001854 netbsd:aarch64_start+0x1054 Author: Maya Rashish <maya@NetBSD.org> Committer: Taylor R Campbell <riastradh@NetBSD.org> 1.6 Sun Dec 19 11:25:25 GMT 2021 riastradh Defer call to drmfb_attach, otherwise we lock against ourselves Mutex error: mutex_vector_enter,542: locking against myself lockdebug_abort() at ffffffc0004ba3ec netbsd:lockdebug_abort+0xcc mutex_enter() at ffffffc000476af4 netbsd:mutex_enter+0x3d4 drm_fb_helper_restore_fbdev_mode_unlocked() at ffffffc0003432a8 netbsd:drm_fb_helper_restore_fbdev_mode_unlocked+0x60 drmfb_genfb_setmode() at ffffffc00031c428 netbsd:drmfb_genfb_setmode+0x18 genfb_attach() at ffffffc000377b04 netbsd:genfb_attach+0x10c drmfb_attach() at ffffffc00031c808 netbsd:drmfb_attach+0x1d0 sunxi_fb_attach() at ffffffc00005a648 netbsd:sunxi_fb_attach+0xd0 config_attach_loc() at ffffffc0004a7174 netbsd:config_attach_loc+0x184 config_found_sm_loc() at ffffffc0004a72a0 netbsd:config_found_sm_loc+0x58 sunxi_drm_fb_probe() at ffffffc00005a078 netbsd:sunxi_drm_fb_probe+0x250 __drm_fb_helper_initial_config_and_unlock() at ffffffc000342bdc netbsd:__drm_fb_helper_initial_config_and_unlock+0x2a4 sunxi_drm_load() at ffffffc00005a384 netbsd:sunxi_drm_load+0x154 drm_dev_register() at ffffffc00033b728 netbsd:drm_dev_register+0xe0 sunxi_drm_init() at ffffffc000059d40 netbsd:sunxi_drm_init+0x20 config_process_deferred() at ffffffc0004a6efc netbsd:config_process_deferred+0xac config_attach_loc() at ffffffc0004a7190 netbsd:config_attach_loc+0x1a0 config_found_sm_loc() at ffffffc0004a72a0 netbsd:config_found_sm_loc+0x58 arm_fdt_attach() at ffffffc000061e34 netbsd:arm_fdt_attach+0x64 config_attach_loc() at ffffffc0004a7174 netbsd:config_attach_loc+0x184 cpu_configure() at ffffffc00005dab4 netbsd:cpu_configure+0x44 main() at ffffffc000605284 netbsd:main+0x2b4 aarch64_start() at ffffffc000001854 netbsd:aarch64_start+0x1054 Author: Maya Rashish <maya@NetBSD.org> Committer: Taylor R Campbell <riastradh@NetBSD.org> 1.6 Sun Dec 19 11:25:25 GMT 2021 riastradh Defer call to drmfb_attach, otherwise we lock against ourselves Mutex error: mutex_vector_enter,542: locking against myself lockdebug_abort() at ffffffc0004ba3ec netbsd:lockdebug_abort+0xcc mutex_enter() at ffffffc000476af4 netbsd:mutex_enter+0x3d4 drm_fb_helper_restore_fbdev_mode_unlocked() at ffffffc0003432a8 netbsd:drm_fb_helper_restore_fbdev_mode_unlocked+0x60 drmfb_genfb_setmode() at ffffffc00031c428 netbsd:drmfb_genfb_setmode+0x18 genfb_attach() at ffffffc000377b04 netbsd:genfb_attach+0x10c drmfb_attach() at ffffffc00031c808 netbsd:drmfb_attach+0x1d0 sunxi_fb_attach() at ffffffc00005a648 netbsd:sunxi_fb_attach+0xd0 config_attach_loc() at ffffffc0004a7174 netbsd:config_attach_loc+0x184 config_found_sm_loc() at ffffffc0004a72a0 netbsd:config_found_sm_loc+0x58 sunxi_drm_fb_probe() at ffffffc00005a078 netbsd:sunxi_drm_fb_probe+0x250 __drm_fb_helper_initial_config_and_unlock() at ffffffc000342bdc netbsd:__drm_fb_helper_initial_config_and_unlock+0x2a4 sunxi_drm_load() at ffffffc00005a384 netbsd:sunxi_drm_load+0x154 drm_dev_register() at ffffffc00033b728 netbsd:drm_dev_register+0xe0 sunxi_drm_init() at ffffffc000059d40 netbsd:sunxi_drm_init+0x20 config_process_deferred() at ffffffc0004a6efc netbsd:config_process_deferred+0xac config_attach_loc() at ffffffc0004a7190 netbsd:config_attach_loc+0x1a0 config_found_sm_loc() at ffffffc0004a72a0 netbsd:config_found_sm_loc+0x58 arm_fdt_attach() at ffffffc000061e34 netbsd:arm_fdt_attach+0x64 config_attach_loc() at ffffffc0004a7174 netbsd:config_attach_loc+0x184 cpu_configure() at ffffffc00005dab4 netbsd:cpu_configure+0x44 main() at ffffffc000605284 netbsd:main+0x2b4 aarch64_start() at ffffffc000001854 netbsd:aarch64_start+0x1054 Author: Maya Rashish <maya@NetBSD.org> Committer: Taylor R Campbell <riastradh@NetBSD.org> 1.6 Sun Dec 19 11:25:25 GMT 2021 riastradh Defer call to drmfb_attach, otherwise we lock against ourselves Mutex error: mutex_vector_enter,542: locking against myself lockdebug_abort() at ffffffc0004ba3ec netbsd:lockdebug_abort+0xcc mutex_enter() at ffffffc000476af4 netbsd:mutex_enter+0x3d4 drm_fb_helper_restore_fbdev_mode_unlocked() at ffffffc0003432a8 netbsd:drm_fb_helper_restore_fbdev_mode_unlocked+0x60 drmfb_genfb_setmode() at ffffffc00031c428 netbsd:drmfb_genfb_setmode+0x18 genfb_attach() at ffffffc000377b04 netbsd:genfb_attach+0x10c drmfb_attach() at ffffffc00031c808 netbsd:drmfb_attach+0x1d0 sunxi_fb_attach() at ffffffc00005a648 netbsd:sunxi_fb_attach+0xd0 config_attach_loc() at ffffffc0004a7174 netbsd:config_attach_loc+0x184 config_found_sm_loc() at ffffffc0004a72a0 netbsd:config_found_sm_loc+0x58 sunxi_drm_fb_probe() at ffffffc00005a078 netbsd:sunxi_drm_fb_probe+0x250 __drm_fb_helper_initial_config_and_unlock() at ffffffc000342bdc netbsd:__drm_fb_helper_initial_config_and_unlock+0x2a4 sunxi_drm_load() at ffffffc00005a384 netbsd:sunxi_drm_load+0x154 drm_dev_register() at ffffffc00033b728 netbsd:drm_dev_register+0xe0 sunxi_drm_init() at ffffffc000059d40 netbsd:sunxi_drm_init+0x20 config_process_deferred() at ffffffc0004a6efc netbsd:config_process_deferred+0xac config_attach_loc() at ffffffc0004a7190 netbsd:config_attach_loc+0x1a0 config_found_sm_loc() at ffffffc0004a72a0 netbsd:config_found_sm_loc+0x58 arm_fdt_attach() at ffffffc000061e34 netbsd:arm_fdt_attach+0x64 config_attach_loc() at ffffffc0004a7174 netbsd:config_attach_loc+0x184 cpu_configure() at ffffffc00005dab4 netbsd:cpu_configure+0x44 main() at ffffffc000605284 netbsd:main+0x2b4 aarch64_start() at ffffffc000001854 netbsd:aarch64_start+0x1054 Author: Maya Rashish <maya@NetBSD.org> Committer: Taylor R Campbell <riastradh@NetBSD.org> 1.6 Sun Dec 19 11:25:25 GMT 2021 riastradh Defer call to drmfb_attach, otherwise we lock against ourselves Mutex error: mutex_vector_enter,542: locking against myself lockdebug_abort() at ffffffc0004ba3ec netbsd:lockdebug_abort+0xcc mutex_enter() at ffffffc000476af4 netbsd:mutex_enter+0x3d4 drm_fb_helper_restore_fbdev_mode_unlocked() at ffffffc0003432a8 netbsd:drm_fb_helper_restore_fbdev_mode_unlocked+0x60 drmfb_genfb_setmode() at ffffffc00031c428 netbsd:drmfb_genfb_setmode+0x18 genfb_attach() at ffffffc000377b04 netbsd:genfb_attach+0x10c drmfb_attach() at ffffffc00031c808 netbsd:drmfb_attach+0x1d0 sunxi_fb_attach() at ffffffc00005a648 netbsd:sunxi_fb_attach+0xd0 config_attach_loc() at ffffffc0004a7174 netbsd:config_attach_loc+0x184 config_found_sm_loc() at ffffffc0004a72a0 netbsd:config_found_sm_loc+0x58 sunxi_drm_fb_probe() at ffffffc00005a078 netbsd:sunxi_drm_fb_probe+0x250 __drm_fb_helper_initial_config_and_unlock() at ffffffc000342bdc netbsd:__drm_fb_helper_initial_config_and_unlock+0x2a4 sunxi_drm_load() at ffffffc00005a384 netbsd:sunxi_drm_load+0x154 drm_dev_register() at ffffffc00033b728 netbsd:drm_dev_register+0xe0 sunxi_drm_init() at ffffffc000059d40 netbsd:sunxi_drm_init+0x20 config_process_deferred() at ffffffc0004a6efc netbsd:config_process_deferred+0xac config_attach_loc() at ffffffc0004a7190 netbsd:config_attach_loc+0x1a0 config_found_sm_loc() at ffffffc0004a72a0 netbsd:config_found_sm_loc+0x58 arm_fdt_attach() at ffffffc000061e34 netbsd:arm_fdt_attach+0x64 config_attach_loc() at ffffffc0004a7174 netbsd:config_attach_loc+0x184 cpu_configure() at ffffffc00005dab4 netbsd:cpu_configure+0x44 main() at ffffffc000605284 netbsd:main+0x2b4 aarch64_start() at ffffffc000001854 netbsd:aarch64_start+0x1054 Author: Maya Rashish <maya@NetBSD.org> Committer: Taylor R Campbell <riastradh@NetBSD.org> 1.6 Sun Dec 19 11:25:25 GMT 2021 riastradh Defer call to drmfb_attach, otherwise we lock against ourselves Mutex error: mutex_vector_enter,542: locking against myself lockdebug_abort() at ffffffc0004ba3ec netbsd:lockdebug_abort+0xcc mutex_enter() at ffffffc000476af4 netbsd:mutex_enter+0x3d4 drm_fb_helper_restore_fbdev_mode_unlocked() at ffffffc0003432a8 netbsd:drm_fb_helper_restore_fbdev_mode_unlocked+0x60 drmfb_genfb_setmode() at ffffffc00031c428 netbsd:drmfb_genfb_setmode+0x18 genfb_attach() at ffffffc000377b04 netbsd:genfb_attach+0x10c drmfb_attach() at ffffffc00031c808 netbsd:drmfb_attach+0x1d0 sunxi_fb_attach() at ffffffc00005a648 netbsd:sunxi_fb_attach+0xd0 config_attach_loc() at ffffffc0004a7174 netbsd:config_attach_loc+0x184 config_found_sm_loc() at ffffffc0004a72a0 netbsd:config_found_sm_loc+0x58 sunxi_drm_fb_probe() at ffffffc00005a078 netbsd:sunxi_drm_fb_probe+0x250 __drm_fb_helper_initial_config_and_unlock() at ffffffc000342bdc netbsd:__drm_fb_helper_initial_config_and_unlock+0x2a4 sunxi_drm_load() at ffffffc00005a384 netbsd:sunxi_drm_load+0x154 drm_dev_register() at ffffffc00033b728 netbsd:drm_dev_register+0xe0 sunxi_drm_init() at ffffffc000059d40 netbsd:sunxi_drm_init+0x20 config_process_deferred() at ffffffc0004a6efc netbsd:config_process_deferred+0xac config_attach_loc() at ffffffc0004a7190 netbsd:config_attach_loc+0x1a0 config_found_sm_loc() at ffffffc0004a72a0 netbsd:config_found_sm_loc+0x58 arm_fdt_attach() at ffffffc000061e34 netbsd:arm_fdt_attach+0x64 config_attach_loc() at ffffffc0004a7174 netbsd:config_attach_loc+0x184 cpu_configure() at ffffffc00005dab4 netbsd:cpu_configure+0x44 main() at ffffffc000605284 netbsd:main+0x2b4 aarch64_start() at ffffffc000001854 netbsd:aarch64_start+0x1054 Author: Maya Rashish <maya@NetBSD.org> Committer: Taylor R Campbell <riastradh@NetBSD.org> 1.6 Sun Dec 19 11:25:25 GMT 2021 riastradh Defer call to drmfb_attach, otherwise we lock against ourselves Mutex error: mutex_vector_enter,542: locking against myself lockdebug_abort() at ffffffc0004ba3ec netbsd:lockdebug_abort+0xcc mutex_enter() at ffffffc000476af4 netbsd:mutex_enter+0x3d4 drm_fb_helper_restore_fbdev_mode_unlocked() at ffffffc0003432a8 netbsd:drm_fb_helper_restore_fbdev_mode_unlocked+0x60 drmfb_genfb_setmode() at ffffffc00031c428 netbsd:drmfb_genfb_setmode+0x18 genfb_attach() at ffffffc000377b04 netbsd:genfb_attach+0x10c drmfb_attach() at ffffffc00031c808 netbsd:drmfb_attach+0x1d0 sunxi_fb_attach() at ffffffc00005a648 netbsd:sunxi_fb_attach+0xd0 config_attach_loc() at ffffffc0004a7174 netbsd:config_attach_loc+0x184 config_found_sm_loc() at ffffffc0004a72a0 netbsd:config_found_sm_loc+0x58 sunxi_drm_fb_probe() at ffffffc00005a078 netbsd:sunxi_drm_fb_probe+0x250 __drm_fb_helper_initial_config_and_unlock() at ffffffc000342bdc netbsd:__drm_fb_helper_initial_config_and_unlock+0x2a4 sunxi_drm_load() at ffffffc00005a384 netbsd:sunxi_drm_load+0x154 drm_dev_register() at ffffffc00033b728 netbsd:drm_dev_register+0xe0 sunxi_drm_init() at ffffffc000059d40 netbsd:sunxi_drm_init+0x20 config_process_deferred() at ffffffc0004a6efc netbsd:config_process_deferred+0xac config_attach_loc() at ffffffc0004a7190 netbsd:config_attach_loc+0x1a0 config_found_sm_loc() at ffffffc0004a72a0 netbsd:config_found_sm_loc+0x58 arm_fdt_attach() at ffffffc000061e34 netbsd:arm_fdt_attach+0x64 config_attach_loc() at ffffffc0004a7174 netbsd:config_attach_loc+0x184 cpu_configure() at ffffffc00005dab4 netbsd:cpu_configure+0x44 main() at ffffffc000605284 netbsd:main+0x2b4 aarch64_start() at ffffffc000001854 netbsd:aarch64_start+0x1054 Author: Maya Rashish <maya@NetBSD.org> Committer: Taylor R Campbell <riastradh@NetBSD.org> 1.6 Sun Dec 19 11:25:25 GMT 2021 riastradh Defer call to drmfb_attach, otherwise we lock against ourselves Mutex error: mutex_vector_enter,542: locking against myself lockdebug_abort() at ffffffc0004ba3ec netbsd:lockdebug_abort+0xcc mutex_enter() at ffffffc000476af4 netbsd:mutex_enter+0x3d4 drm_fb_helper_restore_fbdev_mode_unlocked() at ffffffc0003432a8 netbsd:drm_fb_helper_restore_fbdev_mode_unlocked+0x60 drmfb_genfb_setmode() at ffffffc00031c428 netbsd:drmfb_genfb_setmode+0x18 genfb_attach() at ffffffc000377b04 netbsd:genfb_attach+0x10c drmfb_attach() at ffffffc00031c808 netbsd:drmfb_attach+0x1d0 sunxi_fb_attach() at ffffffc00005a648 netbsd:sunxi_fb_attach+0xd0 config_attach_loc() at ffffffc0004a7174 netbsd:config_attach_loc+0x184 config_found_sm_loc() at ffffffc0004a72a0 netbsd:config_found_sm_loc+0x58 sunxi_drm_fb_probe() at ffffffc00005a078 netbsd:sunxi_drm_fb_probe+0x250 __drm_fb_helper_initial_config_and_unlock() at ffffffc000342bdc netbsd:__drm_fb_helper_initial_config_and_unlock+0x2a4 sunxi_drm_load() at ffffffc00005a384 netbsd:sunxi_drm_load+0x154 drm_dev_register() at ffffffc00033b728 netbsd:drm_dev_register+0xe0 sunxi_drm_init() at ffffffc000059d40 netbsd:sunxi_drm_init+0x20 config_process_deferred() at ffffffc0004a6efc netbsd:config_process_deferred+0xac config_attach_loc() at ffffffc0004a7190 netbsd:config_attach_loc+0x1a0 config_found_sm_loc() at ffffffc0004a72a0 netbsd:config_found_sm_loc+0x58 arm_fdt_attach() at ffffffc000061e34 netbsd:arm_fdt_attach+0x64 config_attach_loc() at ffffffc0004a7174 netbsd:config_attach_loc+0x184 cpu_configure() at ffffffc00005dab4 netbsd:cpu_configure+0x44 main() at ffffffc000605284 netbsd:main+0x2b4 aarch64_start() at ffffffc000001854 netbsd:aarch64_start+0x1054 Author: Maya Rashish <maya@NetBSD.org> Committer: Taylor R Campbell <riastradh@NetBSD.org> 1.6 Sun Dec 19 11:25:25 GMT 2021 riastradh Defer call to drmfb_attach, otherwise we lock against ourselves Mutex error: mutex_vector_enter,542: locking against myself lockdebug_abort() at ffffffc0004ba3ec netbsd:lockdebug_abort+0xcc mutex_enter() at ffffffc000476af4 netbsd:mutex_enter+0x3d4 drm_fb_helper_restore_fbdev_mode_unlocked() at ffffffc0003432a8 netbsd:drm_fb_helper_restore_fbdev_mode_unlocked+0x60 drmfb_genfb_setmode() at ffffffc00031c428 netbsd:drmfb_genfb_setmode+0x18 genfb_attach() at ffffffc000377b04 netbsd:genfb_attach+0x10c drmfb_attach() at ffffffc00031c808 netbsd:drmfb_attach+0x1d0 sunxi_fb_attach() at ffffffc00005a648 netbsd:sunxi_fb_attach+0xd0 config_attach_loc() at ffffffc0004a7174 netbsd:config_attach_loc+0x184 config_found_sm_loc() at ffffffc0004a72a0 netbsd:config_found_sm_loc+0x58 sunxi_drm_fb_probe() at ffffffc00005a078 netbsd:sunxi_drm_fb_probe+0x250 __drm_fb_helper_initial_config_and_unlock() at ffffffc000342bdc netbsd:__drm_fb_helper_initial_config_and_unlock+0x2a4 sunxi_drm_load() at ffffffc00005a384 netbsd:sunxi_drm_load+0x154 drm_dev_register() at ffffffc00033b728 netbsd:drm_dev_register+0xe0 sunxi_drm_init() at ffffffc000059d40 netbsd:sunxi_drm_init+0x20 config_process_deferred() at ffffffc0004a6efc netbsd:config_process_deferred+0xac config_attach_loc() at ffffffc0004a7190 netbsd:config_attach_loc+0x1a0 config_found_sm_loc() at ffffffc0004a72a0 netbsd:config_found_sm_loc+0x58 arm_fdt_attach() at ffffffc000061e34 netbsd:arm_fdt_attach+0x64 config_attach_loc() at ffffffc0004a7174 netbsd:config_attach_loc+0x184 cpu_configure() at ffffffc00005dab4 netbsd:cpu_configure+0x44 main() at ffffffc000605284 netbsd:main+0x2b4 aarch64_start() at ffffffc000001854 netbsd:aarch64_start+0x1054 Author: Maya Rashish <maya@NetBSD.org> Committer: Taylor R Campbell <riastradh@NetBSD.org> 1.6 Sun Dec 19 11:25:25 GMT 2021 riastradh Defer call to drmfb_attach, otherwise we lock against ourselves Mutex error: mutex_vector_enter,542: locking against myself lockdebug_abort() at ffffffc0004ba3ec netbsd:lockdebug_abort+0xcc mutex_enter() at ffffffc000476af4 netbsd:mutex_enter+0x3d4 drm_fb_helper_restore_fbdev_mode_unlocked() at ffffffc0003432a8 netbsd:drm_fb_helper_restore_fbdev_mode_unlocked+0x60 drmfb_genfb_setmode() at ffffffc00031c428 netbsd:drmfb_genfb_setmode+0x18 genfb_attach() at ffffffc000377b04 netbsd:genfb_attach+0x10c drmfb_attach() at ffffffc00031c808 netbsd:drmfb_attach+0x1d0 sunxi_fb_attach() at ffffffc00005a648 netbsd:sunxi_fb_attach+0xd0 config_attach_loc() at ffffffc0004a7174 netbsd:config_attach_loc+0x184 config_found_sm_loc() at ffffffc0004a72a0 netbsd:config_found_sm_loc+0x58 sunxi_drm_fb_probe() at ffffffc00005a078 netbsd:sunxi_drm_fb_probe+0x250 __drm_fb_helper_initial_config_and_unlock() at ffffffc000342bdc netbsd:__drm_fb_helper_initial_config_and_unlock+0x2a4 sunxi_drm_load() at ffffffc00005a384 netbsd:sunxi_drm_load+0x154 drm_dev_register() at ffffffc00033b728 netbsd:drm_dev_register+0xe0 sunxi_drm_init() at ffffffc000059d40 netbsd:sunxi_drm_init+0x20 config_process_deferred() at ffffffc0004a6efc netbsd:config_process_deferred+0xac config_attach_loc() at ffffffc0004a7190 netbsd:config_attach_loc+0x1a0 config_found_sm_loc() at ffffffc0004a72a0 netbsd:config_found_sm_loc+0x58 arm_fdt_attach() at ffffffc000061e34 netbsd:arm_fdt_attach+0x64 config_attach_loc() at ffffffc0004a7174 netbsd:config_attach_loc+0x184 cpu_configure() at ffffffc00005dab4 netbsd:cpu_configure+0x44 main() at ffffffc000605284 netbsd:main+0x2b4 aarch64_start() at ffffffc000001854 netbsd:aarch64_start+0x1054 Author: Maya Rashish <maya@NetBSD.org> Committer: Taylor R Campbell <riastradh@NetBSD.org> 1.6 Sun Dec 19 11:25:25 GMT 2021 riastradh Defer call to drmfb_attach, otherwise we lock against ourselves Mutex error: mutex_vector_enter,542: locking against myself lockdebug_abort() at ffffffc0004ba3ec netbsd:lockdebug_abort+0xcc mutex_enter() at ffffffc000476af4 netbsd:mutex_enter+0x3d4 drm_fb_helper_restore_fbdev_mode_unlocked() at ffffffc0003432a8 netbsd:drm_fb_helper_restore_fbdev_mode_unlocked+0x60 drmfb_genfb_setmode() at ffffffc00031c428 netbsd:drmfb_genfb_setmode+0x18 genfb_attach() at ffffffc000377b04 netbsd:genfb_attach+0x10c drmfb_attach() at ffffffc00031c808 netbsd:drmfb_attach+0x1d0 sunxi_fb_attach() at ffffffc00005a648 netbsd:sunxi_fb_attach+0xd0 config_attach_loc() at ffffffc0004a7174 netbsd:config_attach_loc+0x184 config_found_sm_loc() at ffffffc0004a72a0 netbsd:config_found_sm_loc+0x58 sunxi_drm_fb_probe() at ffffffc00005a078 netbsd:sunxi_drm_fb_probe+0x250 __drm_fb_helper_initial_config_and_unlock() at ffffffc000342bdc netbsd:__drm_fb_helper_initial_config_and_unlock+0x2a4 sunxi_drm_load() at ffffffc00005a384 netbsd:sunxi_drm_load+0x154 drm_dev_register() at ffffffc00033b728 netbsd:drm_dev_register+0xe0 sunxi_drm_init() at ffffffc000059d40 netbsd:sunxi_drm_init+0x20 config_process_deferred() at ffffffc0004a6efc netbsd:config_process_deferred+0xac config_attach_loc() at ffffffc0004a7190 netbsd:config_attach_loc+0x1a0 config_found_sm_loc() at ffffffc0004a72a0 netbsd:config_found_sm_loc+0x58 arm_fdt_attach() at ffffffc000061e34 netbsd:arm_fdt_attach+0x64 config_attach_loc() at ffffffc0004a7174 netbsd:config_attach_loc+0x184 cpu_configure() at ffffffc00005dab4 netbsd:cpu_configure+0x44 main() at ffffffc000605284 netbsd:main+0x2b4 aarch64_start() at ffffffc000001854 netbsd:aarch64_start+0x1054 Author: Maya Rashish <maya@NetBSD.org> Committer: Taylor R Campbell <riastradh@NetBSD.org> 1.6 Sun Dec 19 11:25:25 GMT 2021 riastradh Defer call to drmfb_attach, otherwise we lock against ourselves Mutex error: mutex_vector_enter,542: locking against myself lockdebug_abort() at ffffffc0004ba3ec netbsd:lockdebug_abort+0xcc mutex_enter() at ffffffc000476af4 netbsd:mutex_enter+0x3d4 drm_fb_helper_restore_fbdev_mode_unlocked() at ffffffc0003432a8 netbsd:drm_fb_helper_restore_fbdev_mode_unlocked+0x60 drmfb_genfb_setmode() at ffffffc00031c428 netbsd:drmfb_genfb_setmode+0x18 genfb_attach() at ffffffc000377b04 netbsd:genfb_attach+0x10c drmfb_attach() at ffffffc00031c808 netbsd:drmfb_attach+0x1d0 sunxi_fb_attach() at ffffffc00005a648 netbsd:sunxi_fb_attach+0xd0 config_attach_loc() at ffffffc0004a7174 netbsd:config_attach_loc+0x184 config_found_sm_loc() at ffffffc0004a72a0 netbsd:config_found_sm_loc+0x58 sunxi_drm_fb_probe() at ffffffc00005a078 netbsd:sunxi_drm_fb_probe+0x250 __drm_fb_helper_initial_config_and_unlock() at ffffffc000342bdc netbsd:__drm_fb_helper_initial_config_and_unlock+0x2a4 sunxi_drm_load() at ffffffc00005a384 netbsd:sunxi_drm_load+0x154 drm_dev_register() at ffffffc00033b728 netbsd:drm_dev_register+0xe0 sunxi_drm_init() at ffffffc000059d40 netbsd:sunxi_drm_init+0x20 config_process_deferred() at ffffffc0004a6efc netbsd:config_process_deferred+0xac config_attach_loc() at ffffffc0004a7190 netbsd:config_attach_loc+0x1a0 config_found_sm_loc() at ffffffc0004a72a0 netbsd:config_found_sm_loc+0x58 arm_fdt_attach() at ffffffc000061e34 netbsd:arm_fdt_attach+0x64 config_attach_loc() at ffffffc0004a7174 netbsd:config_attach_loc+0x184 cpu_configure() at ffffffc00005dab4 netbsd:cpu_configure+0x44 main() at ffffffc000605284 netbsd:main+0x2b4 aarch64_start() at ffffffc000001854 netbsd:aarch64_start+0x1054 Author: Maya Rashish <maya@NetBSD.org> Committer: Taylor R Campbell <riastradh@NetBSD.org> 1.6 Sun Dec 19 11:25:25 GMT 2021 riastradh Defer call to drmfb_attach, otherwise we lock against ourselves Mutex error: mutex_vector_enter,542: locking against myself lockdebug_abort() at ffffffc0004ba3ec netbsd:lockdebug_abort+0xcc mutex_enter() at ffffffc000476af4 netbsd:mutex_enter+0x3d4 drm_fb_helper_restore_fbdev_mode_unlocked() at ffffffc0003432a8 netbsd:drm_fb_helper_restore_fbdev_mode_unlocked+0x60 drmfb_genfb_setmode() at ffffffc00031c428 netbsd:drmfb_genfb_setmode+0x18 genfb_attach() at ffffffc000377b04 netbsd:genfb_attach+0x10c drmfb_attach() at ffffffc00031c808 netbsd:drmfb_attach+0x1d0 sunxi_fb_attach() at ffffffc00005a648 netbsd:sunxi_fb_attach+0xd0 config_attach_loc() at ffffffc0004a7174 netbsd:config_attach_loc+0x184 config_found_sm_loc() at ffffffc0004a72a0 netbsd:config_found_sm_loc+0x58 sunxi_drm_fb_probe() at ffffffc00005a078 netbsd:sunxi_drm_fb_probe+0x250 __drm_fb_helper_initial_config_and_unlock() at ffffffc000342bdc netbsd:__drm_fb_helper_initial_config_and_unlock+0x2a4 sunxi_drm_load() at ffffffc00005a384 netbsd:sunxi_drm_load+0x154 drm_dev_register() at ffffffc00033b728 netbsd:drm_dev_register+0xe0 sunxi_drm_init() at ffffffc000059d40 netbsd:sunxi_drm_init+0x20 config_process_deferred() at ffffffc0004a6efc netbsd:config_process_deferred+0xac config_attach_loc() at ffffffc0004a7190 netbsd:config_attach_loc+0x1a0 config_found_sm_loc() at ffffffc0004a72a0 netbsd:config_found_sm_loc+0x58 arm_fdt_attach() at ffffffc000061e34 netbsd:arm_fdt_attach+0x64 config_attach_loc() at ffffffc0004a7174 netbsd:config_attach_loc+0x184 cpu_configure() at ffffffc00005dab4 netbsd:cpu_configure+0x44 main() at ffffffc000605284 netbsd:main+0x2b4 aarch64_start() at ffffffc000001854 netbsd:aarch64_start+0x1054 Author: Maya Rashish <maya@NetBSD.org> Committer: Taylor R Campbell <riastradh@NetBSD.org> 1.6 Sun Dec 19 11:25:25 GMT 2021 riastradh Defer call to drmfb_attach, otherwise we lock against ourselves Mutex error: mutex_vector_enter,542: locking against myself lockdebug_abort() at ffffffc0004ba3ec netbsd:lockdebug_abort+0xcc mutex_enter() at ffffffc000476af4 netbsd:mutex_enter+0x3d4 drm_fb_helper_restore_fbdev_mode_unlocked() at ffffffc0003432a8 netbsd:drm_fb_helper_restore_fbdev_mode_unlocked+0x60 drmfb_genfb_setmode() at ffffffc00031c428 netbsd:drmfb_genfb_setmode+0x18 genfb_attach() at ffffffc000377b04 netbsd:genfb_attach+0x10c drmfb_attach() at ffffffc00031c808 netbsd:drmfb_attach+0x1d0 sunxi_fb_attach() at ffffffc00005a648 netbsd:sunxi_fb_attach+0xd0 config_attach_loc() at ffffffc0004a7174 netbsd:config_attach_loc+0x184 config_found_sm_loc() at ffffffc0004a72a0 netbsd:config_found_sm_loc+0x58 sunxi_drm_fb_probe() at ffffffc00005a078 netbsd:sunxi_drm_fb_probe+0x250 __drm_fb_helper_initial_config_and_unlock() at ffffffc000342bdc netbsd:__drm_fb_helper_initial_config_and_unlock+0x2a4 sunxi_drm_load() at ffffffc00005a384 netbsd:sunxi_drm_load+0x154 drm_dev_register() at ffffffc00033b728 netbsd:drm_dev_register+0xe0 sunxi_drm_init() at ffffffc000059d40 netbsd:sunxi_drm_init+0x20 config_process_deferred() at ffffffc0004a6efc netbsd:config_process_deferred+0xac config_attach_loc() at ffffffc0004a7190 netbsd:config_attach_loc+0x1a0 config_found_sm_loc() at ffffffc0004a72a0 netbsd:config_found_sm_loc+0x58 arm_fdt_attach() at ffffffc000061e34 netbsd:arm_fdt_attach+0x64 config_attach_loc() at ffffffc0004a7174 netbsd:config_attach_loc+0x184 cpu_configure() at ffffffc00005dab4 netbsd:cpu_configure+0x44 main() at ffffffc000605284 netbsd:main+0x2b4 aarch64_start() at ffffffc000001854 netbsd:aarch64_start+0x1054 Author: Maya Rashish <maya@NetBSD.org> Committer: Taylor R Campbell <riastradh@NetBSD.org> 1.6 Sun Dec 19 11:25:25 GMT 2021 riastradh Defer call to drmfb_attach, otherwise we lock against ourselves Mutex error: mutex_vector_enter,542: locking against myself lockdebug_abort() at ffffffc0004ba3ec netbsd:lockdebug_abort+0xcc mutex_enter() at ffffffc000476af4 netbsd:mutex_enter+0x3d4 drm_fb_helper_restore_fbdev_mode_unlocked() at ffffffc0003432a8 netbsd:drm_fb_helper_restore_fbdev_mode_unlocked+0x60 drmfb_genfb_setmode() at ffffffc00031c428 netbsd:drmfb_genfb_setmode+0x18 genfb_attach() at ffffffc000377b04 netbsd:genfb_attach+0x10c drmfb_attach() at ffffffc00031c808 netbsd:drmfb_attach+0x1d0 sunxi_fb_attach() at ffffffc00005a648 netbsd:sunxi_fb_attach+0xd0 config_attach_loc() at ffffffc0004a7174 netbsd:config_attach_loc+0x184 config_found_sm_loc() at ffffffc0004a72a0 netbsd:config_found_sm_loc+0x58 sunxi_drm_fb_probe() at ffffffc00005a078 netbsd:sunxi_drm_fb_probe+0x250 __drm_fb_helper_initial_config_and_unlock() at ffffffc000342bdc netbsd:__drm_fb_helper_initial_config_and_unlock+0x2a4 sunxi_drm_load() at ffffffc00005a384 netbsd:sunxi_drm_load+0x154 drm_dev_register() at ffffffc00033b728 netbsd:drm_dev_register+0xe0 sunxi_drm_init() at ffffffc000059d40 netbsd:sunxi_drm_init+0x20 config_process_deferred() at ffffffc0004a6efc netbsd:config_process_deferred+0xac config_attach_loc() at ffffffc0004a7190 netbsd:config_attach_loc+0x1a0 config_found_sm_loc() at ffffffc0004a72a0 netbsd:config_found_sm_loc+0x58 arm_fdt_attach() at ffffffc000061e34 netbsd:arm_fdt_attach+0x64 config_attach_loc() at ffffffc0004a7174 netbsd:config_attach_loc+0x184 cpu_configure() at ffffffc00005dab4 netbsd:cpu_configure+0x44 main() at ffffffc000605284 netbsd:main+0x2b4 aarch64_start() at ffffffc000001854 netbsd:aarch64_start+0x1054 Author: Maya Rashish <maya@NetBSD.org> Committer: Taylor R Campbell <riastradh@NetBSD.org> 1.6 Sun Dec 19 11:25:25 GMT 2021 riastradh Defer call to drmfb_attach, otherwise we lock against ourselves Mutex error: mutex_vector_enter,542: locking against myself lockdebug_abort() at ffffffc0004ba3ec netbsd:lockdebug_abort+0xcc mutex_enter() at ffffffc000476af4 netbsd:mutex_enter+0x3d4 drm_fb_helper_restore_fbdev_mode_unlocked() at ffffffc0003432a8 netbsd:drm_fb_helper_restore_fbdev_mode_unlocked+0x60 drmfb_genfb_setmode() at ffffffc00031c428 netbsd:drmfb_genfb_setmode+0x18 genfb_attach() at ffffffc000377b04 netbsd:genfb_attach+0x10c drmfb_attach() at ffffffc00031c808 netbsd:drmfb_attach+0x1d0 sunxi_fb_attach() at ffffffc00005a648 netbsd:sunxi_fb_attach+0xd0 config_attach_loc() at ffffffc0004a7174 netbsd:config_attach_loc+0x184 config_found_sm_loc() at ffffffc0004a72a0 netbsd:config_found_sm_loc+0x58 sunxi_drm_fb_probe() at ffffffc00005a078 netbsd:sunxi_drm_fb_probe+0x250 __drm_fb_helper_initial_config_and_unlock() at ffffffc000342bdc netbsd:__drm_fb_helper_initial_config_and_unlock+0x2a4 sunxi_drm_load() at ffffffc00005a384 netbsd:sunxi_drm_load+0x154 drm_dev_register() at ffffffc00033b728 netbsd:drm_dev_register+0xe0 sunxi_drm_init() at ffffffc000059d40 netbsd:sunxi_drm_init+0x20 config_process_deferred() at ffffffc0004a6efc netbsd:config_process_deferred+0xac config_attach_loc() at ffffffc0004a7190 netbsd:config_attach_loc+0x1a0 config_found_sm_loc() at ffffffc0004a72a0 netbsd:config_found_sm_loc+0x58 arm_fdt_attach() at ffffffc000061e34 netbsd:arm_fdt_attach+0x64 config_attach_loc() at ffffffc0004a7174 netbsd:config_attach_loc+0x184 cpu_configure() at ffffffc00005dab4 netbsd:cpu_configure+0x44 main() at ffffffc000605284 netbsd:main+0x2b4 aarch64_start() at ffffffc000001854 netbsd:aarch64_start+0x1054 Author: Maya Rashish <maya@NetBSD.org> Committer: Taylor R Campbell <riastradh@NetBSD.org> 1.6 Sun Dec 19 11:25:25 GMT 2021 riastradh Defer call to drmfb_attach, otherwise we lock against ourselves Mutex error: mutex_vector_enter,542: locking against myself lockdebug_abort() at ffffffc0004ba3ec netbsd:lockdebug_abort+0xcc mutex_enter() at ffffffc000476af4 netbsd:mutex_enter+0x3d4 drm_fb_helper_restore_fbdev_mode_unlocked() at ffffffc0003432a8 netbsd:drm_fb_helper_restore_fbdev_mode_unlocked+0x60 drmfb_genfb_setmode() at ffffffc00031c428 netbsd:drmfb_genfb_setmode+0x18 genfb_attach() at ffffffc000377b04 netbsd:genfb_attach+0x10c drmfb_attach() at ffffffc00031c808 netbsd:drmfb_attach+0x1d0 sunxi_fb_attach() at ffffffc00005a648 netbsd:sunxi_fb_attach+0xd0 config_attach_loc() at ffffffc0004a7174 netbsd:config_attach_loc+0x184 config_found_sm_loc() at ffffffc0004a72a0 netbsd:config_found_sm_loc+0x58 sunxi_drm_fb_probe() at ffffffc00005a078 netbsd:sunxi_drm_fb_probe+0x250 __drm_fb_helper_initial_config_and_unlock() at ffffffc000342bdc netbsd:__drm_fb_helper_initial_config_and_unlock+0x2a4 sunxi_drm_load() at ffffffc00005a384 netbsd:sunxi_drm_load+0x154 drm_dev_register() at ffffffc00033b728 netbsd:drm_dev_register+0xe0 sunxi_drm_init() at ffffffc000059d40 netbsd:sunxi_drm_init+0x20 config_process_deferred() at ffffffc0004a6efc netbsd:config_process_deferred+0xac config_attach_loc() at ffffffc0004a7190 netbsd:config_attach_loc+0x1a0 config_found_sm_loc() at ffffffc0004a72a0 netbsd:config_found_sm_loc+0x58 arm_fdt_attach() at ffffffc000061e34 netbsd:arm_fdt_attach+0x64 config_attach_loc() at ffffffc0004a7174 netbsd:config_attach_loc+0x184 cpu_configure() at ffffffc00005dab4 netbsd:cpu_configure+0x44 main() at ffffffc000605284 netbsd:main+0x2b4 aarch64_start() at ffffffc000001854 netbsd:aarch64_start+0x1054 Author: Maya Rashish <maya@NetBSD.org> Committer: Taylor R Campbell <riastradh@NetBSD.org> 1.6 Sun Dec 19 11:25:25 GMT 2021 riastradh Defer call to drmfb_attach, otherwise we lock against ourselves Mutex error: mutex_vector_enter,542: locking against myself lockdebug_abort() at ffffffc0004ba3ec netbsd:lockdebug_abort+0xcc mutex_enter() at ffffffc000476af4 netbsd:mutex_enter+0x3d4 drm_fb_helper_restore_fbdev_mode_unlocked() at ffffffc0003432a8 netbsd:drm_fb_helper_restore_fbdev_mode_unlocked+0x60 drmfb_genfb_setmode() at ffffffc00031c428 netbsd:drmfb_genfb_setmode+0x18 genfb_attach() at ffffffc000377b04 netbsd:genfb_attach+0x10c drmfb_attach() at ffffffc00031c808 netbsd:drmfb_attach+0x1d0 sunxi_fb_attach() at ffffffc00005a648 netbsd:sunxi_fb_attach+0xd0 config_attach_loc() at ffffffc0004a7174 netbsd:config_attach_loc+0x184 config_found_sm_loc() at ffffffc0004a72a0 netbsd:config_found_sm_loc+0x58 sunxi_drm_fb_probe() at ffffffc00005a078 netbsd:sunxi_drm_fb_probe+0x250 __drm_fb_helper_initial_config_and_unlock() at ffffffc000342bdc netbsd:__drm_fb_helper_initial_config_and_unlock+0x2a4 sunxi_drm_load() at ffffffc00005a384 netbsd:sunxi_drm_load+0x154 drm_dev_register() at ffffffc00033b728 netbsd:drm_dev_register+0xe0 sunxi_drm_init() at ffffffc000059d40 netbsd:sunxi_drm_init+0x20 config_process_deferred() at ffffffc0004a6efc netbsd:config_process_deferred+0xac config_attach_loc() at ffffffc0004a7190 netbsd:config_attach_loc+0x1a0 config_found_sm_loc() at ffffffc0004a72a0 netbsd:config_found_sm_loc+0x58 arm_fdt_attach() at ffffffc000061e34 netbsd:arm_fdt_attach+0x64 config_attach_loc() at ffffffc0004a7174 netbsd:config_attach_loc+0x184 cpu_configure() at ffffffc00005dab4 netbsd:cpu_configure+0x44 main() at ffffffc000605284 netbsd:main+0x2b4 aarch64_start() at ffffffc000001854 netbsd:aarch64_start+0x1054 Author: Maya Rashish <maya@NetBSD.org> Committer: Taylor R Campbell <riastradh@NetBSD.org> 1.6 Sun Dec 19 11:25:25 GMT 2021 riastradh Defer call to drmfb_attach, otherwise we lock against ourselves Mutex error: mutex_vector_enter,542: locking against myself lockdebug_abort() at ffffffc0004ba3ec netbsd:lockdebug_abort+0xcc mutex_enter() at ffffffc000476af4 netbsd:mutex_enter+0x3d4 drm_fb_helper_restore_fbdev_mode_unlocked() at ffffffc0003432a8 netbsd:drm_fb_helper_restore_fbdev_mode_unlocked+0x60 drmfb_genfb_setmode() at ffffffc00031c428 netbsd:drmfb_genfb_setmode+0x18 genfb_attach() at ffffffc000377b04 netbsd:genfb_attach+0x10c drmfb_attach() at ffffffc00031c808 netbsd:drmfb_attach+0x1d0 sunxi_fb_attach() at ffffffc00005a648 netbsd:sunxi_fb_attach+0xd0 config_attach_loc() at ffffffc0004a7174 netbsd:config_attach_loc+0x184 config_found_sm_loc() at ffffffc0004a72a0 netbsd:config_found_sm_loc+0x58 sunxi_drm_fb_probe() at ffffffc00005a078 netbsd:sunxi_drm_fb_probe+0x250 __drm_fb_helper_initial_config_and_unlock() at ffffffc000342bdc netbsd:__drm_fb_helper_initial_config_and_unlock+0x2a4 sunxi_drm_load() at ffffffc00005a384 netbsd:sunxi_drm_load+0x154 drm_dev_register() at ffffffc00033b728 netbsd:drm_dev_register+0xe0 sunxi_drm_init() at ffffffc000059d40 netbsd:sunxi_drm_init+0x20 config_process_deferred() at ffffffc0004a6efc netbsd:config_process_deferred+0xac config_attach_loc() at ffffffc0004a7190 netbsd:config_attach_loc+0x1a0 config_found_sm_loc() at ffffffc0004a72a0 netbsd:config_found_sm_loc+0x58 arm_fdt_attach() at ffffffc000061e34 netbsd:arm_fdt_attach+0x64 config_attach_loc() at ffffffc0004a7174 netbsd:config_attach_loc+0x184 cpu_configure() at ffffffc00005dab4 netbsd:cpu_configure+0x44 main() at ffffffc000605284 netbsd:main+0x2b4 aarch64_start() at ffffffc000001854 netbsd:aarch64_start+0x1054 Author: Maya Rashish <maya@NetBSD.org> Committer: Taylor R Campbell <riastradh@NetBSD.org> 1.6 Sun Dec 19 11:25:25 GMT 2021 riastradh Defer call to drmfb_attach, otherwise we lock against ourselves Mutex error: mutex_vector_enter,542: locking against myself lockdebug_abort() at ffffffc0004ba3ec netbsd:lockdebug_abort+0xcc mutex_enter() at ffffffc000476af4 netbsd:mutex_enter+0x3d4 drm_fb_helper_restore_fbdev_mode_unlocked() at ffffffc0003432a8 netbsd:drm_fb_helper_restore_fbdev_mode_unlocked+0x60 drmfb_genfb_setmode() at ffffffc00031c428 netbsd:drmfb_genfb_setmode+0x18 genfb_attach() at ffffffc000377b04 netbsd:genfb_attach+0x10c drmfb_attach() at ffffffc00031c808 netbsd:drmfb_attach+0x1d0 sunxi_fb_attach() at ffffffc00005a648 netbsd:sunxi_fb_attach+0xd0 config_attach_loc() at ffffffc0004a7174 netbsd:config_attach_loc+0x184 config_found_sm_loc() at ffffffc0004a72a0 netbsd:config_found_sm_loc+0x58 sunxi_drm_fb_probe() at ffffffc00005a078 netbsd:sunxi_drm_fb_probe+0x250 __drm_fb_helper_initial_config_and_unlock() at ffffffc000342bdc netbsd:__drm_fb_helper_initial_config_and_unlock+0x2a4 sunxi_drm_load() at ffffffc00005a384 netbsd:sunxi_drm_load+0x154 drm_dev_register() at ffffffc00033b728 netbsd:drm_dev_register+0xe0 sunxi_drm_init() at ffffffc000059d40 netbsd:sunxi_drm_init+0x20 config_process_deferred() at ffffffc0004a6efc netbsd:config_process_deferred+0xac config_attach_loc() at ffffffc0004a7190 netbsd:config_attach_loc+0x1a0 config_found_sm_loc() at ffffffc0004a72a0 netbsd:config_found_sm_loc+0x58 arm_fdt_attach() at ffffffc000061e34 netbsd:arm_fdt_attach+0x64 config_attach_loc() at ffffffc0004a7174 netbsd:config_attach_loc+0x184 cpu_configure() at ffffffc00005dab4 netbsd:cpu_configure+0x44 main() at ffffffc000605284 netbsd:main+0x2b4 aarch64_start() at ffffffc000001854 netbsd:aarch64_start+0x1054 Author: Maya Rashish <maya@NetBSD.org> Committer: Taylor R Campbell <riastradh@NetBSD.org> |
| /src/sys/crypto/aes/arch/arm/ | ||
| H A D | files.aesarmv8 | 1.1 Mon Jun 29 23:31:41 GMT 2020 riastradh Implement AES in kernel using ARMv8.0-AES on aarch64. |
| /src/share/i18n/csmapper/EBCDIC/ | ||
| H A D | UCS%EBCDIC-US.src | 1.2 Sun Nov 08 10:37:52 GMT 2009 tnozaki lib/42209 various problems with EBCDIC support in iconv(3) 1. RFC1345 have wrong conversion table, 0x00-0x1F is not EBCDIC but ISO-8. 2. correct DST_INVALID. CP1141 is not added yet. 1.2 Sun Nov 08 10:37:52 GMT 2009 tnozaki lib/42209 various problems with EBCDIC support in iconv(3) 1. RFC1345 have wrong conversion table, 0x00-0x1F is not EBCDIC but ISO-8. 2. correct DST_INVALID. CP1141 is not added yet. 1.1 Sat Oct 31 15:06:52 GMT 2009 tnozaki lib/42209 various problems with EBCDIC support in iconv(3) 1. add EBCDIC-US conversion table. 2. RFC1345 have wrong conversion table, 0x00-0x1F is not EBCDIC but ISO-8. (CP273 and CP1141 is not yet) 1.1 Sat Oct 31 15:06:52 GMT 2009 tnozaki lib/42209 various problems with EBCDIC support in iconv(3) 1. add EBCDIC-US conversion table. 2. RFC1345 have wrong conversion table, 0x00-0x1F is not EBCDIC but ISO-8. (CP273 and CP1141 is not yet) |
| /src/sbin/mount_puffs/ | ||
| H A D | Makefile | 1.1 Thu Jan 14 21:25:48 GMT 2010 pooka Add a generic puffs kernel utility for querying mount arguments. E.g.: golem> dtfs -r 'chr 15 25' dtfs /puffs golem> mount_puffs -o getargs dtfs /puffs version=26, flags=0x10, root cookie=0xbb90c0c0, root type=VCHR, root size=0, root rdev=0xf19 1.1 Thu Jan 14 21:25:48 GMT 2010 pooka Add a generic puffs kernel utility for querying mount arguments. E.g.: golem> dtfs -r 'chr 15 25' dtfs /puffs golem> mount_puffs -o getargs dtfs /puffs version=26, flags=0x10, root cookie=0xbb90c0c0, root type=VCHR, root size=0, root rdev=0xf19 1.1 Thu Jan 14 21:25:48 GMT 2010 pooka Add a generic puffs kernel utility for querying mount arguments. E.g.: golem> dtfs -r 'chr 15 25' dtfs /puffs golem> mount_puffs -o getargs dtfs /puffs version=26, flags=0x10, root cookie=0xbb90c0c0, root type=VCHR, root size=0, root rdev=0xf19 1.1 Thu Jan 14 21:25:48 GMT 2010 pooka Add a generic puffs kernel utility for querying mount arguments. E.g.: golem> dtfs -r 'chr 15 25' dtfs /puffs golem> mount_puffs -o getargs dtfs /puffs version=26, flags=0x10, root cookie=0xbb90c0c0, root type=VCHR, root size=0, root rdev=0xf19 |
| /src/lib/libm/src/ | ||
| H A D | s_exp2f.c | 1.2 Sun Mar 16 22:30:43 GMT 2014 dsl Fix overflow and underflow on i386. The return value of a 'float' function is in the x87 %st(0) register. This is an 80bit 'long double' register. If you multiply 0x1p100f by 0x1p100f the caller sees 0x1p200 - not the expected infinity. So use a 'double' value which goes through a store-load sequence to generate the required exception and value. 1.2 Sun Mar 16 22:30:43 GMT 2014 dsl Fix overflow and underflow on i386. The return value of a 'float' function is in the x87 %st(0) register. This is an 80bit 'long double' register. If you multiply 0x1p100f by 0x1p100f the caller sees 0x1p200 - not the expected infinity. So use a 'double' value which goes through a store-load sequence to generate the required exception and value. 1.2 Sun Mar 16 22:30:43 GMT 2014 dsl Fix overflow and underflow on i386. The return value of a 'float' function is in the x87 %st(0) register. This is an 80bit 'long double' register. If you multiply 0x1p100f by 0x1p100f the caller sees 0x1p200 - not the expected infinity. So use a 'double' value which goes through a store-load sequence to generate the required exception and value. 1.2 Sun Mar 16 22:30:43 GMT 2014 dsl Fix overflow and underflow on i386. The return value of a 'float' function is in the x87 %st(0) register. This is an 80bit 'long double' register. If you multiply 0x1p100f by 0x1p100f the caller sees 0x1p200 - not the expected infinity. So use a 'double' value which goes through a store-load sequence to generate the required exception and value. |
| /src/share/i18n/csmapper/JIS/ | ||
| H A D | JISX0201-KANA%UCS.src | 1.3 Thu Oct 26 16:19:02 GMT 2006 tnozaki remove unessesary 0x00-0x20, 0x60-0x7F mapping. 1.3 Thu Oct 26 16:19:02 GMT 2006 tnozaki remove unessesary 0x00-0x20, 0x60-0x7F mapping. 1.3 Thu Oct 26 16:19:02 GMT 2006 tnozaki remove unessesary 0x00-0x20, 0x60-0x7F mapping. 1.3 Thu Oct 26 16:19:02 GMT 2006 tnozaki remove unessesary 0x00-0x20, 0x60-0x7F mapping. |
Completed in 68 milliseconds