mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 21:42:43 +00:00 
			
		
		
		
	AK: Remove custom %b format string specifier
This was a non-standard specifier alias for %02x. This patch replaces all uses of it with new-style formatting functions instead.
This commit is contained in:
		
							parent
							
								
									89d3b09638
								
							
						
					
					
						commit
						cb2c8f71f4
					
				
					 12 changed files with 27 additions and 28 deletions
				
			
		|  | @ -390,10 +390,6 @@ struct PrintfImpl { | ||||||
|     { |     { | ||||||
|         return print_hex(m_putch, m_bufptr, NextArgument<int>()(ap), false, state.alternate_form, false, true, 4); |         return print_hex(m_putch, m_bufptr, NextArgument<int>()(ap), false, state.alternate_form, false, true, 4); | ||||||
|     } |     } | ||||||
|     ALWAYS_INLINE int format_b(const ModifierState& state, ArgumentListRefT ap) const |  | ||||||
|     { |  | ||||||
|         return print_hex(m_putch, m_bufptr, NextArgument<int>()(ap), false, state.alternate_form, false, true, 2); |  | ||||||
|     } |  | ||||||
|     ALWAYS_INLINE int format_c(const ModifierState& state, ArgumentListRefT ap) const |     ALWAYS_INLINE int format_c(const ModifierState& state, ArgumentListRefT ap) const | ||||||
|     { |     { | ||||||
|         char c = NextArgument<int>()(ap); |         char c = NextArgument<int>()(ap); | ||||||
|  | @ -502,7 +498,6 @@ ALWAYS_INLINE int printf_internal(PutChFunc putch, char* buffer, const char*& fm | ||||||
|                 PRINTF_IMPL_DELEGATE_TO_IMPL(P); |                 PRINTF_IMPL_DELEGATE_TO_IMPL(P); | ||||||
|                 PRINTF_IMPL_DELEGATE_TO_IMPL(Q); |                 PRINTF_IMPL_DELEGATE_TO_IMPL(Q); | ||||||
|                 PRINTF_IMPL_DELEGATE_TO_IMPL(X); |                 PRINTF_IMPL_DELEGATE_TO_IMPL(X); | ||||||
|                 PRINTF_IMPL_DELEGATE_TO_IMPL(b); |  | ||||||
|                 PRINTF_IMPL_DELEGATE_TO_IMPL(c); |                 PRINTF_IMPL_DELEGATE_TO_IMPL(c); | ||||||
|                 PRINTF_IMPL_DELEGATE_TO_IMPL(d); |                 PRINTF_IMPL_DELEGATE_TO_IMPL(d); | ||||||
| #ifndef KERNEL | #ifndef KERNEL | ||||||
|  |  | ||||||
|  | @ -345,7 +345,7 @@ FontEditorWidget::FontEditorWidget(const String& path, RefPtr<Gfx::Font>&& edite | ||||||
|         m_glyph_editor_widget->set_glyph(glyph); |         m_glyph_editor_widget->set_glyph(glyph); | ||||||
|         glyph_width_spinbox.set_value(m_edited_font->glyph_width(m_glyph_map_widget->selected_glyph())); |         glyph_width_spinbox.set_value(m_edited_font->glyph_width(m_glyph_map_widget->selected_glyph())); | ||||||
|         StringBuilder builder; |         StringBuilder builder; | ||||||
|         builder.appendf("0x%b (", glyph); |         builder.appendff("{:#02x} (", glyph); | ||||||
|         if (glyph < 128) { |         if (glyph < 128) { | ||||||
|             builder.append(glyph); |             builder.append(glyph); | ||||||
|         } else { |         } else { | ||||||
|  |  | ||||||
|  | @ -296,7 +296,7 @@ void KeyboardDevice::irq_handle_byte_read(u8 byte) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| #ifdef KEYBOARD_DEBUG | #ifdef KEYBOARD_DEBUG | ||||||
|     dbg() << "Keyboard::irq_handle_byte_read: " << String::format("%b", ch) << " " << (pressed ? "down" : "up"); |     dbgln("Keyboard::irq_handle_byte_read: {:#02x} {}", ch, (pressed ? "down" : "up")); | ||||||
| #endif | #endif | ||||||
|     switch (ch) { |     switch (ch) { | ||||||
|     case 0x38: |     case 0x38: | ||||||
|  |  | ||||||
|  | @ -217,7 +217,7 @@ E1000NetworkAdapter::E1000NetworkAdapter(PCI::Address address, u8 irq) | ||||||
|     klog() << "E1000: Has EEPROM? " << m_has_eeprom; |     klog() << "E1000: Has EEPROM? " << m_has_eeprom; | ||||||
|     read_mac_address(); |     read_mac_address(); | ||||||
|     const auto& mac = mac_address(); |     const auto& mac = mac_address(); | ||||||
|     klog() << "E1000: MAC address: " << String::format("%b", mac[0]) << ":" << String::format("%b", mac[1]) << ":" << String::format("%b", mac[2]) << ":" << String::format("%b", mac[3]) << ":" << String::format("%b", mac[4]) << ":" << String::format("%b", mac[5]); |     klog() << "E1000: MAC address: " << mac.to_string(); | ||||||
| 
 | 
 | ||||||
|     u32 flags = in32(REG_CTRL); |     u32 flags = in32(REG_CTRL); | ||||||
|     out32(REG_CTRL, flags | ECTRL_SLU); |     out32(REG_CTRL, flags | ECTRL_SLU); | ||||||
|  | @ -458,7 +458,7 @@ void E1000NetworkAdapter::send_raw(ReadonlyBytes payload) | ||||||
|         m_wait_queue.wait_on(nullptr, "E1000NetworkAdapter"); |         m_wait_queue.wait_on(nullptr, "E1000NetworkAdapter"); | ||||||
|     } |     } | ||||||
| #ifdef E1000_DEBUG | #ifdef E1000_DEBUG | ||||||
|     klog() << "E1000: Sent packet, status is now " << String::format("%b", descriptor.status) << "!"; |     dbgln("E1000: Sent packet, status is now {:#02x}!", descriptor.status); | ||||||
| #endif | #endif | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -128,7 +128,7 @@ void NetworkTask_main(void*) | ||||||
| 
 | 
 | ||||||
| #ifdef ETHERNET_VERY_DEBUG | #ifdef ETHERNET_VERY_DEBUG | ||||||
|         for (size_t i = 0; i < packet_size; i++) { |         for (size_t i = 0; i < packet_size; i++) { | ||||||
|             klog() << String::format("%b", buffer[i]); |             klog() << String::format("%#02x", buffer[i]); | ||||||
| 
 | 
 | ||||||
|             switch (i % 16) { |             switch (i % 16) { | ||||||
|             case 7: |             case 7: | ||||||
|  | @ -249,7 +249,7 @@ void handle_icmp(const EthernetFrameHeader& eth, const IPv4Packet& ipv4_packet, | ||||||
| { | { | ||||||
|     auto& icmp_header = *static_cast<const ICMPHeader*>(ipv4_packet.payload()); |     auto& icmp_header = *static_cast<const ICMPHeader*>(ipv4_packet.payload()); | ||||||
| #ifdef ICMP_DEBUG | #ifdef ICMP_DEBUG | ||||||
|     klog() << "handle_icmp: source=" << ipv4_packet.source().to_string().characters() << ", destination=" << ipv4_packet.destination().to_string().characters() << ", type=" << String::format("%b", icmp_header.type()) << ", code=" << String::format("%b", icmp_header.code()); |     dbgln("handle_icmp: source={}, destination={}, type={:#02x}, code={:#02x}", ipv4_packet.source().to_string(), ipv4_packet.destination().to_string(), icmp_header.type(), icmp_header.code()); | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|     { |     { | ||||||
|  |  | ||||||
|  | @ -144,7 +144,7 @@ protected: | ||||||
| 
 | 
 | ||||||
| inline const LogStream& operator<<(const LogStream& stream, const Address value) | inline const LogStream& operator<<(const LogStream& stream, const Address value) | ||||||
| { | { | ||||||
|     return stream << "PCI [" << String::format("%w", value.seg()) << ":" << String::format("%b", value.bus()) << ":" << String::format("%b", value.slot()) << "." << String::format("%b", value.function()) << "]"; |     return stream << "PCI [" << String::formatted("{:04x}:{:02x}:{:02x}:{:02x}", value.seg(), value.bus(), value.slot(), value.function()) << "]"; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| struct ChangeableAddress : public Address { | struct ChangeableAddress : public Address { | ||||||
|  |  | ||||||
|  | @ -131,7 +131,7 @@ MMIOAccess::MMIOAccess(PhysicalAddress p_mcfg) | ||||||
|         m_mapped_device_regions.append(make<DeviceConfigurationSpaceMapping>(address, m_segments.get(address.seg()).value())); |         m_mapped_device_regions.append(make<DeviceConfigurationSpaceMapping>(address, m_segments.get(address.seg()).value())); | ||||||
|         m_physical_ids.append({ address, id, get_capabilities(address) }); |         m_physical_ids.append({ address, id, get_capabilities(address) }); | ||||||
| #ifdef PCI_DEBUG | #ifdef PCI_DEBUG | ||||||
|         dbg() << "PCI: Mapping device @ pci (" << String::format("%w", address.seg()) << ":" << String::format("%b", address.bus()) << ":" << String::format("%b", address.slot()) << "." << String::format("%b", address.function()) << ")" |         dbg() << "PCI: Mapping device @ pci (" << address << ")" | ||||||
|               << " " << m_mapped_device_regions.last().vaddr() << " " << m_mapped_device_regions.last().paddr(); |               << " " << m_mapped_device_regions.last().vaddr() << " " << m_mapped_device_regions.last().paddr(); | ||||||
| #endif | #endif | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
|  | @ -256,7 +256,7 @@ void IDEChannel::handle_irq(const RegisterState&) | ||||||
|     if (status & ATA_SR_ERR) { |     if (status & ATA_SR_ERR) { | ||||||
|         print_ide_status(status); |         print_ide_status(status); | ||||||
|         m_device_error = m_io_group.io_base().offset(ATA_REG_ERROR).in<u8>(); |         m_device_error = m_io_group.io_base().offset(ATA_REG_ERROR).in<u8>(); | ||||||
|         klog() << "IDEChannel: Error " << String::format("%b", m_device_error) << "!"; |         dbgln("IDEChannel: Error {:#02x}!", (u8)m_device_error); | ||||||
|         complete_current_request(AsyncDeviceRequest::Failure); |         complete_current_request(AsyncDeviceRequest::Failure); | ||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
|  | @ -557,8 +557,8 @@ void IDEChannel::ata_do_write_sector() | ||||||
|     ASSERT(status & ATA_SR_DRQ); |     ASSERT(status & ATA_SR_DRQ); | ||||||
| 
 | 
 | ||||||
|     auto in_buffer = request.buffer().offset(m_current_request_block_index * 512); |     auto in_buffer = request.buffer().offset(m_current_request_block_index * 512); | ||||||
| #ifdef PATA_DEBUG | #ifndef PATA_DEBUG | ||||||
|     dbg() << "IDEChannel: Writing 512 bytes (part " << m_current_request_block_index << ") (status=" << String::format("%b", status) << ")..."; |     dbgln("IDEChannel: Writing 512 bytes (part {}) (status={:#02x})...", m_current_request_block_index, status); | ||||||
| #endif | #endif | ||||||
|     ssize_t nread = request.read_from_buffer_buffered<512>(in_buffer, 512, [&](const u8* buffer, size_t buffer_bytes) { |     ssize_t nread = request.read_from_buffer_buffered<512>(in_buffer, 512, [&](const u8* buffer, size_t buffer_bytes) { | ||||||
|         for (size_t i = 0; i < buffer_bytes; i += sizeof(u16)) |         for (size_t i = 0; i < buffer_bytes; i += sizeof(u16)) | ||||||
|  |  | ||||||
|  | @ -862,7 +862,6 @@ RefPtr<Thread> Thread::clone(Process& process) | ||||||
|     clone->m_signal_mask = m_signal_mask; |     clone->m_signal_mask = m_signal_mask; | ||||||
|     memcpy(clone->m_fpu_state, m_fpu_state, sizeof(FPUState)); |     memcpy(clone->m_fpu_state, m_fpu_state, sizeof(FPUState)); | ||||||
|     clone->m_thread_specific_data = m_thread_specific_data; |     clone->m_thread_specific_data = m_thread_specific_data; | ||||||
|     clone->m_thread_specific_region_size = m_thread_specific_region_size; |  | ||||||
|     return clone; |     return clone; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -1037,19 +1036,28 @@ Vector<FlatPtr> Thread::raw_backtrace(FlatPtr ebp, FlatPtr eip) const | ||||||
|     return backtrace; |     return backtrace; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | size_t Thread::thread_specific_region_alignment() const | ||||||
|  | { | ||||||
|  |     return max(process().m_master_tls_alignment, alignof(ThreadSpecificData)); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | size_t Thread::thread_specific_region_size() const | ||||||
|  | { | ||||||
|  |     return align_up_to(process().m_master_tls_size, thread_specific_region_alignment()) + sizeof(ThreadSpecificData); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| KResult Thread::make_thread_specific_region(Badge<Process>) | KResult Thread::make_thread_specific_region(Badge<Process>) | ||||||
| { | { | ||||||
|     // The process may not require a TLS region
 |     // The process may not require a TLS region
 | ||||||
|     if (!process().m_master_tls_region) |     if (!process().m_master_tls_region) | ||||||
|         return KSuccess; |         return KSuccess; | ||||||
| 
 | 
 | ||||||
|     size_t thread_specific_region_alignment = max(process().m_master_tls_alignment, alignof(ThreadSpecificData)); |     auto* region = process().allocate_region({}, thread_specific_region_size(), "Thread-specific", PROT_READ | PROT_WRITE, true); | ||||||
|     m_thread_specific_region_size = align_up_to(process().m_master_tls_size, thread_specific_region_alignment) + sizeof(ThreadSpecificData); |  | ||||||
|     auto* region = process().allocate_region({}, m_thread_specific_region_size, "Thread-specific", PROT_READ | PROT_WRITE, true); |  | ||||||
|     if (!region) |     if (!region) | ||||||
|         return KResult(-ENOMEM); |         return KResult(-ENOMEM); | ||||||
|  | 
 | ||||||
|     SmapDisabler disabler; |     SmapDisabler disabler; | ||||||
|     auto* thread_specific_data = (ThreadSpecificData*)region->vaddr().offset(align_up_to(process().m_master_tls_size, thread_specific_region_alignment)).as_ptr(); |     auto* thread_specific_data = (ThreadSpecificData*)region->vaddr().offset(align_up_to(process().m_master_tls_size, thread_specific_region_alignment())).as_ptr(); | ||||||
|     auto* thread_local_storage = (u8*)((u8*)thread_specific_data) - align_up_to(process().m_master_tls_size, process().m_master_tls_alignment); |     auto* thread_local_storage = (u8*)((u8*)thread_specific_data) - align_up_to(process().m_master_tls_size, process().m_master_tls_alignment); | ||||||
|     m_thread_specific_data = VirtualAddress(thread_specific_data); |     m_thread_specific_data = VirtualAddress(thread_specific_data); | ||||||
|     thread_specific_data->self = thread_specific_data; |     thread_specific_data->self = thread_specific_data; | ||||||
|  |  | ||||||
|  | @ -758,7 +758,8 @@ public: | ||||||
|     const char* state_string() const; |     const char* state_string() const; | ||||||
| 
 | 
 | ||||||
|     VirtualAddress thread_specific_data() const { return m_thread_specific_data; } |     VirtualAddress thread_specific_data() const { return m_thread_specific_data; } | ||||||
|     size_t thread_specific_region_size() const { return m_thread_specific_region_size; } |     size_t thread_specific_region_size() const; | ||||||
|  |     size_t thread_specific_region_alignment() const; | ||||||
| 
 | 
 | ||||||
|     ALWAYS_INLINE void yield_if_stopped() |     ALWAYS_INLINE void yield_if_stopped() | ||||||
|     { |     { | ||||||
|  | @ -1198,7 +1199,6 @@ private: | ||||||
|     u32 m_kernel_stack_top { 0 }; |     u32 m_kernel_stack_top { 0 }; | ||||||
|     OwnPtr<Region> m_kernel_stack_region; |     OwnPtr<Region> m_kernel_stack_region; | ||||||
|     VirtualAddress m_thread_specific_data; |     VirtualAddress m_thread_specific_data; | ||||||
|     size_t m_thread_specific_region_size { 0 }; |  | ||||||
|     SignalActionData m_signal_action_data[32]; |     SignalActionData m_signal_action_data[32]; | ||||||
|     Blocker* m_blocker { nullptr }; |     Blocker* m_blocker { nullptr }; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -824,7 +824,7 @@ void Terminal::DSR(const ParamVector& params) | ||||||
| void Terminal::on_input(u8 ch) | void Terminal::on_input(u8 ch) | ||||||
| { | { | ||||||
| #ifdef TERMINAL_DEBUG | #ifdef TERMINAL_DEBUG | ||||||
|     dbgprintf("Terminal::on_char: %b (%c), fg=%u, bg=%u\n", ch, ch, m_current_attribute.foreground_color, m_current_attribute.background_color); |     dbgln("Terminal::on_input: {:#02x} ({:c}), fg={}, bg={}\n", ch, ch, m_current_attribute.foreground_color, m_current_attribute.background_color); | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|     auto fail_utf8_parse = [this] { |     auto fail_utf8_parse = [this] { | ||||||
|  |  | ||||||
|  | @ -46,10 +46,6 @@ struct PrintfImpl : public PrintfImplementation::PrintfImpl<PutChFunc, ArgumentL | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     ALWAYS_INLINE int format_b(const PrintfImplementation::ModifierState&, ArgumentListRefT&) const |  | ||||||
|     { |  | ||||||
|         fail("format specifier 'b' is not supported"); |  | ||||||
|     } |  | ||||||
|     ALWAYS_INLINE int format_q(const PrintfImplementation::ModifierState& state, ArgumentListRefT& ap) const |     ALWAYS_INLINE int format_q(const PrintfImplementation::ModifierState& state, ArgumentListRefT& ap) const | ||||||
|     { |     { | ||||||
|         auto state_copy = state; |         auto state_copy = state; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling