diff --git a/Jamfile b/Jamfile index 942323c29e..3ea234bde4 100644 --- a/Jamfile +++ b/Jamfile @@ -173,11 +173,7 @@ SubDir HAIKU_TOP ; UserBuildConfigRulePostBuildTargets ; # specify the Haiku image and network boot archive contents -if $(TARGET_ARCH) = x86_64 { - include [ FDirName $(HAIKU_BUILD_RULES_DIR) Haiku64Image ] ; -} else { - include [ FDirName $(HAIKU_BUILD_RULES_DIR) HaikuImage ] ; -} +include [ FDirName $(HAIKU_BUILD_RULES_DIR) HaikuImage ] ; include [ FDirName $(HAIKU_BUILD_RULES_DIR) NetBootArchive ] ; include [ FDirName $(HAIKU_BUILD_RULES_DIR) FloppyBootImage ] ; include [ FDirName $(HAIKU_BUILD_RULES_DIR) CDBootImage ] ; diff --git a/build/jam/HaikuImage b/build/jam/HaikuImage index 88aaee9128..ea469b1b19 100644 --- a/build/jam/HaikuImage +++ b/build/jam/HaikuImage @@ -100,10 +100,13 @@ SYSTEM_NETWORK_DATALINK_PROTOCOLS = ethernet_frame arp loopback_frame SYSTEM_NETWORK_PROTOCOLS = ipv4 tcp udp icmp unix icmp6 ipv6 ; SYSTEM_ADD_ONS_ACCELERANTS = [ FFilterByBuildFeatures + x86,x86_64 @{ + vesa.accelerant + }@ # x86,x86_64 x86 @{ 3dfx.accelerant ati.accelerant matrox.accelerant neomagic.accelerant nvidia.accelerant intel_810.accelerant intel_extreme.accelerant - radeon.accelerant radeon_hd.accelerant s3.accelerant vesa.accelerant + radeon.accelerant radeon_hd.accelerant s3.accelerant #via.accelerant vmware.accelerant }@ # x86 ] ; @@ -125,7 +128,7 @@ SYSTEM_ADD_ONS_MEDIA = [ FFilterByBuildFeatures usb_webcam.media_addon video_producer_demo.media_addon video_window_demo.media_addon - firewire_dv.media_addon + firewire_dv.media_addon@x86 #legacy.media_addon equalizer.media_addon vst_host.media_addon @@ -155,18 +158,21 @@ SYSTEM_ADD_ONS_SCREENSAVERS = [ FFilterByBuildFeatures SYSTEM_ADD_ONS_DRIVERS_AUDIO = auich auvia echo3g emuxki hda ice1712 sis7018 ; SYSTEM_ADD_ONS_DRIVERS_AUDIO_OLD = ; #cmedia usb_audio ; SYSTEM_ADD_ONS_DRIVERS_GRAPHICS = [ FFilterByBuildFeatures + x86,x86_64 @{ + vesa + }@ # x86,x86_64 x86 @{ ati 3dfx intel_810 intel_extreme matrox neomagic nvidia radeon radeon_hd - s3 vesa #via vmware + s3 #via vmware }@ # x86 ] ; SYSTEM_ADD_ONS_DRIVERS_MIDI = emuxki ice1712 usb_midi ; SYSTEM_ADD_ONS_DRIVERS_NET = [ FFilterByBuildFeatures - x86 @{ + x86,x86_64 @{ 3com atheros813x ar81xx attansic_l1 attansic_l2 broadcom440x broadcom570x dec21xxx ipro100 ipro1000 jmicron2x0 marvell_yukon nforce pcnet rtl8139 rtl81xx sis19x syskonnect via_rhine vt612x - }@ # x86 + }@ # x86_64 etherpci pegasus sis900 usb_davicom usb_asix usb_ecm wb840 @@ -183,11 +189,12 @@ SYSTEM_ADD_ONS_DRIVERS_NET = [ FFilterByBuildFeatures ] ; SYSTEM_ADD_ONS_DRIVERS_POWER = [ FFilterByBuildFeatures acpi_button@x86 ] ; SYSTEM_ADD_ONS_BUS_MANAGERS = [ FFilterByBuildFeatures - ata@ata pci ps2@x86 isa@x86 - ide@ide scsi config_manager agp_gart usb firewire acpi@x86 + ata@ata pci ps2@x86,x86_64 isa@x86,x86_64 + ide@ide scsi config_manager agp_gart@x86 usb firewire@x86 acpi@x86 ] ; SYSTEM_ADD_ONS_FILE_SYSTEMS = bfs bindfs btrfs cdda exfat ext2 fat iso9660 nfs - nfs4 attribute_overlay write_overlay ntfs packagefs reiserfs udf googlefs ; + nfs4 attribute_overlay write_overlay ntfs packagefs reiserfs@x86 udf + googlefs ; # build the haiku system package and add it diff --git a/build/jam/MiscRules b/build/jam/MiscRules index 784351d1ff..10108adf1c 100644 --- a/build/jam/MiscRules +++ b/build/jam/MiscRules @@ -512,7 +512,7 @@ rule FFilterByBuildFeatures list switch $(element) { case }@ : { - # Pop the topmost specificaton off the stack. + # Pop the topmost specification off the stack. evaluationStack = $(evaluationStack[2-]) ; if ! $(evaluationStack) { Exit "FFilterByBuildFeatures: Unbalanced @( in: " $(list) ; diff --git a/build/jam/packages/Haiku b/build/jam/packages/Haiku index 4195ab5242..a9fd70cc7d 100644 --- a/build/jam/packages/Haiku +++ b/build/jam/packages/Haiku @@ -42,13 +42,13 @@ AddFilesToPackage add-ons kernel debugger run_on_exit ; AddFilesToPackage add-ons kernel file_systems : $(SYSTEM_ADD_ONS_FILE_SYSTEMS) ; AddFilesToPackage add-ons kernel generic - : ata_adapter@ata bios@x86 dpc ide_adapter@ide + : ata_adapter@ata bios@x86,x86_64 dpc ide_adapter@ide locked_pool mpu401 scsi_periph tty ; AddFilesToPackage add-ons kernel partitioning_systems : amiga_rdb apple efi_gpt intel session ; AddFilesToPackage add-ons kernel interrupt_controllers : openpic@ppc ; -if $(TARGET_ARCH) = x86 { +if $(TARGET_ARCH) = x86 || $(TARGET_ARCH) = x86_64 { AddFilesToPackage add-ons kernel cpu : generic_x86 ; } @@ -64,7 +64,7 @@ AddDriversToPackage : console dprintf null random tty AddDriversToPackage audio hmulti : $(SYSTEM_ADD_ONS_DRIVERS_AUDIO) ; AddDriversToPackage audio old : $(SYSTEM_ADD_ONS_DRIVERS_AUDIO_OLD) ; AddDriversToPackage midi : $(SYSTEM_ADD_ONS_DRIVERS_MIDI) ; -AddDriversToPackage bus : usb_raw fw_raw ; +AddDriversToPackage bus : usb_raw fw_raw@x86 ; AddDriversToPackage disk floppy : pc_floppy@x86 ; AddDriversToPackage disk usb : usb_disk ; AddDriversToPackage disk usb : usb_floppy ; diff --git a/data/catalogs/add-ons/input_server/devices/keyboard/pt_BR.catkeys b/data/catalogs/add-ons/input_server/devices/keyboard/pt_BR.catkeys index 0dd28a58f3..e345e9ab9b 100644 --- a/data/catalogs/add-ons/input_server/devices/keyboard/pt_BR.catkeys +++ b/data/catalogs/add-ons/input_server/devices/keyboard/pt_BR.catkeys @@ -1,7 +1,7 @@ 1 portuguese (brazil) x-vnd.Haiku-KeyboardInputServerDevice 2536418998 Kill application Team monitor Matar aplicação Quit application Team monitor Fechar aplicativo -Select an application from the list above and click one of the buttons 'Kill application' and 'Quit application' in order to close it.\n\nHold CONTROL+ALT+DELETE for %ld seconds to reboot. Team monitor Selecione uma aplicação da lista acima e clique um dos botões 'Matar aplicativo' e 'Fechar aplicativo' de maneira a fechá-lo.\n\nPressione CONTROL+ALT+DELETE por %ld segundos para reiniciar. +Select an application from the list above and click one of the buttons 'Kill application' and 'Quit application' in order to close it.\n\nHold CONTROL+ALT+DELETE for %ld seconds to reboot. Team monitor Selecione um aplicativo da lista acima e clique um dos botões 'Matar aplicativo' e 'Fechar aplicativo' de maneira a fechá-lo.\n\nPressione CONTROL+ALT+DELETE por %ld segundos para reiniciar. If the application will not quit you may have to kill it. Team monitor Se a aplicação não fechar, você deve matá-la. Force reboot Team monitor Forçar a reinicialização Team monitor Team monitor Monitor de equipe diff --git a/data/catalogs/add-ons/translators/gif/pt_BR.catkeys b/data/catalogs/add-ons/translators/gif/pt_BR.catkeys index 28d7e456ec..ac6f390946 100644 --- a/data/catalogs/add-ons/translators/gif/pt_BR.catkeys +++ b/data/catalogs/add-ons/translators/gif/pt_BR.catkeys @@ -1,11 +1,11 @@ 1 portuguese (brazil) x-vnd.Haiku-GIFTranslator 2708495435 Websafe GIFView Websafe Write interlaced images GIFView Escrever imagens entrelaçadas -Optimal GIFView Ideal +Optimal GIFView Ótimo Greyscale GIFView Escala de cinza Be Bitmap Format (GIFTranslator) GIFTranslator Formato de Mapa de Bits Be (Tradutor GIF) GIF image translator GIFView Tradutor de imagem GIF -GIF image GIFTranslator imagem GIF +GIF image GIFTranslator Imagem GIF Write transparent images GIFView Gravar imagens transparentes Palette GIFView Paleta Use RGB color GIFView Usar cor RGB diff --git a/data/catalogs/apps/deskbar/pt_BR.catkeys b/data/catalogs/apps/deskbar/pt_BR.catkeys index 55d70242bb..bf9581185b 100644 --- a/data/catalogs/apps/deskbar/pt_BR.catkeys +++ b/data/catalogs/apps/deskbar/pt_BR.catkeys @@ -1,16 +1,19 @@ -1 portuguese (brazil) x-vnd.Be-TSKB 1042823442 +1 portuguese (brazil) x-vnd.Be-TSKB 2335730970 Power off DeskbarMenu Desligar +Sort applications by name PreferencesWindow Ordenar aplicativos pelo nome Suspend DeskbarMenu Suspender Hide clock TimeView Ocultar relógio Applications PreferencesWindow Aplicativos Time preferences… TimeView Preferências de hora… About Haiku DeskbarMenu Sobre o Haiku +Edit in Tracker… PreferencesWindow Editar no Rastreador… Recent documents: PreferencesWindow Documentos recentes: Recent applications DeskbarMenu Aplicativos recentes Applications B_USER_DESKBAR_DIRECTORY/Applications Aplicativos Find… DeskbarMenu Localizar… Show clock Tray Exibir relógio Window PreferencesWindow Janela +Defaults PreferencesWindow Padrões Menu PreferencesWindow Menu Recent documents DeskbarMenu Documentos recentes Auto-hide PreferencesWindow Ocultar automaticamente @@ -28,6 +31,7 @@ Restart Tracker DeskbarMenu Reiniciar Rastreador Close all WindowMenu Fechar tudo Deskbar preferences PreferencesWindow Preferências da Deskbar Mount DeskbarMenu Montar +Revert PreferencesWindow Reverter Small PreferencesWindow Pequeno Recent applications: PreferencesWindow Aplicativos recentes: Shutdown… DeskbarMenu Desligar… diff --git a/data/catalogs/apps/terminal/pt_BR.catkeys b/data/catalogs/apps/terminal/pt_BR.catkeys index 3ed2a75e3d..0ee0309ab8 100644 --- a/data/catalogs/apps/terminal/pt_BR.catkeys +++ b/data/catalogs/apps/terminal/pt_BR.catkeys @@ -1,4 +1,4 @@ -1 portuguese (brazil) x-vnd.Haiku-Terminal 328707356 +1 portuguese (brazil) x-vnd.Haiku-Terminal 2967760334 Not found. Terminal TermWindow Não localizado. Switch Terminals Terminal TermWindow Alternar Terminais Change directory Terminal TermView Mudar de pasta @@ -79,6 +79,7 @@ Clear all Terminal TermWindow Limpar tudo Text encoding Terminal TermWindow Codificação de texto size Terminal TermView tamanho Close window Terminal TermWindow Fechar janela +\t%d\t-\tThe current working directory of the active process in the\n\t\t\tcurrent tab. Optionally the maximum number of path components\n\t\t\tcan be specified. E.g. '%2d' for at most two components.\n\t%T\t-\tThe Terminal application name for the current locale.\n\t%e\t-\tThe encoding of the current tab. Not shown for UTF-8.\n\t%i\t-\tThe index of the window.\n\t%p\t-\tThe name of the active process in the current tab.\n\t%t\t-\tThe title of the current tab.\n\t%%\t-\tThe character '%'. Terminal ToolTips \t%d\t-\tO diretório atualmente em uso do processo ativo na\n\t\t\tguia atual. Opcionalmente o número máximo de componentes do caminho\n\t\t\tpode ser especificado. Por exemplo, '%2d' para ao menos dois componentes.\n\t%T\t-\tO nome do aplicativo Terminal para a localidade atual.\n\t%e\t-\tA codificação da guia atual. Não exibido para UTF-8.\n\t%i\t-\tO índice da janela.\n\t%p\t-\tO nome do processo ativo na guia atual.\n\t%t\t-\tO título da guia atual.\n\t%%\t-\tO caractere '%'. Save as default Terminal TermWindow Salvar como padrão Set tab title Terminal TermWindow Definir o título da guia Settings… Terminal TermWindow Configurações... diff --git a/data/catalogs/kits/be.catkeys b/data/catalogs/kits/be.catkeys index 55fa824a9f..f8f9f5fea6 100644 --- a/data/catalogs/kits/be.catkeys +++ b/data/catalogs/kits/be.catkeys @@ -1,4 +1,4 @@ -1 belarusian x-vnd.Haiku-libbe 672385853 +1 belarusian x-vnd.Haiku-libbe 677628532 gamma AboutWindow гамма beta AboutWindow бэта %3.2f GiB StringForSize %3.2f ГіБ @@ -7,7 +7,6 @@ About %app% AboutMenuItem Пра %app% Cut TextView Выразаць Version AboutWindow Версія Cannot create the replicant for \"%description\".\n%error ZombieReplicantView Немагчыма стварыць рэплікант \"%description\".\n%error -About AboutWindow Пра праграму Copy TextView Капіяваць %3.2f KiB StringForSize %3.2f КіБ %d bytes StringForSize %d байтаў diff --git a/data/catalogs/kits/de.catkeys b/data/catalogs/kits/de.catkeys index 077aa2cfa7..c790fa4bff 100644 --- a/data/catalogs/kits/de.catkeys +++ b/data/catalogs/kits/de.catkeys @@ -1,4 +1,4 @@ -1 german x-vnd.Haiku-libbe 672385853 +1 german x-vnd.Haiku-libbe 677628532 gamma AboutWindow Gamma beta AboutWindow Beta %3.2f GiB StringForSize %3.2f GiB @@ -7,7 +7,6 @@ About %app% AboutMenuItem Über %app% Cut TextView Ausschneiden Version AboutWindow Version Cannot create the replicant for \"%description\".\n%error ZombieReplicantView Replikant für \"%description\" konnte nicht erstellt werden.\n%error -About AboutWindow Über Copy TextView Kopieren %3.2f KiB StringForSize %3.2f KiB %d bytes StringForSize %d Bytes diff --git a/data/catalogs/kits/fi.catkeys b/data/catalogs/kits/fi.catkeys index c82592ed8a..55e2bf7acd 100644 --- a/data/catalogs/kits/fi.catkeys +++ b/data/catalogs/kits/fi.catkeys @@ -1,4 +1,4 @@ -1 finnish x-vnd.Haiku-libbe 672385853 +1 finnish x-vnd.Haiku-libbe 677628532 gamma AboutWindow gamma beta AboutWindow beeta %3.2f GiB StringForSize %3.2f gibitavua @@ -7,7 +7,6 @@ About %app% AboutMenuItem Ohjelmasta %app% Cut TextView Leikkaa Version AboutWindow Versio Cannot create the replicant for \"%description\".\n%error ZombieReplicantView Ei voida luoda replikanttia kohteelle ”%description”.\n%error -About AboutWindow Ohjelmasta Copy TextView Kopioi %3.2f KiB StringForSize %3.2f kibitavua %d bytes StringForSize %d tavua diff --git a/data/catalogs/kits/fr.catkeys b/data/catalogs/kits/fr.catkeys index 20c4b12e6b..9b5a0eebab 100644 --- a/data/catalogs/kits/fr.catkeys +++ b/data/catalogs/kits/fr.catkeys @@ -1,4 +1,4 @@ -1 french x-vnd.Haiku-libbe 672385853 +1 french x-vnd.Haiku-libbe 677628532 gamma AboutWindow gamma beta AboutWindow bêta %3.2f GiB StringForSize %3.2f Gio @@ -7,7 +7,6 @@ About %app% AboutMenuItem À propos de %app% Cut TextView Couper Version AboutWindow Version Cannot create the replicant for \"%description\".\n%error ZombieReplicantView Impossible de créer le réplicant pour « %description ».\n%error -About AboutWindow À propos Copy TextView Copier %3.2f KiB StringForSize %3.2f Kio %d bytes StringForSize %d octets diff --git a/data/catalogs/kits/hu.catkeys b/data/catalogs/kits/hu.catkeys index a1fa48c9cc..55d05b4ea8 100644 --- a/data/catalogs/kits/hu.catkeys +++ b/data/catalogs/kits/hu.catkeys @@ -1,4 +1,4 @@ -1 hungarian x-vnd.Haiku-libbe 672385853 +1 hungarian x-vnd.Haiku-libbe 677628532 gamma AboutWindow gamma beta AboutWindow béta %3.2f GiB StringForSize %3.2f GB @@ -7,7 +7,6 @@ About %app% AboutMenuItem %app% névjegye Cut TextView Kivágás Version AboutWindow Verzió Cannot create the replicant for \"%description\".\n%error ZombieReplicantView Nem lehet replikánst létrehozni ehhez: %description.\n%error -About AboutWindow Névjegy Copy TextView Másolás %3.2f KiB StringForSize %3.2f KB %d bytes StringForSize %Ld byte diff --git a/data/catalogs/kits/pt_BR.catkeys b/data/catalogs/kits/pt_BR.catkeys index da5b30ef48..fc1d39d260 100644 --- a/data/catalogs/kits/pt_BR.catkeys +++ b/data/catalogs/kits/pt_BR.catkeys @@ -1,4 +1,4 @@ -1 portuguese (brazil) x-vnd.Haiku-libbe 677628532 +1 portuguese (brazil) x-vnd.Haiku-libbe 3504008668 gamma AboutWindow gama beta AboutWindow beta %3.2f GiB StringForSize %3.2f GB @@ -14,9 +14,11 @@ alpha AboutWindow alfa Error PrintJob Erro No Pages to print! PrintJob Nenhuma Página para imprimir! All Rights Reserved. AboutWindow Todos os direitos reservados. +About %app% AboutWindow Sobre %app% OK Dragger OK OK PrintJob OK Green: ColorControl Verde: +Ok AboutWindow Ok Version history: AboutWindow Histórico de versões Remove replicant Dragger Remover replicante OK ZombieReplicantView OK diff --git a/data/catalogs/kits/textencoding/de.catkeys b/data/catalogs/kits/textencoding/de.catkeys index 7128647750..b1e5ab410f 100644 --- a/data/catalogs/kits/textencoding/de.catkeys +++ b/data/catalogs/kits/textencoding/de.catkeys @@ -1,4 +1,4 @@ -1 german x-vnd.Haiku-libtextencoding 3062073902 +1 german x-vnd.Haiku-libtextencoding 1525027211 ISO Greek textencodings ISO Griechisch ISO South European textencodings ISO Südeuropäisch Chinese Big5 textencodings Chinesisch Big5 @@ -7,6 +7,7 @@ ISO Arabic textencodings ISO Arabisch ISO Latin 9 textencodings ISO Latin-9 Japanese Shift JIS textencodings Japanisch (Shift-JIS) DOS Cyrillic textencodings DOS Kyrillisch +Windows Central European (CP 1250) textencodings Windows Zentraleuropäisch (CP 1250) Windows Cyrillic (CP 1251) textencodings Kyrillisch Windows (CP 1251) Japanese EUC textencodings Japanisch EUC Unicode textencodings Unicode diff --git a/data/catalogs/kits/textencoding/pt_BR.catkeys b/data/catalogs/kits/textencoding/pt_BR.catkeys index 6f994abe68..c2a358fe6b 100644 --- a/data/catalogs/kits/textencoding/pt_BR.catkeys +++ b/data/catalogs/kits/textencoding/pt_BR.catkeys @@ -1,4 +1,4 @@ -1 portuguese (brazil) x-vnd.Haiku-libtextencoding 3062073902 +1 portuguese (brazil) x-vnd.Haiku-libtextencoding 1525027211 ISO Greek textencodings Grego ISO ISO South European textencodings Europeu do Sul ISO Chinese Big5 textencodings Chinês Big5 @@ -7,6 +7,7 @@ ISO Arabic textencodings Árabe ISO ISO Latin 9 textencodings Latino 9 ISO Japanese Shift JIS textencodings Japonês Shift JIS DOS Cyrillic textencodings Cirílico DOS +Windows Central European (CP 1250) textencodings Windows Centro-europeu (CP 1250) Windows Cyrillic (CP 1251) textencodings Cirílico Windows (CP 1251) Japanese EUC textencodings Japonês EUC Unicode textencodings Unicode diff --git a/data/catalogs/kits/tracker/be.catkeys b/data/catalogs/kits/tracker/be.catkeys index 8a10544139..b561a32c54 100644 --- a/data/catalogs/kits/tracker/be.catkeys +++ b/data/catalogs/kits/tracker/be.catkeys @@ -1,4 +1,4 @@ -1 belarusian x-vnd.Haiku-libtracker 4167158175 +1 belarusian x-vnd.Haiku-libtracker 1638733886 common B_COMMON_DIRECTORY агульны OK WidgetAttributeText ОК Icon view VolumeWindow Від іконак @@ -212,7 +212,6 @@ Resize to fit VolumeWindow Расцягнуць Could not find application \"%appname\" OpenWithWindow Не ўдалося знайсці праграму \"%appname\" The selected item cannot be moved to the Trash. Would you like to delete it instead? (This operation cannot be reverted.) PoseView Выбраны элемент нельга адправіць у Сметніцу. Жадаеце выдаліць іх беззваротна? Invert SelectionWindow Інвертаваць -Save Query as template… FindPanel Захаваць Запыт як шаблон… rename InfoWindow As in 'if you rename this folder...' (en) 'Wird dieser Ordner umbenannt...' (de) перайменуеце Find FindPanel Знайсці Move FSUtils Button label, 'Move' (en), 'Verschieben' (de) Перасунуць diff --git a/data/catalogs/kits/tracker/de.catkeys b/data/catalogs/kits/tracker/de.catkeys index 96eb7df55e..c617eafbe9 100644 --- a/data/catalogs/kits/tracker/de.catkeys +++ b/data/catalogs/kits/tracker/de.catkeys @@ -1,4 +1,4 @@ -1 german x-vnd.Haiku-libtracker 4167158175 +1 german x-vnd.Haiku-libtracker 1638733886 common B_COMMON_DIRECTORY Allgemein OK WidgetAttributeText OK Icon view VolumeWindow Icon-Ansicht @@ -212,7 +212,6 @@ Resize to fit VolumeWindow Optimale Größe Could not find application \"%appname\" OpenWithWindow Die Anwendung \"%appname\" wurde nicht gefunden. The selected item cannot be moved to the Trash. Would you like to delete it instead? (This operation cannot be reverted.) PoseView Das ausgewählte Objekt kann nicht in den Papierkorb verschoben werden. Soll es stattdessen gelöscht werden? (Diese Aktion kann nicht rückgängig gemacht werden.) Invert SelectionWindow Umkehren -Save Query as template… FindPanel Query als Vorlage speichern… rename InfoWindow As in 'if you rename this folder...' (en) 'Wird dieser Ordner umbenannt...' (de) umbenannt Find FindPanel Suchen Move FSUtils Button label, 'Move' (en), 'Verschieben' (de) Verschieben diff --git a/data/catalogs/kits/tracker/el.catkeys b/data/catalogs/kits/tracker/el.catkeys index 635f8873cf..7be265f80c 100644 --- a/data/catalogs/kits/tracker/el.catkeys +++ b/data/catalogs/kits/tracker/el.catkeys @@ -1,4 +1,4 @@ -1 greek, modern (1453-) x-vnd.Haiku-libtracker 3015739927 +1 greek, modern (1453-) x-vnd.Haiku-libtracker 487315638 common B_COMMON_DIRECTORY κοινό OK WidgetAttributeText Εντάξει Icon view VolumeWindow Προβολή εικονιδίου @@ -197,7 +197,6 @@ Resize to fit VolumeWindow Αλλαγή μεγέθους για να χωράε Could not find application \"%appname\" OpenWithWindow Αδυναμία εύρεσης της εφαρμογής \"%appname\" The selected item cannot be moved to the Trash. Would you like to delete it instead? (This operation cannot be reverted.) PoseView To επιλεγμένο στοιχείο δε μπορεί να μετακινηθεί στον κάδο απορριμμάτων. Θα θέλατε να το διαγράψετε αντ' αυτού; (Αυτή η λειτουργία δεν μπορεί να επανέλθει.) Invert SelectionWindow Αντιστροφή -Save Query as template… FindPanel Αποθήκευση του ερωτήματος ως πρότυπο... rename InfoWindow As in 'if you rename this folder...' (en) 'Wird dieser Ordner umbenannt...' (de) μετονομασία Find FindPanel Εύρεση Move FSUtils Button label, 'Move' (en), 'Verschieben' (de) Μετακίνηση diff --git a/data/catalogs/kits/tracker/fi.catkeys b/data/catalogs/kits/tracker/fi.catkeys index 2987ff7db6..6e53f69270 100644 --- a/data/catalogs/kits/tracker/fi.catkeys +++ b/data/catalogs/kits/tracker/fi.catkeys @@ -1,4 +1,4 @@ -1 finnish x-vnd.Haiku-libtracker 4167158175 +1 finnish x-vnd.Haiku-libtracker 1638733886 common B_COMMON_DIRECTORY yhteinen OK WidgetAttributeText Valmis Icon view VolumeWindow Kuvakenäkymä @@ -212,7 +212,6 @@ Resize to fit VolumeWindow Muunna koko sopimaan Could not find application \"%appname\" OpenWithWindow Ei voitu löytää sovellusta ”%appname” The selected item cannot be moved to the Trash. Would you like to delete it instead? (This operation cannot be reverted.) PoseView Valittua kohdetta ei voida siirtää roskakoriin. Haluaisitko sen sijaan poistaa sen? (Tätä toimintoa ei voida palauttaa.) Invert SelectionWindow Käänteinen -Save Query as template… FindPanel Tallenna kysely mallinteena... rename InfoWindow As in 'if you rename this folder...' (en) 'Wird dieser Ordner umbenannt...' (de) nimeä uudelleen Find FindPanel Haku Move FSUtils Button label, 'Move' (en), 'Verschieben' (de) Siirrä diff --git a/data/catalogs/kits/tracker/fr.catkeys b/data/catalogs/kits/tracker/fr.catkeys index d1d68eb7ec..6e90007ccf 100644 --- a/data/catalogs/kits/tracker/fr.catkeys +++ b/data/catalogs/kits/tracker/fr.catkeys @@ -1,4 +1,4 @@ -1 french x-vnd.Haiku-libtracker 4167158175 +1 french x-vnd.Haiku-libtracker 1638733886 common B_COMMON_DIRECTORY commun OK WidgetAttributeText OK Icon view VolumeWindow Vue en icônes @@ -212,7 +212,6 @@ Resize to fit VolumeWindow Ajuster Could not find application \"%appname\" OpenWithWindow Impossible de trouver l'application « %appname » The selected item cannot be moved to the Trash. Would you like to delete it instead? (This operation cannot be reverted.) PoseView L'élément sélectionné ne peut pas être envoyé à la Corbeille. Voulez vous le supprimer ? (Cette opération est irrémédiable.) Invert SelectionWindow Inverser -Save Query as template… FindPanel Enregistrer le modèle de la requête… rename InfoWindow As in 'if you rename this folder...' (en) 'Wird dieser Ordner umbenannt...' (de) renommez Find FindPanel Rechercher Move FSUtils Button label, 'Move' (en), 'Verschieben' (de) Déplacer diff --git a/data/catalogs/kits/tracker/hi.catkeys b/data/catalogs/kits/tracker/hi.catkeys index 00fd369d00..b90716a724 100644 --- a/data/catalogs/kits/tracker/hi.catkeys +++ b/data/catalogs/kits/tracker/hi.catkeys @@ -1,4 +1,4 @@ -1 hindi x-vnd.Haiku-libtracker 1458537919 +1 hindi x-vnd.Haiku-libtracker 3225080926 common B_COMMON_DIRECTORY सामान्य OK WidgetAttributeText ठीक है Icon view VolumeWindow चिह्न दृश्य @@ -197,7 +197,6 @@ Resize to fit VolumeWindow आकार बदलने के फिट कर Could not find application \"%appname\" OpenWithWindow आवेदन नहीं मिला \"%appname\" The selected item cannot be moved to the Trash. Would you like to delete it instead? (This operation cannot be reverted.) PoseView चयनित आइटम को कचरा पेटी में स्थानांतरित नहीं किया जा सकता है. क्या आप इसे इसकी बजाय मिटाना चाहते हैं? (यह आपरेशन किया जाना है. नहीं लौट सकते हैं) Invert SelectionWindow पलटे -Save Query as template… FindPanel टेम्पलेट के रूप में सहेजें क्वेरी... rename InfoWindow As in 'if you rename this folder...' (en) 'Wird dieser Ordner umbenannt...' (de) फिर से नाम दें Find FindPanel खोजें Move FSUtils Button label, 'Move' (en), 'Verschieben' (de) मूव diff --git a/data/catalogs/kits/tracker/hu.catkeys b/data/catalogs/kits/tracker/hu.catkeys index ae42ac9ffe..65ea2318a7 100644 --- a/data/catalogs/kits/tracker/hu.catkeys +++ b/data/catalogs/kits/tracker/hu.catkeys @@ -1,4 +1,4 @@ -1 hungarian x-vnd.Haiku-libtracker 4167158175 +1 hungarian x-vnd.Haiku-libtracker 1638733886 common B_COMMON_DIRECTORY Közös OK WidgetAttributeText Rendben Icon view VolumeWindow Ikon nézet @@ -212,7 +212,6 @@ Resize to fit VolumeWindow Átméretezés hogy elférjen Could not find application \"%appname\" OpenWithWindow A program (%appname) nem található The selected item cannot be moved to the Trash. Would you like to delete it instead? (This operation cannot be reverted.) PoseView A kiválasztott elemet nem lehet a Szemetesbe mozgatni. Szeretné inkább törölni? (Nem vonható vissza.) Invert SelectionWindow Megfordítás -Save Query as template… FindPanel Keresés mentése sablonként… rename InfoWindow As in 'if you rename this folder...' (en) 'Wird dieser Ordner umbenannt...' (de) átnevezi Find FindPanel Keresés Move FSUtils Button label, 'Move' (en), 'Verschieben' (de) Mozgatás diff --git a/data/catalogs/kits/tracker/ja.catkeys b/data/catalogs/kits/tracker/ja.catkeys index 818cf1daa5..885c833543 100644 --- a/data/catalogs/kits/tracker/ja.catkeys +++ b/data/catalogs/kits/tracker/ja.catkeys @@ -1,4 +1,4 @@ -1 japanese x-vnd.Haiku-libtracker 419889716 +1 japanese x-vnd.Haiku-libtracker 1188087477 common B_COMMON_DIRECTORY 一般 OK WidgetAttributeText OK Icon view VolumeWindow アイコン表示 @@ -141,6 +141,7 @@ Add-ons ContainerWindow アドオン Edit templates… TemplatesMenu テンプレートを編集… Finish: %time - Over %finishtime left StatusWindow 終了: %time - 残り %finishtime 以上 An item named \"%name\" already exists in this folder. Would you like to replace it with the symbolic link you are creating? FSUtils このフォルダーにすでに \"%name\" という項目があります。作成しようとしているシンボリックリンクと置き換えますか? +Fewer options FindPanel 検索オプションを隠す Sorry, there is not enough free space on the destination volume to copy the selection. FSUtils コピー先ディスクの空き容量が不足しています。コピーができません。 Could not open \"%document\" with application \"%app\" (%error). FSUtils アプリケーション \"%app\" を使って \"%document\" を開けませんでした (%error)。 Sorry, saving more than one item is not allowed. FilePanelPriv 2 項目以上は保存できません。 @@ -234,6 +235,7 @@ Temporary FindPanel 一時的なクエリ Version OpenWithWindow バージョン Default application InfoWindow デフォルトアプリケーション Preparing to copy items… StatusWindow コピーの準備をしています… +Save query as template… FindPanel クエリテンプレートとして保存… Show folder location in title tab SettingsView タイトルタブにフォルダー位置を表示 Proceed FSUtils 続行 Some items already exist in this folder with the same names as the items you are %verb.\n \nWould you like to replace them with the ones you are %verb or be prompted for each one? FSUtils %verbしようとしているものと同じ名前の項目がすでにフォルダーの中に存在します。\n \n%verbして置き換えますか?それとも、一つずつ確認しますか? @@ -331,6 +333,7 @@ The specified name is already used as the name of a folder. Please choose anothe Clean up ContainerWindow アイコンの整列 after FindPanel 以降 Select… QueryContainerWindow 選択… +More options FindPanel 検索オプションを表示 link FSUtils filename link リンク At %func \nfind_directory() failed. \nReason: %error TrackerInitialState %func にて\nfind_directory() が失敗。\nエラー: %error The specified name is illegal. Please choose another name. FilePanelPriv 指定された名前は利用できない文字を含んでいます。他の名前を指定してください。 diff --git a/data/catalogs/kits/tracker/pt_BR.catkeys b/data/catalogs/kits/tracker/pt_BR.catkeys index 98be8e2683..45b1b265ba 100644 --- a/data/catalogs/kits/tracker/pt_BR.catkeys +++ b/data/catalogs/kits/tracker/pt_BR.catkeys @@ -1,4 +1,4 @@ -1 portuguese (brazil) x-vnd.Haiku-libtracker 1638733886 +1 portuguese (brazil) x-vnd.Haiku-libtracker 1762695842 common B_COMMON_DIRECTORY comum OK WidgetAttributeText OK Icon view VolumeWindow Em ícones @@ -143,6 +143,7 @@ Add-ons ContainerWindow Adicionais Edit templates… TemplatesMenu Editar modelos... Finish: %time - Over %finishtime left StatusWindow Término: %time - Mais de %finishtime restante An item named \"%name\" already exists in this folder. Would you like to replace it with the symbolic link you are creating? FSUtils Um item chamado \"%name\" já existe nesta pasta. Gostaria de substituí-lo pelo link simbólico que está sendo criado? +Fewer options FindPanel Menos opções Sorry, there is not enough free space on the destination volume to copy the selection. FSUtils Desculpe, não existe espaço livre suficiente no volume de destino para para copiar a seleção. Could not open \"%document\" with application \"%app\" (%error). FSUtils Não foi possível abrir \"%document\" com a aplicativo \"%app\" (%error). Sorry, saving more than one item is not allowed. FilePanelPriv Desculpe, salvar mais de um item não é permitido. @@ -236,6 +237,7 @@ Temporary FindPanel Temporário Version OpenWithWindow Versão Default application InfoWindow Aplicativo padrão Preparing to copy items… StatusWindow Preparando para copiar itens... +Save query as template… FindPanel Salvar consulta como modelo… Show folder location in title tab SettingsView Mostrar local da pasta na barra de títulos Proceed FSUtils Prosseguir Some items already exist in this folder with the same names as the items you are %verb.\n \nWould you like to replace them with the ones you are %verb or be prompted for each one? FSUtils Alguns itens já existem nesta pasta com os mesmos nomes dos itens que você quer %verb.\n \nVocê gostaria de substituí-los com aqueles que você vai %verb ou ser perguntado em cada um? @@ -334,6 +336,7 @@ The specified name is already used as the name of a folder. Please choose anothe Clean up ContainerWindow Limpeza after FindPanel após Select… QueryContainerWindow Selecionar… +More options FindPanel Mais opções link FSUtils filename link vínculo At %func \nfind_directory() failed. \nReason: %error TrackerInitialState Em %func \nfind_directory() falhou. \nRazão: %error The specified name is illegal. Please choose another name. FilePanelPriv O nome especificado é ilegal. Por favor escolha outro nome. @@ -445,6 +448,7 @@ contains FindPanel contém Relation OpenWithWindow Relação Open FilePanelPriv Abrir Mount DeskWindow Montar +Recent queries FindPanel Consultas recentes Mount ContainerWindow Montar %capacity (%used used -- %free free) InfoWindow %capacity (%used utilizados -- %free livres) Cancel FSClipBoard Cancelar diff --git a/data/catalogs/preferences/appearance/de.catkeys b/data/catalogs/preferences/appearance/de.catkeys index 0783140413..99055020de 100644 --- a/data/catalogs/preferences/appearance/de.catkeys +++ b/data/catalogs/preferences/appearance/de.catkeys @@ -1,4 +1,4 @@ -1 german x-vnd.Haiku-Appearance 2993758435 +1 german x-vnd.Haiku-Appearance 727801787 Plain font: Font view Normal: Control highlight Colors tab Steuerelement - Ausgewählt Control border Colors tab Steuerelement - Rahmen @@ -50,6 +50,7 @@ The quick brown fox jumps over the lazy dog. Font Selection view Don't translate %decorName\n\nAuthors:\n\t%decorAuthors\n\nURL: %decorURL\nLicense: %decorLic\n\n%decorDesc\n DecorSettingsView %decorName\n\nAutoren:\n\t%decorAuthors\n\nURL: %decorURL\nLizens: %decorLic\n\n%decorDesc\n Reduce colored edges filter strength: AntialiasingSettingsView Farbsaumfilter: Subpixel based anti-aliasing in combination with glyph hinting is not available in this build of Haiku to avoid possible patent issues. To enable this feature, you have to build Haiku yourself and enable certain options in the libfreetype configuration header. AntialiasingSettingsView Zur Vermeidung von möglichen Patentproblemen ist die Kombination von Subpixel-Kantenglättung und Glyph-Hinting deaktiviert. Um diese Funktion zu aktivieren, müssen spezielle Optionen im Konfigurationsheader der Freetype-Bibliothek freigeschaltet und anschließend Haiku neu kompiliert werden. +Scroll bar thumb Colors tab Scroll-Balken Control text Colors tab Steuerelement - Text Single: DecorSettingsView Einfach: Tooltip text Colors tab Tooltip - Text diff --git a/data/catalogs/preferences/appearance/pt_BR.catkeys b/data/catalogs/preferences/appearance/pt_BR.catkeys index d0ddb5ba57..1186e69d8b 100644 --- a/data/catalogs/preferences/appearance/pt_BR.catkeys +++ b/data/catalogs/preferences/appearance/pt_BR.catkeys @@ -1,4 +1,4 @@ -1 portuguese (brazil) x-vnd.Haiku-Appearance 1457181689 +1 portuguese (brazil) x-vnd.Haiku-Appearance 727801787 Plain font: Font view Fonte plana: Control highlight Colors tab Realce do controle Control border Colors tab Borda do controle @@ -16,6 +16,7 @@ Success Colors tab Sucesso Inactive window tab text Colors tab Texto da aba de janela inativa Failure Colors tab Falha Hinting menu AntialiasingSettingsView Menu de sugestão +Scroll bar: DecorSettingsView Barra de rolagem: Document background Colors tab Plano de fundo do documento Revert APRWindow Reverter Window tab Colors tab Aba da janela @@ -49,6 +50,7 @@ The quick brown fox jumps over the lazy dog. Font Selection view Don't translate %decorName\n\nAuthors:\n\t%decorAuthors\n\nURL: %decorURL\nLicense: %decorLic\n\n%decorDesc\n DecorSettingsView %decorName\n\nAutores:\n\t %decorAuthors\n\nURL: %decorURL\nLicença: %decorLic\n\n%decorDesc\n Reduce colored edges filter strength: AntialiasingSettingsView Reduzir a força do filtro de bordas coloridas: Subpixel based anti-aliasing in combination with glyph hinting is not available in this build of Haiku to avoid possible patent issues. To enable this feature, you have to build Haiku yourself and enable certain options in the libfreetype configuration header. AntialiasingSettingsView A possibilidade de usar o antiserrilhamento baseado em Subpíxeis juntamente com o alisamento de glifos não está disponível nesta versão do Haiku para evitar possíveis problemas com patentes. Para habilitar esta funcionalidade, você terá que compilar o Haiku e ativar certas opções no cabeçalho de configuração da libfreetype. +Scroll bar thumb Colors tab Botão da barra de rolagem Control text Colors tab Texto do controle Single: DecorSettingsView Único: Tooltip text Colors tab Texto da dica diff --git a/data/catalogs/preferences/mail/fr.catkeys b/data/catalogs/preferences/mail/fr.catkeys index f9d175b53c..e3d51d56bc 100644 --- a/data/catalogs/preferences/mail/fr.catkeys +++ b/data/catalogs/preferences/mail/fr.catkeys @@ -12,7 +12,7 @@ Start mail services on startup Config Window Lancer les services de mail au dé E-mail address: E-Mail Adresse email : Account name: E-Mail Nom du compte : Account name: Config Views Nom du compte : -Create new account AutoConfigWindow Créé un nouveau compte +Create new account AutoConfigWindow Créer un nouveau compte OK Config Views OK The filter could not be moved. Deleting filter. Config Views Le filtre n'a pas pu être déplacé. Suppression du filtre. Revert Config Window Rétablir diff --git a/data/catalogs/preferences/network/be.catkeys b/data/catalogs/preferences/network/be.catkeys index de89352c89..94c80730c5 100644 --- a/data/catalogs/preferences/network/be.catkeys +++ b/data/catalogs/preferences/network/be.catkeys @@ -1,10 +1,11 @@ -1 belarusian x-vnd.Haiku-Network 365183238 +1 belarusian x-vnd.Haiku-Network 781877986 Choose automatically EthernetSettingsView Выбіраць аўтаматычна Gateway: EthernetSettingsView Шлюз: Netmask: EthernetSettingsView Маска сеткі: DHCP EthernetSettingsView DHCP DNS #2: EthernetSettingsView DNS #2: Apply EthernetSettingsView Ужыць +Netmask is invalid EthernetSettingsView Няслушная маска падсеткі. OK EthernetSettingsView ОК DNS #1: EthernetSettingsView DNS #1: IP address: EthernetSettingsView IP адрас: diff --git a/data/catalogs/preferences/notifications/be.catkeys b/data/catalogs/preferences/notifications/be.catkeys index 50b00771b1..d3fc1bf1f9 100644 --- a/data/catalogs/preferences/notifications/be.catkeys +++ b/data/catalogs/preferences/notifications/be.catkeys @@ -1,4 +1,4 @@ -1 belarusian x-vnd.Haiku-Notifications 814394708 +1 belarusian x-vnd.Haiku-Notifications 2177286129 An error occurred saving the preferences.\nIt's possible you are running out of disk space. GeneralView Адбылася памылка пры захаванні наладак.\nМагчыма, не хапае месца на дыску. Notifications GeneralView Паведамленні seconds of inactivity GeneralView секунд прастою @@ -17,6 +17,7 @@ Cannot disable notifications because the server can't be reached. GeneralView Progress NotificationView Прагрэс Last Received NotificationView Апошняе атрыманае General PrefletView Агульныя +Apply PrefletWin Ужыць Display PrefletView Экран Can't enable notifications at startup time, you probably don't have write permission to the boot settings directory. GeneralView Не ўдалося занесці паведамленні ў аўтазапуск, магчыма, вы не маеце правоў на змяненне дырэкторыі аўтазапуску. Search: NotificationView Пошук: diff --git a/data/catalogs/preferences/time/be.catkeys b/data/catalogs/preferences/time/be.catkeys index 4294263f31..c91571db10 100644 --- a/data/catalogs/preferences/time/be.catkeys +++ b/data/catalogs/preferences/time/be.catkeys @@ -1,4 +1,4 @@ -1 belarusian x-vnd.Haiku-Time 3544635877 +1 belarusian x-vnd.Haiku-Time 3259467657 GMT (UNIX compatible) Time GMT (як у UNIX) OK Time ОК Asia Time Азія @@ -11,6 +11,7 @@ Preview time: Time Праглядзець час: Synchronize Time Сінхранізаваць Revert Time Адвярнуць Pacific Time Ціхі акіян +Show day of week Time Паказваць дзень тыдню Add Time Дадаць Date and time Time Дата і Час about Time пра праграму @@ -26,6 +27,7 @@ Time Time Час Indian Time Індыя Sending request failed Time Немагчыма адаслаць запыт Arctic Time Арктыка +Display time with seconds Time Паказваць час з секундамі Time System name Дата і Час America Time Амерыка Reset Time Скінуць @@ -33,6 +35,8 @@ Synchronize at boot Time Сінхранізаваць падчас старту Time & Date, written by:\n\n\tAndrew Edward McCall\n\tMike Berg\n\tJulun\n\tPhilippe Saint-Pierre\n\nCopyright 2004-2012, Haiku. Time Time & Date, распрацавана:\n\n\t Andrew Edward McCall\n\t Mike Berg\n\t Julun\n\t Philippe Saint-Pierre\n\nCopyright 2004-2012, Haiku. Received invalid time Time Атрыманы несапраўдны час Antarctica Time Антарктыка +Show time zone Time Паказаць часавы пояс +Show clock in Deskbar Time Паказваць гадзіннік у Deskbar-ы The following error occured while synchronizing:r\n%s: %s Time Памылка падчас сінхранізацыі:r\n%s: %s Time <Іншае> Current time: Time Сапраўдны час: diff --git a/data/catalogs/servers/print/be.catkeys b/data/catalogs/servers/print/be.catkeys index e9017a9d1c..ad461ee9a9 100644 --- a/data/catalogs/servers/print/be.catkeys +++ b/data/catalogs/servers/print/be.catkeys @@ -1,4 +1,4 @@ -1 belarusian x-vnd.Be-PSRV 1761631281 +1 belarusian x-vnd.Be-PSRV 123334776 Undefined ConfigWindow Нявызначаны Return the number of available transports PrintServerApp Scripting Вярнуць колькасць даступных транспортаў Return the number of available printers PrintServerApp Scripting Вярнуць колькасць даступных прынтэраў @@ -9,6 +9,7 @@ Retrieve a specific printer PrintServerApp Scripting Вызначыць аса Page %1 to %2 ConfigWindow Старонкі з %1 па %2 Get name of the printer add-on used for this printer Printer Scripting Вызначыць імя дапаўнення, ужытага для гэтага прынтэра Page setup: ConfigWindow Наладкі старонкі: +B5 (JIS) ConfigWindow JIS P0138 B5, a Japanese paper size B5 (JIS) OK ConfigWindow Так Cancel ConfigWindow Адмена Printer server ConfigWindow Сервер друку diff --git a/data/catalogs/servers/print/pt_BR.catkeys b/data/catalogs/servers/print/pt_BR.catkeys index ff31ef7bc3..9457d195bf 100644 --- a/data/catalogs/servers/print/pt_BR.catkeys +++ b/data/catalogs/servers/print/pt_BR.catkeys @@ -1,4 +1,4 @@ -1 portuguese (brazil) x-vnd.Be-PSRV 1761631281 +1 portuguese (brazil) x-vnd.Be-PSRV 123334776 Undefined ConfigWindow Indefinido Return the number of available transports PrintServerApp Scripting Mostrar o número de transportes disponíveis Return the number of available printers PrintServerApp Scripting Mostrar o número de impressoras disponíveis @@ -9,6 +9,7 @@ Retrieve a specific printer PrintServerApp Scripting Obter uma impressora espec Page %1 to %2 ConfigWindow Página %1 até %2 Get name of the printer add-on used for this printer Printer Scripting Obter o nome de um adicional usado para esta impressora Page setup: ConfigWindow Configurações de página: +B5 (JIS) ConfigWindow JIS P0138 B5, a Japanese paper size B5 (JIS) OK ConfigWindow OK Cancel ConfigWindow Cancelar Printer server ConfigWindow Servidor de impressão diff --git a/data/catalogs/tests/kits/net/preflet/InterfacesAddOn/pt_BR.catkeys b/data/catalogs/tests/kits/net/preflet/InterfacesAddOn/pt_BR.catkeys new file mode 100644 index 0000000000..6d4884a90f --- /dev/null +++ b/data/catalogs/tests/kits/net/preflet/InterfacesAddOn/pt_BR.catkeys @@ -0,0 +1,33 @@ +1 portuguese (brazil) x-vnd.Haiku-InterfacesAddOn 160108912 +Interface InterfaceWindow Interface +Configure… InterfacesListView Configurar… +Static IntefaceAddressView Estático +None InterfacesListView Nenhum +IP: InterfacesListView IPv4 address label IP: +Status: IntefaceHardwareView Estado: +IPv6: InterfacesListView IPv6 address label IPv6: +Save InterfaceWindow Salvar +Link speed: IntefaceHardwareView Velocidade do link: +Renegotiate InterfacesAddOn Renegociar +The method for obtaining an IP address IntefaceAddressView O método para obter um endereço IP +Your gateway IntefaceAddressView Sua rota padrão +Enable InterfacesListView Habilitar +Received: IntefaceHardwareView Recebido: +Revert InterfaceWindow Reverter +connected IntefaceHardwareView conectado +Gateway: IntefaceAddressView Rota padrão: +Disable InterfacesListView Desabilitar +Sent: IntefaceHardwareView Enviado: +Disable InterfacesAddOn Desabilitar +Configure… InterfacesAddOn Configurar… +Renegotiate Address InterfacesListView Endereço de renegociação +DHCP IntefaceAddressView DHCP +Mode: IntefaceAddressView Modo: +Your netmask IntefaceAddressView Sua máscara de rede +IP Address: IntefaceAddressView Endereço IP: +Off IntefaceAddressView Desligar +MAC address: IntefaceHardwareView Endereço MAC: +Netmask: IntefaceAddressView Máscara de rede: +Your IP address IntefaceAddressView Seu endereço IP +%llu KBytes IntefaceHardwareView %llu KBytes +disconnected IntefaceHardwareView desconectado diff --git a/data/system/data/fonts/ttfonts/VL-Gothic-Regular.ttf b/data/system/data/fonts/ttfonts/VL-Gothic-Regular.ttf index 46e1b9063e..d2bb546d21 100644 Binary files a/data/system/data/fonts/ttfonts/VL-Gothic-Regular.ttf and b/data/system/data/fonts/ttfonts/VL-Gothic-Regular.ttf differ diff --git a/data/system/data/fonts/ttfonts/VL-PGothic-Regular.ttf b/data/system/data/fonts/ttfonts/VL-PGothic-Regular.ttf index 64f8934268..07f5bd8f01 100644 Binary files a/data/system/data/fonts/ttfonts/VL-PGothic-Regular.ttf and b/data/system/data/fonts/ttfonts/VL-PGothic-Regular.ttf differ diff --git a/headers/os/interface/Menu.h b/headers/os/interface/Menu.h index 4ef27a77f5..bbca5c4d6d 100644 --- a/headers/os/interface/Menu.h +++ b/headers/os/interface/Menu.h @@ -1,5 +1,5 @@ /* - * Copyright 2007-2009, Haiku, Inc. All rights reserved. + * Copyright 2007-2013 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. */ #ifndef _MENU_H @@ -10,6 +10,7 @@ #include #include + class BMenu; class BMenuBar; class BMenuItem; @@ -216,7 +217,7 @@ private: void _ComputeColumnLayout(int32 index, bool bestFit, bool moveItems, BRect* override, BRect& outRect); void _ComputeRowLayout(int32 index, bool bestFit, - bool moveItems, BRect& outRect); + bool moveItems, BRect& outRect); void _ComputeMatrixLayout(BRect& outRect); BRect _CalcFrame(BPoint where, bool* scrollOn); diff --git a/headers/os/interface/MenuField.h b/headers/os/interface/MenuField.h index 2fba75910c..aaf3cdfd5c 100644 --- a/headers/os/interface/MenuField.h +++ b/headers/os/interface/MenuField.h @@ -16,12 +16,14 @@ class BMenuField : public BView { public: BMenuField(BRect frame, const char* name, const char* label, BMenu* menu, - uint32 resize = B_FOLLOW_LEFT|B_FOLLOW_TOP, + uint32 resizingMode = B_FOLLOW_LEFT + | B_FOLLOW_TOP, uint32 flags = B_WILL_DRAW | B_NAVIGABLE); BMenuField(BRect frame, const char* name, const char* label, BMenu* menu, bool fixed_size, - uint32 resize = B_FOLLOW_LEFT|B_FOLLOW_TOP, + uint32 resizingMode = B_FOLLOW_LEFT + | B_FOLLOW_TOP, uint32 flags = B_WILL_DRAW | B_NAVIGABLE); BMenuField(const char* name, const char* label, BMenu* menu, @@ -35,14 +37,14 @@ public: virtual status_t Archive(BMessage* archive, bool deep = true) const; - virtual void Draw(BRect update); + virtual void Draw(BRect updateRect); virtual void AttachedToWindow(); virtual void AllAttached(); virtual void MouseDown(BPoint where); virtual void KeyDown(const char* bytes, int32 numBytes); virtual void MakeFocus(bool state); - virtual void MessageReceived(BMessage* message); - virtual void WindowActivated(bool state); + virtual void MessageReceived(BMessage* message); + virtual void WindowActivated(bool state); virtual void MouseUp(BPoint where); virtual void MouseMoved(BPoint where, uint32 transit, const BMessage* dragMessage); @@ -58,24 +60,24 @@ public: virtual void SetLabel(const char* label); const char* Label() const; - virtual void SetEnabled(bool on); + virtual void SetEnabled(bool on); bool IsEnabled() const; virtual void SetAlignment(alignment label); alignment Alignment() const; - virtual void SetDivider(float dividing_line); + virtual void SetDivider(float position); float Divider() const; void ShowPopUpMarker(); void HidePopUpMarker(); - virtual BHandler* ResolveSpecifier(BMessage* message, + virtual BHandler* ResolveSpecifier(BMessage* message, int32 index, BMessage* specifier, int32 form, const char* property); - virtual status_t GetSupportedSuites(BMessage* data); + virtual status_t GetSupportedSuites(BMessage* data); - virtual void ResizeToPreferred(); - virtual void GetPreferredSize(float* width, float* height); + virtual void ResizeToPreferred(); + virtual void GetPreferredSize(float* width, float* height); virtual BSize MinSize(); virtual BSize MaxSize(); @@ -87,8 +89,8 @@ public: virtual status_t Perform(perform_code d, void* arg); protected: - virtual status_t AllArchived(BMessage* into) const; - virtual status_t AllUnarchived(const BMessage* from); + virtual status_t AllArchived(BMessage* into) const; + virtual status_t AllUnarchived(const BMessage* from); virtual void LayoutInvalidated(bool descendants); virtual void DoLayout(); @@ -121,7 +123,7 @@ private: void InitObject(const char* label); void InitObject2(); - void DrawLabel(BRect bounds, BRect update); + void DrawLabel(BRect updateRect); static void InitMenu(BMenu* menu); int32 _MenuTask(); diff --git a/headers/os/support/SupportDefs.h b/headers/os/support/SupportDefs.h index a37bd7d141..7cc5aaf67e 100644 --- a/headers/os/support/SupportDefs.h +++ b/headers/os/support/SupportDefs.h @@ -137,6 +137,7 @@ typedef generic_addr_t generic_size_t; /* off_t */ #define B_PRIdOFF B_PRId64 #define B_PRIiOFF B_PRIi64 +#define B_PRIxOFF B_PRIx64 /* dev_t */ #define B_PRIdDEV B_PRId32 #define B_PRIiDEV B_PRIi32 diff --git a/headers/private/graphics/intel_extreme/AreaKeeper.h b/headers/private/graphics/intel_extreme/AreaKeeper.h index 8e17dec24a..d604bb45cb 100644 --- a/headers/private/graphics/intel_extreme/AreaKeeper.h +++ b/headers/private/graphics/intel_extreme/AreaKeeper.h @@ -22,7 +22,7 @@ class AreaKeeper { area_id Create(const char *name, void **_virtualAddress, uint32 spec, size_t size, uint32 lock, uint32 protection); - area_id Map(const char *name, void *physicalAddress, size_t numBytes, + area_id Map(const char *name, addr_t physicalAddress, size_t numBytes, uint32 spec, uint32 protection, void **_virtualAddress); status_t InitCheck() { return fArea < B_OK ? (status_t)fArea : B_OK; } @@ -57,10 +57,10 @@ AreaKeeper::Create(const char *name, void **_virtualAddress, uint32 spec, area_id -AreaKeeper::Map(const char *name, void *physicalAddress, size_t numBytes, +AreaKeeper::Map(const char *name, addr_t physicalAddress, size_t numBytes, uint32 spec, uint32 protection, void **_virtualAddress) { - fArea = map_physical_memory(name, (addr_t)physicalAddress, numBytes, spec, + fArea = map_physical_memory(name, physicalAddress, numBytes, spec, protection, _virtualAddress); return fArea; } diff --git a/headers/private/graphics/intel_extreme/intel_extreme.h b/headers/private/graphics/intel_extreme/intel_extreme.h index f7e7d22d5a..b8e969fba7 100644 --- a/headers/private/graphics/intel_extreme/intel_extreme.h +++ b/headers/private/graphics/intel_extreme/intel_extreme.h @@ -226,13 +226,13 @@ struct intel_allocate_graphics_memory { uint32 size; uint32 alignment; uint32 flags; - uint32 buffer_base; + addr_t buffer_base; }; // free graphics memory struct intel_free_graphics_memory { uint32 magic; - uint32 buffer_base; + addr_t buffer_base; }; //---------------------------------------------------------- diff --git a/headers/private/graphics/radeon_hd/AreaKeeper.h b/headers/private/graphics/radeon_hd/AreaKeeper.h index 8e17dec24a..d604bb45cb 100644 --- a/headers/private/graphics/radeon_hd/AreaKeeper.h +++ b/headers/private/graphics/radeon_hd/AreaKeeper.h @@ -22,7 +22,7 @@ class AreaKeeper { area_id Create(const char *name, void **_virtualAddress, uint32 spec, size_t size, uint32 lock, uint32 protection); - area_id Map(const char *name, void *physicalAddress, size_t numBytes, + area_id Map(const char *name, addr_t physicalAddress, size_t numBytes, uint32 spec, uint32 protection, void **_virtualAddress); status_t InitCheck() { return fArea < B_OK ? (status_t)fArea : B_OK; } @@ -57,10 +57,10 @@ AreaKeeper::Create(const char *name, void **_virtualAddress, uint32 spec, area_id -AreaKeeper::Map(const char *name, void *physicalAddress, size_t numBytes, +AreaKeeper::Map(const char *name, addr_t physicalAddress, size_t numBytes, uint32 spec, uint32 protection, void **_virtualAddress) { - fArea = map_physical_memory(name, (addr_t)physicalAddress, numBytes, spec, + fArea = map_physical_memory(name, physicalAddress, numBytes, spec, protection, _virtualAddress); return fArea; } diff --git a/headers/private/interface/BMCPrivate.h b/headers/private/interface/BMCPrivate.h index f8ff7036ff..5c9678c388 100644 --- a/headers/private/interface/BMCPrivate.h +++ b/headers/private/interface/BMCPrivate.h @@ -1,10 +1,11 @@ /* - * Copyright 2001-2009 Haiku, Inc. All rights reserved. + * Copyright 2001-2013 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: - * Marc Flerackers (mflerackers@androme.be) - * Stephan Aßmus + * Stephan Aßmus, superstippi@gmx.de + * Marc Flerackers, mflerackers@androme.be + * John Scipione, jscipione@gmail.com */ #ifndef _BMC_PRIVATE_H #define _BMC_PRIVATE_H @@ -12,9 +13,9 @@ #include #include -#include #include + class BMessageRunner; @@ -36,8 +37,7 @@ class _BMCMenuBar_ : public BMenuBar { public: _BMCMenuBar_(BRect frame, bool fixedSize, BMenuField* menuField); - _BMCMenuBar_(bool fixedSize, - BMenuField* menuField); + _BMCMenuBar_(BMenuField* menuField); _BMCMenuBar_(BMessage* data); virtual ~_BMCMenuBar_(); @@ -54,7 +54,7 @@ public: bool IsPopUpMarkerShown() const { return fShowPopUpMarker; } - virtual BSize MinSize(); + virtual BSize MinSize(); virtual BSize MaxSize(); private: diff --git a/headers/private/interface/ColumnTypes.h b/headers/private/interface/ColumnTypes.h index c9fc5882df..6e581fd7ba 100644 --- a/headers/private/interface/ColumnTypes.h +++ b/headers/private/interface/ColumnTypes.h @@ -60,10 +60,11 @@ class BStringField : public BField void SetString (const char* string); const char* String () const; void SetClippedString (const char* string); + bool HasClippedString () const; const char* ClippedString (); void SetWidth (float); float Width (); - + private: float fWidth; BString fString; @@ -109,7 +110,7 @@ class BDateField : public BField time_t Seconds (); time_t UnixTime (); - private: + private: struct tm fTime; time_t fUnixTime; time_t fSeconds; @@ -235,7 +236,7 @@ class BBitmapColumn : public BTitledColumn virtual int CompareFields (BField* field1, BField* field2); virtual bool AcceptsField (const BField* field) const; }; - + //===================================================================== // Column to display BIntegerField objects as a graph. diff --git a/headers/private/shared/AboutWindow.h b/headers/private/shared/AboutWindow.h index a8ec0b58fa..9a3cc60576 100644 --- a/headers/private/shared/AboutWindow.h +++ b/headers/private/shared/AboutWindow.h @@ -37,6 +37,9 @@ class BAboutWindow : public BWindow { void AddVersionHistory(const char** history); void AddExtraInfo(const char* extraInfo); + void AddText(const char* header, + const char** contents = NULL); + BBitmap* Icon(); void SetIcon(BBitmap* icon); diff --git a/src/add-ons/accelerants/intel_extreme/accelerant.h b/src/add-ons/accelerants/intel_extreme/accelerant.h index 1f8aa4523c..df5e274859 100644 --- a/src/add-ons/accelerants/intel_extreme/accelerant.h +++ b/src/add-ons/accelerants/intel_extreme/accelerant.h @@ -105,7 +105,7 @@ extern void save_lvds_mode(void); extern status_t create_mode_list(void); // memory.cpp -extern void intel_free_memory(uint32 base); -extern status_t intel_allocate_memory(size_t size, uint32 flags, uint32 &base); +extern void intel_free_memory(addr_t base); +extern status_t intel_allocate_memory(size_t size, uint32 flags, addr_t &base); #endif /* INTEL_EXTREME_ACCELERANT_H */ diff --git a/src/add-ons/accelerants/intel_extreme/memory.cpp b/src/add-ons/accelerants/intel_extreme/memory.cpp index 6ab8422266..731b972b72 100644 --- a/src/add-ons/accelerants/intel_extreme/memory.cpp +++ b/src/add-ons/accelerants/intel_extreme/memory.cpp @@ -27,7 +27,7 @@ void -intel_free_memory(uint32 base) +intel_free_memory(addr_t base) { if (base == 0) return; @@ -42,7 +42,7 @@ intel_free_memory(uint32 base) status_t -intel_allocate_memory(size_t size, uint32 flags, uint32 &base) +intel_allocate_memory(size_t size, uint32 flags, addr_t &base) { intel_allocate_graphics_memory allocMemory; allocMemory.magic = INTEL_PRIVATE_DATA_MAGIC; diff --git a/src/add-ons/accelerants/intel_extreme/mode.cpp b/src/add-ons/accelerants/intel_extreme/mode.cpp index 2727a16df0..4e87f10f78 100644 --- a/src/add-ons/accelerants/intel_extreme/mode.cpp +++ b/src/add-ons/accelerants/intel_extreme/mode.cpp @@ -77,7 +77,7 @@ struct pll_limits { static status_t get_i2c_signals(void* cookie, int* _clock, int* _data) { - uint32 ioRegister = (uint32)cookie; + uint32 ioRegister = (uint32)(addr_t)cookie; uint32 value = read32(ioRegister); *_clock = (value & I2C_CLOCK_VALUE_IN) != 0; @@ -90,7 +90,7 @@ get_i2c_signals(void* cookie, int* _clock, int* _data) static status_t set_i2c_signals(void* cookie, int clock, int data) { - uint32 ioRegister = (uint32)cookie; + uint32 ioRegister = (uint32)(addr_t)cookie; uint32 value; if (gInfo->shared_info->device_type.InGroup(INTEL_TYPE_83x)) { @@ -488,17 +488,20 @@ sanitize_display_mode(display_mode& mode) // TODO: verify constraints - these are more or less taken from the // radeon driver! - const display_constraints constraints = { + display_constraints constraints = { // resolution 320, 8192, 200, 4096, // pixel clock gInfo->shared_info->pll_info.min_frequency, gInfo->shared_info->pll_info.max_frequency, // horizontal - {olderCard ? 2 : 1, 0, 8160, 32, 8192, 0, 8192}, + {1, 0, 8160, 32, 8192, 0, 8192}, {1, 1, 4092, 2, 63, 1, 4096} }; + if (olderCard) + constraints.horizontal_timing.resolution = 2; + return sanitize_display_mode(mode, constraints, gInfo->has_edid ? &gInfo->edid_info : NULL); } @@ -563,7 +566,7 @@ status_t create_mode_list(void) { i2c_bus bus; - bus.cookie = (void*)INTEL_I2C_IO_A; + bus.cookie = (void*)(addr_t)INTEL_I2C_IO_A; bus.set_signals = &set_i2c_signals; bus.get_signals = &get_i2c_signals; ddc2_init_timing(&bus); @@ -762,7 +765,7 @@ if (first) { intel_free_memory(sharedInfo.frame_buffer); - uint32 base; + addr_t base; if (intel_allocate_memory(bytesPerRow * target.virtual_height, 0, base) < B_OK) { // oh, how did that happen? Unfortunately, there is no really good way diff --git a/src/add-ons/input_server/filters/shortcut_catcher/CommandActuators.cpp b/src/add-ons/input_server/filters/shortcut_catcher/CommandActuators.cpp index 84d63c5c97..eae5dad29e 100644 --- a/src/add-ons/input_server/filters/shortcut_catcher/CommandActuators.cpp +++ b/src/add-ons/input_server/filters/shortcut_catcher/CommandActuators.cpp @@ -609,10 +609,10 @@ KeyStrokeSequenceCommandActuator::KeyStrokeSequenceCommandActuator(int32 argc, BString newStr = fSequence; newStr.Truncate(nextStart); - fOverrides.AddItem((void*)unicodeVal); - fOverrideOffsets.AddItem((void*)newStr.Length()); - fOverrideModifiers.AddItem((void*)customMods); - fOverrideKeyCodes.AddItem((void*)customKey); + fOverrides.AddItem((void*)(addr_t)unicodeVal); + fOverrideOffsets.AddItem((void*)(addr_t)newStr.Length()); + fOverrideModifiers.AddItem((void*)(addr_t)customMods); + fOverrideKeyCodes.AddItem((void*)(addr_t)customKey); newStr.Append(((unicodeVal > 0) && (unicodeVal < 127)) ? ((char)unicodeVal): ' ',1); newStr.Append(&fSequence.String()[nextEnd + 2]); @@ -636,22 +636,22 @@ KeyStrokeSequenceCommandActuator::KeyStrokeSequenceCommandActuator( int32 temp; for (int32 i = 0; from->FindInt32("ooffsets", i, &temp) == B_NO_ERROR; i++) { - fOverrideOffsets.AddItem((void*)temp); + fOverrideOffsets.AddItem((void*)(addr_t)temp); if (from->FindInt32("overrides", i, &temp) != B_NO_ERROR) temp = ' '; - fOverrides.AddItem((void*)temp); + fOverrides.AddItem((void*)(addr_t)temp); if (from->FindInt32("omods", i, &temp) != B_NO_ERROR) temp = -1; - fOverrideModifiers.AddItem((void*)temp); + fOverrideModifiers.AddItem((void*)(addr_t)temp); if (from->FindInt32("okeys", i, &temp) != B_NO_ERROR) temp = 0; - fOverrideKeyCodes.AddItem((void*)temp); + fOverrideKeyCodes.AddItem((void*)(addr_t)temp); } _GenerateKeyCodes(); } @@ -682,9 +682,9 @@ KeyStrokeSequenceCommandActuator::_GenerateKeyCodes() uint32 overrideKey= 0; uint32 overrideMods = (uint32)-1; for (int32 j = fOverrideOffsets.CountItems()-1; j >= 0; j--) { - if ((int32)fOverrideOffsets.ItemAt(j) == i) { - overrideKey= (uint32) fOverrideKeyCodes.ItemAt(j); - overrideMods = (uint32) fOverrideModifiers.ItemAt(j); + if ((int32)(addr_t)fOverrideOffsets.ItemAt(j) == i) { + overrideKey= (uint32)(addr_t) fOverrideKeyCodes.ItemAt(j); + overrideMods = (uint32)(addr_t) fOverrideModifiers.ItemAt(j); break; } } @@ -853,19 +853,23 @@ KeyStrokeSequenceCommandActuator::Archive(BMessage* into, bool deep) const int32 numOverrides = fOverrideOffsets.CountItems(); status_t tmp = B_OK; for (int32 i = 0; i < numOverrides; i++) { - ret = into->AddInt32("ooffsets", (int32)fOverrideOffsets.ItemAt(i)); + ret = into->AddInt32("ooffsets", + (int32)(addr_t)fOverrideOffsets.ItemAt(i)); if (ret != B_NO_ERROR) tmp = B_ERROR; - ret = into->AddInt32("overrides", (int32)fOverrides.ItemAt(i)); + ret = into->AddInt32("overrides", + (int32)(addr_t)fOverrides.ItemAt(i)); if (ret != B_NO_ERROR) tmp = B_ERROR; - ret = into->AddInt32("omods", (int32)fOverrideModifiers.ItemAt(i)); + ret = into->AddInt32("omods", + (int32)(addr_t)fOverrideModifiers.ItemAt(i)); if (ret != B_NO_ERROR) tmp = B_ERROR; - ret = into->AddInt32("okeys", (int32)fOverrideKeyCodes.ItemAt(i)); + ret = into->AddInt32("okeys", + (int32)(addr_t)fOverrideKeyCodes.ItemAt(i)); } if (tmp == B_ERROR) @@ -895,9 +899,9 @@ KeyStrokeSequenceCommandActuator::KeyEvent(const BMessage* keyMsg, int32 override = -1; for (int32 j = fOverrideOffsets.CountItems()-1; j >= 0; j--) { - int32 offset = (int32) fOverrideOffsets.ItemAt(j); + int32 offset = (int32)(addr_t) fOverrideOffsets.ItemAt(j); if (offset == i) { - override = (int32) fOverrides.ItemAt(j); + override = (int32)(addr_t) fOverrides.ItemAt(j); break; } } diff --git a/src/add-ons/input_server/methods/canna/lib/kctrl.c b/src/add-ons/input_server/methods/canna/lib/kctrl.c index fe0a7ab6f7..60e3f4f888 100644 --- a/src/add-ons/input_server/methods/canna/lib/kctrl.c +++ b/src/add-ons/input_server/methods/canna/lib/kctrl.c @@ -2039,7 +2039,7 @@ KC_changeServer(uiContext d, char *arg) return 0; } } - return (int)RkwGetServerName(); + return (int)(addr_t)RkwGetServerName(); } static int @@ -2103,7 +2103,7 @@ KC_setUserInfo(uiContext d, jrUserInfoStruct *arg) sprintf(buf, "%s/%s", uinfo->topdir ? uinfo->topdir : "", "default.can"); } - wcKanjiControl((int)d, KC_SETINITFILENAME, buf); + wcKanjiControl((int)(addr_t)d, KC_SETINITFILENAME, buf); RkwSetUserInfo(uinfo->uname, uinfo->gname, uinfo->topdir); ret = 1; goto return_ret; diff --git a/src/add-ons/input_server/methods/canna/rk/dd.c b/src/add-ons/input_server/methods/canna/rk/dd.c index 128cd49ec7..8b84d9b36d 100644 --- a/src/add-ons/input_server/methods/canna/rk/dd.c +++ b/src/add-ons/input_server/methods/canna/rk/dd.c @@ -688,7 +688,7 @@ _RkRealizeDD(struct DD *dd) int ret = -1; int tmpres; int fdes; - long tloc; + time_t tloc; char *whattime, *header, *dicsdir, *backup; whattime = (char *)malloc(RK_LINE_BMAX); diff --git a/src/add-ons/kernel/bus_managers/agp_gart/agp_gart.cpp b/src/add-ons/kernel/bus_managers/agp_gart/agp_gart.cpp index cc43abb9ec..da9234efea 100644 --- a/src/add-ons/kernel/bus_managers/agp_gart/agp_gart.cpp +++ b/src/add-ons/kernel/bus_managers/agp_gart/agp_gart.cpp @@ -248,7 +248,7 @@ check_capabilities(agp_device_info &deviceInfo, uint32 &command) agpStatus = fix_rate_support(agpStatus); } - TRACE("device %u.%u.%u has AGP capabilities %lx\n", deviceInfo.info.bus, + TRACE("device %u.%u.%u has AGP capabilities %" B_PRIx32 "\n", deviceInfo.info.bus, deviceInfo.info.device, deviceInfo.info.function, agpStatus); // block non-supported AGP modes @@ -482,8 +482,8 @@ Aperture::CreateMemory(size_t size, size_t alignment, uint32 flags) return NULL; } - TRACE("create memory %p, base %lx, size %lx, flags %lx\n", memory, - memory->base, memory->size, flags); + TRACE("create memory %p, base %" B_PRIxADDR ", size %" B_PRIxSIZE + ", flags %" B_PRIx32 "\n", memory, memory->base, memory->size, flags); memory->flags = flags; #if defined(__HAIKU__) && !defined(GART_TEST) @@ -852,7 +852,7 @@ Aperture::_Insert(aperture_memory *memory, size_t size, size_t alignment, status_t get_nth_agp_info(uint32 index, agp_info *info) { - TRACE("get_nth_agp_info(index %lu)\n", index); + TRACE("get_nth_agp_info(index %" B_PRIu32 ")\n", index); if (index >= sDeviceCount) return B_BAD_VALUE; @@ -888,7 +888,7 @@ release_agp(void) uint32 set_agp_mode(uint32 command) { - TRACE("set_agp_mode(command %lx)\n", command); + TRACE("set_agp_mode(command %" B_PRIx32 ")\n", command); if ((command & AGP_ENABLE) == 0) { set_pci_mode(); @@ -912,7 +912,7 @@ set_agp_mode(uint32 command) } command = fix_rate_command(command); - TRACE("set AGP command %lx on all capable devices.\n", command); + TRACE("set AGP command %" B_PRIx32 " on all capable devices.\n", command); // The order of programming differs for enabling/disabling AGP mode // (see AGP specification) @@ -1213,7 +1213,7 @@ agp_init(void) sDeviceCount++; } - TRACE("found %ld AGP devices\n", sDeviceCount); + TRACE("found %" B_PRId32 " AGP devices\n", sDeviceCount); // Since there can be custom aperture modules (for memory management only), // we always succeed if we could get the resources we need. diff --git a/src/add-ons/kernel/busses/agp_gart/intel_gart.cpp b/src/add-ons/kernel/busses/agp_gart/intel_gart.cpp index 7a358d653b..77c6ff288e 100644 --- a/src/add-ons/kernel/busses/agp_gart/intel_gart.cpp +++ b/src/add-ons/kernel/busses/agp_gart/intel_gart.cpp @@ -385,7 +385,7 @@ intel_map(intel_info &info) AreaKeeper mmioMapper; info.registers_area = mmioMapper.Map("intel GMCH mmio", - (void*)info.display.u.h0.base_registers[mmioIndex], + info.display.u.h0.base_registers[mmioIndex], info.display.u.h0.base_register_sizes[mmioIndex], B_ANY_KERNEL_ADDRESS, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA, (void**)&info.registers); if (mmioMapper.InitCheck() < B_OK) { @@ -444,7 +444,7 @@ intel_map(intel_info &info) AreaKeeper gttMapper; info.gtt_area = gttMapper.Map("intel GMCH gtt", - (void*)info.gtt_physical_base, gttSize, B_ANY_KERNEL_ADDRESS, + info.gtt_physical_base, gttSize, B_ANY_KERNEL_ADDRESS, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA, (void**)&info.gtt_base); if (gttMapper.InitCheck() < B_OK) { dprintf("intel_gart: could not map GTT!\n"); @@ -467,7 +467,7 @@ intel_map(intel_info &info) AreaKeeper apertureMapper; info.aperture_area = apertureMapper.Map("intel graphics aperture", - (void*)info.aperture_physical_base, info.aperture_size, + info.aperture_physical_base, info.aperture_size, B_ANY_KERNEL_BLOCK_ADDRESS | B_MTR_WC, B_READ_AREA | B_WRITE_AREA, (void**)&info.aperture_base); if (apertureMapper.InitCheck() < B_OK) { @@ -475,7 +475,7 @@ intel_map(intel_info &info) dprintf(DEVICE_NAME ": enabling write combined mode failed.\n"); info.aperture_area = apertureMapper.Map("intel graphics aperture", - (void*)info.aperture_physical_base, info.aperture_size, + info.aperture_physical_base, info.aperture_size, B_ANY_KERNEL_BLOCK_ADDRESS, B_READ_AREA | B_WRITE_AREA, (void**)&info.aperture_base); } diff --git a/src/add-ons/kernel/busses/ata/silicon_image_3112/silicon_image_3112.c b/src/add-ons/kernel/busses/ata/silicon_image_3112/silicon_image_3112.c index d0037ddc9c..0038c4c842 100644 --- a/src/add-ons/kernel/busses/ata/silicon_image_3112/silicon_image_3112.c +++ b/src/add-ons/kernel/busses/ata/silicon_image_3112/silicon_image_3112.c @@ -69,7 +69,7 @@ typedef struct controller_data { uint32 int_num; area_id mmio_area; - uint32 mmio_addr; + addr_t mmio_addr; uint32 lost; // != 0 if device got removed, i.e. if it must not // be accessed anymore @@ -251,7 +251,7 @@ controller_init(device_node *node, void **_controllerCookie) pci_device *device; uint32 asicIndex; uint32 mmioBase; - uint32 mmioAddr; + addr_t mmioAddr; area_id mmioArea; uint32 interruptNumber; status_t res; @@ -286,10 +286,10 @@ controller_init(device_node *node, void **_controllerCookie) sDeviceManager->get_driver(parent, (driver_module_info **)&pci, (void **)&device); sDeviceManager->put_node(parent); - TRACE("asic index %ld\n", asicIndex); + TRACE("asic index %" B_PRId32 "\n", asicIndex); TRACE("asic name %s\n", kASICData[asicIndex].asic_name); - TRACE("int num %ld\n", interruptNumber); - TRACE("mmio addr %p\n", (void *)mmioAddr); + TRACE("int num %" B_PRId32 "\n", interruptNumber); + TRACE("mmio addr %" B_PRIxADDR"\n", mmioAddr); controller->pci = pci; controller->device = device; @@ -437,7 +437,7 @@ channel_init(device_node *node, void **_channelCookie) } #endif - TRACE("channel_index %ld\n", channelIndex); + TRACE("channel_index %" B_PRId32 "\n", channelIndex); TRACE("channel name: %s\n", kControllerChannelData[channelIndex].name); TRACE("channel %p\n", channel); @@ -685,19 +685,19 @@ dma_prepare(void *channelCookie, const physical_entry *sg_list, for (i = sg_list_count - 1, prd = channel->prdt; i >= 0; --i, ++prd, ++sg_list ) { - prd->address = B_HOST_TO_LENDIAN_INT32((uint32)pci->ram_address(device, + prd->address = B_HOST_TO_LENDIAN_INT32((uint32)(addr_t)pci->ram_address(device, (void*)(addr_t)sg_list->address)); // 0 means 64K - this is done automatically by discarding upper 16 bits prd->count = B_HOST_TO_LENDIAN_INT16((uint16)sg_list->size); prd->EOT = i == 0; - FLOW("%x, %x, %d\n", (int)prd->address, prd->count, prd->EOT); + FLOW("%" B_PRIx32", %" B_PRId16", %" B_PRId8"\n", prd->address, prd->count, prd->EOT); } // XXX move this to chan init? temp = (*channel->bm_prdt_address) & 3; - temp |= B_HOST_TO_LENDIAN_INT32((uint32)pci->ram_address(device, + temp |= B_HOST_TO_LENDIAN_INT32((uint32)(addr_t)pci->ram_address(device, (void *)(addr_t)channel->prdt_phys)) & ~3; *channel->bm_prdt_address = temp; diff --git a/src/add-ons/kernel/drivers/audio/echo/midi.cpp b/src/add-ons/kernel/drivers/audio/echo/midi.cpp index d10d16dd55..f90302f56a 100644 --- a/src/add-ons/kernel/drivers/audio/echo/midi.cpp +++ b/src/add-ons/kernel/drivers/audio/echo/midi.cpp @@ -131,13 +131,15 @@ midi_read(void* cookie, off_t pos, void* ptr, size_t* nread) static status_t -midi_write(void* cookie, off_t pos, const void* ptr, size_t* nwritten) +midi_write(void* cookie, off_t pos, const void* ptr, size_t* _nwritten) { echo_dev *card = (echo_dev *) cookie; ECHOSTATUS err; + DWORD nwritten = *_nwritten; LOG(("midi_write()\n")); - err = card->pEG->WriteMidi(*nwritten, (PBYTE)ptr, nwritten); + err = card->pEG->WriteMidi(nwritten, (PBYTE)ptr, &nwritten); + *_nwritten = nwritten; return (err != ECHOSTATUS_OK) ? B_ERROR : B_OK; } diff --git a/src/add-ons/kernel/drivers/audio/echo/multi.cpp b/src/add-ons/kernel/drivers/audio/echo/multi.cpp index ffd364c897..9388550161 100644 --- a/src/add-ons/kernel/drivers/audio/echo/multi.cpp +++ b/src/add-ons/kernel/drivers/audio/echo/multi.cpp @@ -97,8 +97,8 @@ echo_channel_get_mix(void *card, MIXER_AUDIO_CHANNEL channel, int32 type, float } else { values[0] = function[0].Data.iNominal == 4 ? 1.0 : 0.0; } - PRINT(("echo_channel_get_mix iLevel: %ld, %d, %ld\n", function[0].Data.iLevel, - channel.wChannel, channel.dwType)); + PRINT(("echo_channel_get_mix iLevel: %" B_PRId32 ", %d, %" B_PRIu32 + "\n", function[0].Data.iLevel, channel.wChannel, channel.dwType)); } } @@ -134,8 +134,8 @@ echo_channel_set_mix(void *card, MIXER_AUDIO_CHANNEL channel, int32 type, float dev->pEG->ProcessMixerMultiFunction(multi_function, size); if (function[0].RtnStatus == ECHOSTATUS_OK) { - PRINT(("echo_channel_set_mix OK: %ld, %d, %ld\n", function[0].Data.iLevel, - channel.wChannel, channel.dwType)); + PRINT(("echo_channel_set_mix OK: %" B_PRId32 ", %d, %" B_PRIu32 "\n", + function[0].Data.iLevel, channel.wChannel, channel.dwType)); } } @@ -242,7 +242,7 @@ echo_create_controls_list(multi_dev *multi) } multi->control_count = index; - PRINT(("multi->control_count %lu\n", multi->control_count)); + PRINT(("multi->control_count %" B_PRIu32 "\n", multi->control_count)); return B_OK; } @@ -256,7 +256,8 @@ echo_get_mix(echo_dev *card, multi_mix_value_info * mmvi) for (i = 0; i < mmvi->item_count; i++) { id = mmvi->values[i].id - MULTI_CONTROL_FIRSTID; if (id < 0 || id >= card->multi.control_count) { - PRINT(("echo_get_mix : invalid control id requested : %li\n", id)); + PRINT(("echo_get_mix : invalid control id requested : %" B_PRIu32 + "\n", id)); continue; } control = &card->multi.controls[id]; @@ -297,7 +298,8 @@ echo_set_mix(echo_dev *card, multi_mix_value_info * mmvi) for (i = 0; i < mmvi->item_count; i++) { id = mmvi->values[i].id - MULTI_CONTROL_FIRSTID; if (id < 0 || id >= card->multi.control_count) { - PRINT(("echo_set_mix : invalid control id requested : %li\n", id)); + PRINT(("echo_set_mix : invalid control id requested : %" B_PRIu32 + "\n", id)); continue; } control = &card->multi.controls[id]; @@ -307,7 +309,8 @@ echo_set_mix(echo_dev *card, multi_mix_value_info * mmvi) if (i + 1 < mmvi->item_count) { id = mmvi->values[i + 1].id - MULTI_CONTROL_FIRSTID; if (id < 0 || id >= card->multi.control_count) { - PRINT(("echo_set_mix : invalid control id requested : %li\n", id)); + PRINT(("echo_set_mix : invalid control id requested : %" + B_PRIu32 "\n", id)); } else { control2 = &card->multi.controls[id]; if (control2->mix_control.master != control->mix_control.id) @@ -995,21 +998,21 @@ echo_open(const char *name, uint32 flags, void** cookie) value = strtoul (item, &end, 0); if (*end == '\0') current_settings.sample_rate = value; } - PRINT(("sample_rate %lu\n", current_settings.sample_rate)); + PRINT(("sample_rate %" B_PRIu32 "\n", current_settings.sample_rate)); item = get_driver_parameter (settings_handle, "buffer_frames", NULL, NULL); if (item) { value = strtoul (item, &end, 0); if (*end == '\0') current_settings.buffer_frames = value; } - PRINT(("buffer_frames %lu\n", current_settings.buffer_frames)); + PRINT(("buffer_frames %" B_PRIu32 "\n", current_settings.buffer_frames)); item = get_driver_parameter (settings_handle, "buffer_count", NULL, NULL); if (item) { value = strtoul (item, &end, 0); if (*end == '\0') current_settings.buffer_count = value; } - PRINT(("buffer_count %lu\n", current_settings.buffer_count)); + PRINT(("buffer_count %" B_PRId32 "\n", current_settings.buffer_count)); unload_driver_settings (settings_handle); } diff --git a/src/add-ons/kernel/drivers/audio/emuxki/emuxki.c b/src/add-ons/kernel/drivers/audio/emuxki/emuxki.c index c69a304382..713554615d 100644 --- a/src/add-ons/kernel/drivers/audio/emuxki/emuxki.c +++ b/src/add-ons/kernel/drivers/audio/emuxki/emuxki.c @@ -353,12 +353,12 @@ emuxki_mem_free(emuxki_dev *card, void *ptr) static void emuxki_chanparms_set_defaults(emuxki_channel *chan) { - chan->fxsend.a.level = chan->fxsend.b.level = - chan->fxsend.c.level = chan->fxsend.d.level = + chan->fxsend.a.level = chan->fxsend.b.level + = chan->fxsend.c.level = chan->fxsend.d.level /* for audigy */ - chan->fxsend.e.level = chan->fxsend.f.level = - chan->fxsend.g.level = chan->fxsend.h.level = - IS_AUDIGY(&chan->voice->stream->card->config) ? 0xc0 : 0xff; /* not max */ + = chan->fxsend.e.level = chan->fxsend.f.level + = chan->fxsend.g.level = chan->fxsend.h.level + = IS_AUDIGY(&chan->voice->stream->card->config) ? 0xc0 : 0xff; /* not max */ chan->fxsend.a.dest = 0x0; chan->fxsend.b.dest = 0x1; diff --git a/src/add-ons/kernel/drivers/bus/usb/usb_raw.cpp b/src/add-ons/kernel/drivers/bus/usb/usb_raw.cpp index d430080f19..3199d03d02 100644 --- a/src/add-ons/kernel/drivers/bus/usb/usb_raw.cpp +++ b/src/add-ons/kernel/drivers/bus/usb/usb_raw.cpp @@ -49,7 +49,7 @@ static char **gDeviceNames = NULL; static status_t usb_raw_device_added(usb_device newDevice, void **cookie) { - TRACE((DRIVER_NAME": device_added(0x%08lx)\n", newDevice)); + TRACE((DRIVER_NAME": device_added(0x%08" B_PRIx32 ")\n", newDevice)); raw_device *device = (raw_device *)malloc(sizeof(raw_device)); mutex_init(&device->lock, "usb_raw device lock"); @@ -66,7 +66,7 @@ usb_raw_device_added(usb_device newDevice, void **cookie) if (gUSBModule->usb_ioctl('DNAM', deviceName, sizeof(deviceName)) >= B_OK) { snprintf(device->name, sizeof(device->name), "bus/usb/%s", deviceName); } else { - snprintf(device->name, sizeof(device->name), "bus/usb/%08lx", + snprintf(device->name, sizeof(device->name), "bus/usb/%08" B_PRIx32, newDevice); } @@ -79,7 +79,7 @@ usb_raw_device_added(usb_device newDevice, void **cookie) gDeviceCount++; mutex_unlock(&gDeviceListLock); - TRACE((DRIVER_NAME": new device: 0x%08lx\n", (uint32)device)); + TRACE((DRIVER_NAME": new device: 0x%p\n", device)); *cookie = (void *)device; return B_OK; } @@ -88,7 +88,7 @@ usb_raw_device_added(usb_device newDevice, void **cookie) static status_t usb_raw_device_removed(void *cookie) { - TRACE((DRIVER_NAME": device_removed(0x%08lx)\n", (uint32)cookie)); + TRACE((DRIVER_NAME": device_removed(0x%p)\n", cookie)); raw_device *device = (raw_device *)cookie; mutex_lock(&gDeviceListLock); @@ -825,7 +825,8 @@ init_driver() status_t result = get_module(B_USB_MODULE_NAME, (module_info **)&gUSBModule); if (result < B_OK) { - TRACE((DRIVER_NAME": getting module failed 0x%08lx\n", result)); + TRACE((DRIVER_NAME": getting module failed 0x%08" B_PRIx32 "\n", + result)); mutex_destroy(&gDeviceListLock); return result; } diff --git a/src/add-ons/kernel/drivers/disk/usb/usb_floppy/usb_disk.cpp b/src/add-ons/kernel/drivers/disk/usb/usb_floppy/usb_disk.cpp index 0f19f99826..b24a77ce04 100644 --- a/src/add-ons/kernel/drivers/disk/usb/usb_floppy/usb_disk.cpp +++ b/src/add-ons/kernel/drivers/disk/usb/usb_floppy/usb_disk.cpp @@ -18,7 +18,7 @@ #define DRIVER_NAME "usb_floppy" #define DEVICE_NAME_BASE "disk/ufi/" -#define DEVICE_NAME DEVICE_NAME_BASE"%ld/%d/raw" +#define DEVICE_NAME DEVICE_NAME_BASE "%" B_PRId32 "/%d/raw" //#define TRACE_USB_DISK @@ -113,7 +113,7 @@ status_t usb_disk_transfer_data(disk_device *device, bool directionIn, status_t usb_disk_receive_csw(disk_device *device, command_status_wrapper *status); status_t usb_disk_operation(device_lun *lun, uint8* operation, - void *data, uint32 *dataLength, + void *data, size_t *dataLength, bool directionIn); status_t usb_disk_send_diagnostic(device_lun *lun); @@ -194,7 +194,7 @@ usb_disk_transfer_data(disk_device *device, bool directionIn, void *data, void -usb_disk_interrupt(void* cookie, int32 status, void* data, uint32 length) +usb_disk_interrupt(void* cookie, int32 status, void* data, size_t length) { disk_device* dev = (disk_device*)cookie; // We release the lock even if the interrupt is invalid. This way there @@ -202,7 +202,8 @@ usb_disk_interrupt(void* cookie, int32 status, void* data, uint32 length) release_sem(dev->interruptLock); if (length != 2) { - TRACE_ALWAYS("interrupt of length %ld! (expected 2)\n", length); + TRACE_ALWAYS("interrupt of length %" B_PRIuSIZE "! (expected 2)\n", + length); // In this case we do not reschedule the interrupt. This means the // driver will be locked. The interrupt should perhaps be scheduled // when starting a transfer instead. But getting there means something @@ -234,7 +235,7 @@ usb_disk_receive_csw(disk_device *device, command_status_wrapper *status) status_t usb_disk_operation(device_lun *lun, uint8* operation, - void *data, uint32 *dataLength, bool directionIn) + void *data, size_t *dataLength, bool directionIn) { // TODO: remove transferLength TRACE("operation: lun: %u; op: 0x%x; data: %p; dlen: %p (%lu); in: %c\n", @@ -342,7 +343,7 @@ usb_disk_send_diagnostic(device_lun *lun) status_t usb_disk_request_sense(device_lun *lun) { - uint32 dataLength = sizeof(scsi_request_sense_6_parameter); + size_t dataLength = sizeof(scsi_request_sense_6_parameter); uint8 commandBlock[12]; memset(commandBlock, 0, sizeof(commandBlock)); @@ -413,7 +414,7 @@ usb_disk_request_sense(device_lun *lun) status_t usb_disk_mode_sense(device_lun *lun) { - uint32 dataLength = sizeof(scsi_mode_sense_6_parameter); + size_t dataLength = sizeof(scsi_mode_sense_6_parameter); uint8 commandBlock[12]; memset(commandBlock, 0, sizeof(commandBlock)); @@ -459,7 +460,7 @@ usb_disk_test_unit_ready(device_lun *lun) status_t usb_disk_inquiry(device_lun *lun) { - uint32 dataLength = sizeof(scsi_inquiry_6_parameter); + size_t dataLength = sizeof(scsi_inquiry_6_parameter); uint8 commandBlock[12]; memset(commandBlock, 0, sizeof(commandBlock)); @@ -526,7 +527,7 @@ usb_disk_reset_capacity(device_lun *lun) status_t usb_disk_update_capacity(device_lun *lun) { - uint32 dataLength = sizeof(scsi_read_capacity_10_parameter); + size_t dataLength = sizeof(scsi_read_capacity_10_parameter); scsi_read_capacity_10_parameter parameter; status_t result = B_ERROR; @@ -668,8 +669,8 @@ usb_disk_device_added(usb_device newDevice, void **cookie) mutex_init(&device->lock, "usb_disk device lock"); - status_t result = device->notify = - create_sem(0, "usb_disk callback notify"); + status_t result = device->notify + = create_sem(0, "usb_disk callback notify"); if (result < B_OK) { mutex_destroy(&device->lock); @@ -1172,7 +1173,7 @@ usb_disk_ioctl(void *cookie, uint32 op, void *buffer, size_t length) #endif default: - TRACE_ALWAYS("unhandled ioctl %ld\n", op); + TRACE_ALWAYS("unhandled ioctl %" B_PRIu32 "\n", op); break; } @@ -1223,7 +1224,7 @@ usb_disk_read(void *cookie, off_t position, void *buffer, size_t *length) } *length = 0; - TRACE_ALWAYS("read fails with 0x%08lx\n", result); + TRACE_ALWAYS("read fails with 0x%08" B_PRIx32 "\n", result); return result; } @@ -1274,7 +1275,7 @@ usb_disk_write(void *cookie, off_t position, const void *buffer, } *length = 0; - TRACE_ALWAYS("write fails with 0x%08lx\n", result); + TRACE_ALWAYS("write fails with 0x%08" B_PRIx32 "\n", result); return result; } @@ -1314,7 +1315,7 @@ init_driver() status_t result = get_module(B_USB_MODULE_NAME, (module_info **)&gUSBModule); if (result < B_OK) { - TRACE_ALWAYS("getting module failed 0x%08lx\n", result); + TRACE_ALWAYS("getting module failed 0x%08" B_PRIx32 "\n", result); mutex_destroy(&gDeviceListLock); return result; } diff --git a/src/add-ons/kernel/drivers/disk/virtual/nbd/nbd.c b/src/add-ons/kernel/drivers/disk/virtual/nbd/nbd.c index f3cc5e8dbe..21068357dd 100644 --- a/src/add-ons/kernel/drivers/disk/virtual/nbd/nbd.c +++ b/src/add-ons/kernel/drivers/disk/virtual/nbd/nbd.c @@ -174,7 +174,8 @@ status_t nbd_alloc_request(struct nbd_device *dev, struct nbd_request_entry **re struct nbd_request_entry *r; status_t err = EINVAL; uint64 handle; - PRINT((DP ">%s(%ld, %Ld, %ld)\n", __FUNCTION__, type, from, len)); + PRINT((DP ">%s(%" B_PRIu32 ", %" B_PRIdOFF ", %ld)\n", __FUNCTION__, type, + from, len)); if (type != NBD_CMD_READ && type != NBD_CMD_WRITE && type != NBD_CMD_DISC) return err; @@ -223,14 +224,14 @@ status_t nbd_alloc_request(struct nbd_device *dev, struct nbd_request_entry **re err1: free(r); err0: - dprintf(DP " %s: error 0x%08lx\n", __FUNCTION__, err); + dprintf(DP " %s: error 0x%08" B_PRIx32 "\n", __FUNCTION__, err); return err; } status_t nbd_queue_request(struct nbd_device *dev, struct nbd_request_entry *req) { - PRINT((DP ">%s(handle:%Ld)\n", __FUNCTION__, req->handle)); + PRINT((DP ">%s(handle:%" B_PRIu64 ")\n", __FUNCTION__, req->handle)); req->next = dev->reqs; dev->reqs = req; return B_OK; @@ -240,7 +241,7 @@ status_t nbd_queue_request(struct nbd_device *dev, struct nbd_request_entry *req status_t nbd_dequeue_request(struct nbd_device *dev, uint64 handle, struct nbd_request_entry **req) { struct nbd_request_entry *r, *prev; - PRINT((DP ">%s(handle:%Ld)\n", __FUNCTION__, handle)); + PRINT((DP ">%s(handle:%" B_PRIu64 ")\n", __FUNCTION__, handle)); r = dev->reqs; prev = NULL; while (r && r->handle != handle) { @@ -262,7 +263,7 @@ status_t nbd_dequeue_request(struct nbd_device *dev, uint64 handle, struct nbd_r status_t nbd_free_request(struct nbd_device *dev, struct nbd_request_entry *req) { - PRINT((DP ">%s(handle:%Ld)\n", __FUNCTION__, req->handle)); + PRINT((DP ">%s(handle:%" B_PRIu64 ")\n", __FUNCTION__, req->handle)); delete_sem(req->sem); free(req); return B_OK; @@ -354,7 +355,7 @@ int32 nbd_postoffice(void *arg) return 0; err: - dprintf(DP "%s: %s: error 0x%08lx\n", __FUNCTION__, reason, err); + dprintf(DP "%s: %s: error 0x%08" B_PRIx32 "\n", __FUNCTION__, reason, err); return err; } @@ -397,7 +398,8 @@ status_t nbd_connect(struct nbd_device *dev) dev->size = B_BENDIAN_TO_HOST_INT64(initpkt.device_size); - dprintf(DP " %s: connected, device size %Ld bytes.\n", __FUNCTION__, dev->size); + dprintf(DP " %s: connected, device size %" B_PRIu64 " bytes.\n", + __FUNCTION__, dev->size); err = dev->postoffice = spawn_kernel_thread(nbd_postoffice, "nbd postoffice", B_REAL_TIME_PRIORITY, dev); if (err < B_OK) @@ -415,7 +417,7 @@ err1: kclosesocket(dev->sock); dev->sock = -1; err0: - dprintf(DP "<%s: error 0x%08lx\n", __FUNCTION__, err); + dprintf(DP "<%s: error 0x%08" B_PRIx32 "\n", __FUNCTION__, err); return err; } @@ -435,7 +437,7 @@ status_t nbd_teardown(struct nbd_device *dev) status_t nbd_post_request(struct nbd_device *dev, struct nbd_request_entry *req) { status_t err; - PRINT((DP ">%s(handle:%Ld)\n", __FUNCTION__, req->handle)); + PRINT((DP ">%s(handle:%" B_PRIu64 ")\n", __FUNCTION__, req->handle)); err = ksend(dev->sock, &req->req, sizeof(req->req), 0); if (err < 0) @@ -466,7 +468,7 @@ status_t nbd_open(const char *name, uint32 flags, cookie_t **cookie) { int kfd; #endif struct nbd_device *dev = NULL; - PRINT((DP ">%s(%s, %lx, )\n", __FUNCTION__, name, flags)); + PRINT((DP ">%s(%s, %" B_PRIx32 ", )\n", __FUNCTION__, name, flags)); (void)name; (void)flags; dev = nbd_find_device(name); if (!dev || !dev->valid) @@ -509,7 +511,7 @@ err2: err1: free(*cookie); err0: - dprintf(DP " %s: error 0x%08lx\n", __FUNCTION__, err); + dprintf(DP " %s: error 0x%08" B_PRIx32 "\n", __FUNCTION__, err); return err; } @@ -564,7 +566,8 @@ status_t nbd_free(cookie_t *cookie) { status_t nbd_control(cookie_t *cookie, uint32 op, void *data, size_t len) { - PRINT((DP ">%s(%d, %lu, , %ld)\n", __FUNCTION__, WHICH(cookie->dev), op, len)); + PRINT((DP ">%s(%d, %" B_PRIu32 ", , %ld)\n", __FUNCTION__, + WHICH(cookie->dev), op, len)); switch (op) { case B_GET_DEVICE_SIZE: /* this one is broken anyway... */ if (data) { @@ -623,7 +626,8 @@ status_t nbd_read(cookie_t *cookie, off_t position, void *data, size_t *numbytes struct nbd_device *dev = cookie->dev; struct nbd_request_entry *req; status_t err, semerr; - PRINT((DP ">%s(%d, %Ld, , )\n", __FUNCTION__, WHICH(cookie->dev), position)); + PRINT((DP ">%s(%d, %" B_PRIdOFF ", , )\n", __FUNCTION__, + WHICH(cookie->dev), position)); if (position < 0) return EINVAL; @@ -692,7 +696,8 @@ status_t nbd_write(cookie_t *cookie, off_t position, const void *data, size_t *n struct nbd_device *dev = cookie->dev; struct nbd_request_entry *req; status_t err, semerr; - PRINT((DP ">%s(%d, %Ld, %ld, )\n", __FUNCTION__, WHICH(cookie->dev), position, *numbytes)); + PRINT((DP ">%s(%d, %" B_PRIdOFF ", %ld, )\n", __FUNCTION__, + WHICH(cookie->dev), position, *numbytes)); if (position < 0) return EINVAL; diff --git a/src/add-ons/kernel/drivers/dvb/cx23882/cx23882.c b/src/add-ons/kernel/drivers/dvb/cx23882/cx23882.c index dcba84cc35..b0d33e5c50 100644 --- a/src/add-ons/kernel/drivers/dvb/cx23882/cx23882.c +++ b/src/add-ons/kernel/drivers/dvb/cx23882/cx23882.c @@ -244,7 +244,9 @@ cx23882_int(void *data) if (mstat & (PCI_INT_STAT_HST_INT | PCI_INT_STAT_VIP_INT | PCI_INT_STAT_AUD_INT | PCI_INT_STAT_VID_INT)) { // serious error, these bits should not be set - dprintf("cx23882_int error: msk 0x%08lx, stat 0x%08lx, mstat 0x%08lx\n", reg_read32(REG_PCI_INT_MSK), reg_read32(REG_PCI_INT_STAT), mstat); + dprintf("cx23882_int error: msk 0x%08" B_PRIx32 ", stat 0x%08" B_PRIx32 + ", mstat 0x%08" B_PRIx32 "\n", reg_read32(REG_PCI_INT_MSK), + reg_read32(REG_PCI_INT_STAT), mstat); reg_write32(REG_PCI_INT_MSK, 0); return B_HANDLED_INTERRUPT; } @@ -254,7 +256,7 @@ cx23882_int(void *data) reg_write32(REG_PCI_INT_STAT, wmstat); if (wmstat) - dprintf("cx23882_int got 0x%08lx\n", wmstat); + dprintf("cx23882_int got 0x%08" B_PRIx32 "\n", wmstat); if (mstat & PCI_INT_STAT_TS_INT) { cx23882_mpegts_int(device); diff --git a/src/add-ons/kernel/drivers/dvb/cx23882/cx23882.h b/src/add-ons/kernel/drivers/dvb/cx23882/cx23882.h index 0204c6cb79..56b7f4f4a5 100644 --- a/src/add-ons/kernel/drivers/dvb/cx23882/cx23882.h +++ b/src/add-ons/kernel/drivers/dvb/cx23882/cx23882.h @@ -40,10 +40,10 @@ typedef struct { area_id dma_buf1_area; void * dma_buf1_virt; - void * dma_buf1_phys; + phys_addr_t dma_buf1_phys; area_id dma_buf2_area; void * dma_buf2_virt; - void * dma_buf2_phys; + phys_addr_t dma_buf2_phys; sem_id capture_sem; void * capture_data; diff --git a/src/add-ons/kernel/drivers/dvb/cx23882/dtt7592.c b/src/add-ons/kernel/drivers/dvb/cx23882/dtt7592.c index 06a36ad8c4..8940641e5e 100644 --- a/src/add-ons/kernel/drivers/dvb/cx23882/dtt7592.c +++ b/src/add-ons/kernel/drivers/dvb/cx23882/dtt7592.c @@ -68,7 +68,8 @@ dtt7592_set_frequency(i2c_bus *bus, uint32 frequency, dvb_bandwidth_t bandwidth) if (divider > 0x7fff) divider = 0x7fff; - TRACE("dtt7592_set_frequency frequency %ld, divider 0x%lx (%ld)\n", frequency, divider, divider); + TRACE("dtt7592_set_frequency frequency %" B_PRId32 ", divider 0x%" + B_PRIx32 " (%" B_PRId32 ")\n", frequency, divider, divider); data[0] = divider >> 8; data[1] = (uint8)divider; diff --git a/src/add-ons/kernel/drivers/dvb/cx23882/dvb_interface.c b/src/add-ons/kernel/drivers/dvb/cx23882/dvb_interface.c index 2213c77acb..2d3415eea3 100644 --- a/src/add-ons/kernel/drivers/dvb/cx23882/dvb_interface.c +++ b/src/add-ons/kernel/drivers/dvb/cx23882/dvb_interface.c @@ -95,7 +95,8 @@ interface_attach(void **cookie, const pci_info *info) // adjust PCI latency timer val = gPci->read_pci_config(device->pci_info->bus, device->pci_info->device, device->pci_info->function, PCI_latency, 1); - TRACE("PCI latency is %02lx, changing to %02x\n", val, PCI_LATENCY); + TRACE("PCI latency is %02" B_PRIx32 ", changing to %02x\n", val, + PCI_LATENCY); gPci->write_pci_config(device->pci_info->bus, device->pci_info->device, device->pci_info->function, PCI_latency, 1, PCI_LATENCY); // get IRQ @@ -113,8 +114,9 @@ interface_attach(void **cookie, const pci_info *info) dprintf("cx23882: Error, no memory space assigned\n"); goto err; } - TRACE("hardware register address %p\n", (void *) val); - device->regs_area = map_mem(&device->regs, (void *)val, 16777216 /* 16 MB */, 0, "cx23882 registers"); + TRACE("hardware register address 0x%" B_PRIx32 "\n", val); + device->regs_area = map_mem(&device->regs, (addr_t)val, + 16777216 /* 16 MB */, 0, "cx23882 registers"); if (device->regs_area < B_OK) { dprintf("cx23882: Error, can't map hardware registers\n"); goto err; diff --git a/src/add-ons/kernel/drivers/dvb/cx23882/util.c b/src/add-ons/kernel/drivers/dvb/cx23882/util.c index 77da6534c0..ceb0b623de 100644 --- a/src/add-ons/kernel/drivers/dvb/cx23882/util.c +++ b/src/add-ons/kernel/drivers/dvb/cx23882/util.c @@ -37,47 +37,49 @@ area_id -map_mem(void **virt, void *phy, size_t size, uint32 protection, +map_mem(void **virt, phys_addr_t phy, size_t size, uint32 protection, const char *name) { uint32 offset; - void *phyadr; + phys_addr_t phyadr; void *mapadr; area_id area; - TRACE("mapping physical address %p with %ld bytes for %s\n", phy, size, - name); + TRACE("mapping physical address %" B_PRIxPHYSADDR " with %ld bytes for %s\n", + phy, size, name); offset = (uint32)phy & (B_PAGE_SIZE - 1); - phyadr = (char *)phy - offset; + phyadr = phy - offset; size = ROUNDUP(size + offset, B_PAGE_SIZE); - area = map_physical_memory(name, (addr_t)phyadr, size, + area = map_physical_memory(name, phyadr, size, B_ANY_KERNEL_BLOCK_ADDRESS, protection, &mapadr); if (area < B_OK) { - TRACE("mapping '%s' failed, error 0x%lx (%s)\n", name, area, strerror(area)); + TRACE("mapping '%s' failed, error 0x%" B_PRIx32 " (%s)\n", name, area, + strerror(area)); return area; } *virt = (char *)mapadr + offset; - TRACE("physical = %p, virtual = %p, offset = %ld, phyadr = %p, mapadr = %p, size = %ld, area = 0x%08lx\n", - phy, *virt, offset, phyadr, mapadr, size, area); + TRACE("physical = %" B_PRIxPHYSADDR ", virtual = %p, offset = %" B_PRIu32 + ", phyadr = %" B_PRIxPHYSADDR ", mapadr = %p, size = %" B_PRIuSIZE + ", area = 0x%08" B_PRIx32 "\n", phy, *virt, offset, phyadr, mapadr, + size, area); return area; } area_id -alloc_mem(void **virt, void **phy, size_t size, uint32 protection, +alloc_mem(void **virt, phys_addr_t *phy, size_t size, uint32 protection, const char *name) { -// TODO: phy should be phys_addr_t*! physical_entry pe; void * virtadr; area_id areaid; status_t rv; - TRACE("allocating %ld bytes for %s\n", size, name); + TRACE("allocating %" B_PRIuSIZE " bytes for %s\n", size, name); size = ROUNDUP(size, B_PAGE_SIZE); areaid = create_area(name, &virtadr, B_ANY_KERNEL_ADDRESS, size, @@ -97,7 +99,8 @@ alloc_mem(void **virt, void **phy, size_t size, uint32 protection, if (virt) *virt = virtadr; if (phy) - *phy = (void*)(addr_t)pe.address; - TRACE("area = %ld, size = %ld, virt = %p, phy = %" B_PRIxPHYSADDR "\n", areaid, size, virtadr, pe.address); + *phy = pe.address; + TRACE("area = %" B_PRId32 ", size = %" B_PRIuSIZE ", virt = %p, phy = %" + B_PRIxPHYSADDR "\n", areaid, size, virtadr, pe.address); return areaid; } diff --git a/src/add-ons/kernel/drivers/dvb/cx23882/util.h b/src/add-ons/kernel/drivers/dvb/cx23882/util.h index 8df060ed7c..f6a25f01d1 100644 --- a/src/add-ons/kernel/drivers/dvb/cx23882/util.h +++ b/src/add-ons/kernel/drivers/dvb/cx23882/util.h @@ -27,8 +27,10 @@ #include -area_id map_mem(void **virt, void *phy, size_t size, uint32 protection, const char *name); -area_id alloc_mem(void **virt, void **phy, size_t size, uint32 protection, const char *name); +area_id map_mem(void **virt, phys_addr_t phy, size_t size, uint32 protection, + const char *name); +area_id alloc_mem(void **virt, phys_addr_t *phy, size_t size, uint32 protection, + const char *name); // generic macro for rounding, can only be used for power of 2 blocksize #define ROUNDUP(size, blocksize) (((size) + (blocksize) - 1) & ~((blocksize) - 1)) diff --git a/src/add-ons/kernel/drivers/graphics/intel_extreme/device.cpp b/src/add-ons/kernel/drivers/graphics/intel_extreme/device.cpp index 7b95058931..5aa448c08e 100644 --- a/src/add-ons/kernel/drivers/graphics/intel_extreme/device.cpp +++ b/src/add-ons/kernel/drivers/graphics/intel_extreme/device.cpp @@ -231,7 +231,7 @@ device_ioctl(void* data, uint32 op, void* buffer, size_t bufferLength) status_t status = intel_allocate_memory(*info, allocMemory.size, allocMemory.alignment, allocMemory.flags, - (addr_t* )&allocMemory.buffer_base); + &allocMemory.buffer_base); if (status == B_OK) { // copy result #ifdef __HAIKU__ diff --git a/src/add-ons/kernel/drivers/graphics/intel_extreme/driver.cpp b/src/add-ons/kernel/drivers/graphics/intel_extreme/driver.cpp index bfbd21302d..2fa2ff48fc 100644 --- a/src/add-ons/kernel/drivers/graphics/intel_extreme/driver.cpp +++ b/src/add-ons/kernel/drivers/graphics/intel_extreme/driver.cpp @@ -224,7 +224,7 @@ init_driver(void) gDeviceInfo[found]->init_status = B_NO_INIT; gDeviceInfo[found]->id = found; gDeviceInfo[found]->pci = info; - gDeviceInfo[found]->registers = (uint8*)info->u.h0.base_registers[0]; + gDeviceInfo[found]->registers = info->u.h0.base_registers[0]; gDeviceInfo[found]->device_identifier = kSupportedDevices[type].name; gDeviceInfo[found]->device_type = kSupportedDevices[type].type; diff --git a/src/add-ons/kernel/drivers/graphics/intel_extreme/intel_extreme.cpp b/src/add-ons/kernel/drivers/graphics/intel_extreme/intel_extreme.cpp index a6a8c81178..f4d4f7164a 100644 --- a/src/add-ons/kernel/drivers/graphics/intel_extreme/intel_extreme.cpp +++ b/src/add-ons/kernel/drivers/graphics/intel_extreme/intel_extreme.cpp @@ -239,7 +239,7 @@ intel_extreme_init(intel_info &info) AreaKeeper mmioMapper; info.registers_area = mmioMapper.Map("intel extreme mmio", - (void*)info.pci->u.h0.base_registers[mmioIndex], + info.pci->u.h0.base_registers[mmioIndex], info.pci->u.h0.base_register_sizes[mmioIndex], B_ANY_KERNEL_ADDRESS, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA, (void**)&info.registers); diff --git a/src/add-ons/kernel/drivers/graphics/intel_extreme/intel_extreme_private.h b/src/add-ons/kernel/drivers/graphics/intel_extreme/intel_extreme_private.h index 8df7837870..4735393620 100644 --- a/src/add-ons/kernel/drivers/graphics/intel_extreme/intel_extreme_private.h +++ b/src/add-ons/kernel/drivers/graphics/intel_extreme/intel_extreme_private.h @@ -25,7 +25,7 @@ struct intel_info { addr_t aperture_base; aperture_id aperture; - uint8* registers; + addr_t registers; area_id registers_area; struct intel_shared_info* shared_info; diff --git a/src/add-ons/kernel/drivers/graphics/radeon_hd/driver.cpp b/src/add-ons/kernel/drivers/graphics/radeon_hd/driver.cpp index ffb1ddcf46..beb03523be 100644 --- a/src/add-ons/kernel/drivers/graphics/radeon_hd/driver.cpp +++ b/src/add-ons/kernel/drivers/graphics/radeon_hd/driver.cpp @@ -436,7 +436,7 @@ init_driver(void) gDeviceInfo[found]->init_status = B_NO_INIT; gDeviceInfo[found]->id = found; gDeviceInfo[found]->pci = info; - gDeviceInfo[found]->registers = (uint8*)info->u.h0.base_registers[0]; + gDeviceInfo[found]->registers = info->u.h0.base_registers[0]; gDeviceInfo[found]->pciID = kSupportedDevices[type].pciID; gDeviceInfo[found]->deviceName = kSupportedDevices[type].deviceName; gDeviceInfo[found]->chipsetID = kSupportedDevices[type].chipsetID; diff --git a/src/add-ons/kernel/drivers/graphics/radeon_hd/radeon_hd.cpp b/src/add-ons/kernel/drivers/graphics/radeon_hd/radeon_hd.cpp index 1609f9c308..4d048920f0 100644 --- a/src/add-ons/kernel/drivers/graphics/radeon_hd/radeon_hd.cpp +++ b/src/add-ons/kernel/drivers/graphics/radeon_hd/radeon_hd.cpp @@ -592,7 +592,7 @@ radeon_hd_init(radeon_info &info) // *** Map Memory mapped IO AreaKeeper mmioMapper; info.registers_area = mmioMapper.Map("radeon hd mmio", - (void*)info.pci->u.h0.base_registers[PCI_BAR_MMIO], + info.pci->u.h0.base_registers[PCI_BAR_MMIO], info.pci->u.h0.base_register_sizes[PCI_BAR_MMIO], B_ANY_KERNEL_ADDRESS, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA, (void**)&info.registers); @@ -665,7 +665,7 @@ radeon_hd_init(radeon_info &info) // *** Framebuffer mapping AreaKeeper frambufferMapper; info.framebuffer_area = frambufferMapper.Map("radeon hd frame buffer", - (void*)info.pci->u.h0.base_registers[PCI_BAR_FB], + info.pci->u.h0.base_registers[PCI_BAR_FB], info.shared_info->frame_buffer_size * 1024, B_ANY_KERNEL_ADDRESS, B_READ_AREA | B_WRITE_AREA, (void**)&info.shared_info->frame_buffer); diff --git a/src/add-ons/kernel/drivers/graphics/radeon_hd/radeon_hd_private.h b/src/add-ons/kernel/drivers/graphics/radeon_hd/radeon_hd_private.h index 10135221e8..ad9d2edcb9 100644 --- a/src/add-ons/kernel/drivers/graphics/radeon_hd/radeon_hd_private.h +++ b/src/add-ons/kernel/drivers/graphics/radeon_hd/radeon_hd_private.h @@ -34,7 +34,7 @@ struct radeon_info { status_t init_status; int32 id; pci_info* pci; - uint8* registers; + addr_t registers; uint8* atom_buffer; // buffer for atombios diff --git a/src/add-ons/kernel/drivers/midi/usb_midi/usb_midi.cpp b/src/add-ons/kernel/drivers/midi/usb_midi/usb_midi.cpp index 51177adc16..eebaff2ede 100644 --- a/src/add-ons/kernel/drivers/midi/usb_midi/usb_midi.cpp +++ b/src/add-ons/kernel/drivers/midi/usb_midi/usb_midi.cpp @@ -94,7 +94,7 @@ create_device(const usb_device* dev, uint16 ifno) midiDevice->sem_lock = sem = create_sem(1, DRIVER_NAME "_lock"); if (sem < 0) { - DPRINTF_ERR((MY_ID "create_sem() failed 0x%lx\n", sem)); + DPRINTF_ERR((MY_ID "create_sem() failed 0x%" B_PRIx32 "\n", sem)); free(midiDevice); return NULL; } @@ -104,7 +104,7 @@ create_device(const usb_device* dev, uint16 ifno) (void**)&midiDevice->buffer, B_ANY_KERNEL_ADDRESS, B_PAGE_SIZE, B_CONTIGUOUS, B_READ_AREA | B_WRITE_AREA); if (area < 0) { - DPRINTF_ERR((MY_ID "create_area() failed 0x%lx\n", area)); + DPRINTF_ERR((MY_ID "create_area() failed 0x%" B_PRIx32 "\n", area)); delete_sem(midiDevice->sem_lock); free(midiDevice); return NULL; @@ -114,7 +114,7 @@ create_device(const usb_device* dev, uint16 ifno) (usb_midi_event_packet*)((uint8*)midiDevice->buffer + B_PAGE_SIZE / 2); midiDevice->sem_send = sem = create_sem(1, DRIVER_NAME "_send"); if (sem < 0) { - DPRINTF_ERR((MY_ID "create_sem() failed 0x%lx\n", sem)); + DPRINTF_ERR((MY_ID "create_sem() failed 0x%" B_PRIx32 "\n", sem)); delete_sem(midiDevice->sem_lock); delete_area(area); free(midiDevice); @@ -278,7 +278,7 @@ midi_usb_read_callback(void* cookie, status_t status, (usb_callback_func)midi_usb_read_callback, midiDevice); if (st != B_OK) { /* probably endpoint stall */ - DPRINTF_ERR((MY_ID "queue_bulk() error 0x%lx\n", st)); + DPRINTF_ERR((MY_ID "queue_bulk() error 0x%" B_PRIx32 "\n", st)); } } @@ -358,7 +358,8 @@ usb_midi_added(const usb_device* dev, void** cookie) got_one: if ((status = usb->set_configuration(dev, conf)) != B_OK) { - DPRINTF_ERR((MY_ID "set_configuration() failed 0x%lx\n", status)); + DPRINTF_ERR((MY_ID "set_configuration() failed 0x%" B_PRIx32 "\n", + status)); return B_ERROR; } @@ -430,7 +431,7 @@ got_one: midiDevice->inMaxPkt, (usb_callback_func)midi_usb_read_callback, midiDevice); if (status != B_OK) { - DPRINTF_ERR((MY_ID "queue_bulk() error 0x%lx\n", status)); + DPRINTF_ERR((MY_ID "queue_bulk() error 0x%" B_PRIx32 "\n", status)); return B_ERROR; } @@ -504,7 +505,8 @@ usb_midi_open(const char* name, uint32 flags, assert(name != NULL); assert(out_cookie != NULL); - DPRINTF_INFO((MY_ID "usb_midi_open(%s) flags=%lx\n", name, flags)); + DPRINTF_INFO((MY_ID "usb_midi_open(%s) flags=%" B_PRIx32 "\n", name, + flags)); if ((port = search_port_info(name)) == NULL) return B_ENTRY_NOT_FOUND; @@ -519,7 +521,8 @@ usb_midi_open(const char* name, uint32 flags, cookie->sem_cb = create_sem(0, DRIVER_NAME "_cb"); if (cookie->sem_cb < 0) { - DPRINTF_ERR((MY_ID "create_sem() failed 0x%lx\n", cookie->sem_cb)); + DPRINTF_ERR((MY_ID "create_sem() failed 0x%" B_PRIx32 "\n", + cookie->sem_cb)); free(cookie); return B_ERROR; } @@ -674,8 +677,8 @@ usb_midi_write(driver_cookie* cookie, off_t position, * packet_count, (usb_callback_func)midi_usb_write_callback, midiDevice); if (status != B_OK) { - DPRINTF_ERR((MY_ID "midi write queue_bulk() error 0x%lx\n", - status)); + DPRINTF_ERR((MY_ID "midi write queue_bulk() error 0x%" B_PRIx32 + "\n", status)); return B_ERROR; } } diff --git a/src/add-ons/kernel/drivers/network/usb_asix/ASIXDevice.cpp b/src/add-ons/kernel/drivers/network/usb_asix/ASIXDevice.cpp index 49cd5803d2..19eb3580bd 100644 --- a/src/add-ons/kernel/drivers/network/usb_asix/ASIXDevice.cpp +++ b/src/add-ons/kernel/drivers/network/usb_asix/ASIXDevice.cpp @@ -700,7 +700,7 @@ ASIXDevice::ModifyMulticastTable(bool join, ether_address_t* group) void ASIXDevice::_ReadCallback(void *cookie, int32 status, void *data, - uint32 actualLength) + size_t actualLength) { TRACE_FLOW("ReadCB: %d bytes; status:%#010x\n", actualLength, status); ASIXDevice *device = (ASIXDevice *)cookie; @@ -712,7 +712,7 @@ ASIXDevice::_ReadCallback(void *cookie, int32 status, void *data, void ASIXDevice::_WriteCallback(void *cookie, int32 status, void *data, - uint32 actualLength) + size_t actualLength) { TRACE_FLOW("WriteCB: %d bytes; status:%#010x\n", actualLength, status); ASIXDevice *device = (ASIXDevice *)cookie; @@ -724,7 +724,7 @@ ASIXDevice::_WriteCallback(void *cookie, int32 status, void *data, void ASIXDevice::_NotifyCallback(void *cookie, int32 status, void *data, - uint32 actualLength) + size_t actualLength) { ASIXDevice *device = (ASIXDevice *)cookie; atomic_add(&device->fInsideNotify, 1); diff --git a/src/add-ons/kernel/drivers/network/usb_asix/ASIXDevice.h b/src/add-ons/kernel/drivers/network/usb_asix/ASIXDevice.h index e932a377ab..0bccbbfb68 100644 --- a/src/add-ons/kernel/drivers/network/usb_asix/ASIXDevice.h +++ b/src/add-ons/kernel/drivers/network/usb_asix/ASIXDevice.h @@ -64,11 +64,11 @@ virtual status_t SetupDevice(bool deviceReplugged); private: static void _ReadCallback(void *cookie, int32 status, - void *data, uint32 actualLength); + void *data, size_t actualLength); static void _WriteCallback(void *cookie, int32 status, - void *data, uint32 actualLength); + void *data, size_t actualLength); static void _NotifyCallback(void *cookie, int32 status, - void *data, uint32 actualLength); + void *data, size_t actualLength); status_t _SetupEndpoints(); diff --git a/src/add-ons/kernel/drivers/network/usb_asix/Driver.cpp b/src/add-ons/kernel/drivers/network/usb_asix/Driver.cpp index e19f45ad6b..1a67009d7d 100644 --- a/src/add-ons/kernel/drivers/network/usb_asix/Driver.cpp +++ b/src/add-ons/kernel/drivers/network/usb_asix/Driver.cpp @@ -363,7 +363,8 @@ publish_devices() gDeviceNames[deviceCount] = (char *)malloc(strlen(sDeviceBaseName) + 4); if (gDeviceNames[deviceCount]) { - sprintf(gDeviceNames[deviceCount], "%s%ld", sDeviceBaseName, i); + sprintf(gDeviceNames[deviceCount], "%s%" B_PRId32, sDeviceBaseName, + i); TRACE("publishing %s\n", gDeviceNames[deviceCount]); deviceCount++; } else diff --git a/src/add-ons/kernel/drivers/network/usb_asix/Settings.cpp b/src/add-ons/kernel/drivers/network/usb_asix/Settings.cpp index 511ff1ad1e..5ac346e771 100644 --- a/src/add-ons/kernel/drivers/network/usb_asix/Settings.cpp +++ b/src/add-ons/kernel/drivers/network/usb_asix/Settings.cpp @@ -96,7 +96,8 @@ void usb_asix_trace(bool force, const char* func, const char *fmt, ...) bigtime_t time = system_time(); uint32 msec = time / 1000; uint32 sec = msec / 1000; - sprintf(buf_ptr, "%02ld.%02ld.%03ld:", sec / 60, sec % 60, msec % 1000); + sprintf(buf_ptr, "%02" B_PRId32 ".%02" B_PRId32 ".%03" B_PRId32 ":", + sec / 60, sec % 60, msec % 1000); buf_ptr += strlen(buf_ptr); } diff --git a/src/add-ons/kernel/drivers/network/usb_davicom/DavicomDevice.cpp b/src/add-ons/kernel/drivers/network/usb_davicom/DavicomDevice.cpp index 8cff098f32..9ceb5f987a 100644 --- a/src/add-ons/kernel/drivers/network/usb_davicom/DavicomDevice.cpp +++ b/src/add-ons/kernel/drivers/network/usb_davicom/DavicomDevice.cpp @@ -346,11 +346,12 @@ DavicomDevice::Write(const uint8 *buffer, size_t *numBytes) } struct _TXHeader { - uint countLow :8; - uint countHigh :8; + uint8 countLow; + uint8 countHigh; } __attribute__((__packed__)); - _TXHeader header = { length & 0xff, length >> 8 & 0xff }; + _TXHeader header = { (uint8)(length & 0xff), + (uint8)((length >> 8) & 0xff) }; uint8 padding = 0; @@ -821,7 +822,7 @@ DavicomDevice::_ModifyMulticastTable(bool join, ether_address_t *group) void DavicomDevice::_ReadCallback(void *cookie, int32 status, void *data, - uint32 actualLength) + size_t actualLength) { TRACE_RX("ReadCB: %d bytes; status:%#010x\n", actualLength, status); DavicomDevice *device = (DavicomDevice *)cookie; @@ -834,7 +835,7 @@ DavicomDevice::_ReadCallback(void *cookie, int32 status, void *data, void DavicomDevice::_WriteCallback(void *cookie, int32 status, void *data, - uint32 actualLength) + size_t actualLength) { TRACE_TX("WriteCB: %d bytes; status:%#010x\n", actualLength, status); DavicomDevice *device = (DavicomDevice *)cookie; @@ -847,7 +848,7 @@ DavicomDevice::_WriteCallback(void *cookie, int32 status, void *data, void DavicomDevice::_NotifyCallback(void *cookie, int32 status, void *data, - uint32 actualLength) + size_t actualLength) { DavicomDevice *device = (DavicomDevice *)cookie; atomic_add(&device->fInsideNotify, 1); @@ -1117,7 +1118,7 @@ DavicomDevice::_WriteMII(uint8 reg, uint16 data) } // put the value to data register - uint8 values[] = { data & 0xff, ( data >> 8 ) & 0xff }; + uint8 values[] = { (uint8)(data & 0xff), (uint8)((data >> 8) & 0xff) }; result = _WriteRegister(RegEPDRL, sizeof(uint16), values); if (result != B_OK) { TRACE_ALWAYS("Failed to put data %#x. Error:%#x\n", data, result); diff --git a/src/add-ons/kernel/drivers/network/usb_davicom/DavicomDevice.h b/src/add-ons/kernel/drivers/network/usb_davicom/DavicomDevice.h index 4d94f5fb75..af0ce0e0de 100644 --- a/src/add-ons/kernel/drivers/network/usb_davicom/DavicomDevice.h +++ b/src/add-ons/kernel/drivers/network/usb_davicom/DavicomDevice.h @@ -123,11 +123,11 @@ public: private: static void _ReadCallback(void *cookie, int32 status, - void *data, uint32 actualLength); + void *data, size_t actualLength); static void _WriteCallback(void *cookie, int32 status, - void *data, uint32 actualLength); + void *data, size_t actualLength); static void _NotifyCallback(void *cookie, int32 status, - void *data, uint32 actualLength); + void *data, size_t actualLength); status_t _SetupEndpoints(); diff --git a/src/add-ons/kernel/drivers/network/usb_davicom/Driver.cpp b/src/add-ons/kernel/drivers/network/usb_davicom/Driver.cpp index 1e85b40af7..cbbe356758 100644 --- a/src/add-ons/kernel/drivers/network/usb_davicom/Driver.cpp +++ b/src/add-ons/kernel/drivers/network/usb_davicom/Driver.cpp @@ -321,7 +321,7 @@ publish_devices() gDeviceNames[deviceCount] = (char *)malloc(strlen(sDeviceBaseName) + 4); if (gDeviceNames[deviceCount]) { - sprintf(gDeviceNames[deviceCount], "%s%ld", sDeviceBaseName, i); + sprintf(gDeviceNames[deviceCount], "%s%" B_PRId32, sDeviceBaseName, i); TRACE("publishing %s\n", gDeviceNames[deviceCount]); deviceCount++; } else diff --git a/src/add-ons/kernel/drivers/network/usb_davicom/Settings.cpp b/src/add-ons/kernel/drivers/network/usb_davicom/Settings.cpp index 3aaf213087..3e46e946e1 100644 --- a/src/add-ons/kernel/drivers/network/usb_davicom/Settings.cpp +++ b/src/add-ons/kernel/drivers/network/usb_davicom/Settings.cpp @@ -103,7 +103,7 @@ void usb_davicom_trace(bool force, const char* func, const char *fmt, ...) bigtime_t time = system_time(); uint32 msec = time / 1000; uint32 sec = msec / 1000; - sprintf(buf_ptr, "%02ld.%02ld.%03ld:", + sprintf(buf_ptr, "%02" B_PRId32 ".%02" B_PRId32 ".%03" B_PRId32 ":", sec / 60, sec % 60, msec % 1000); buf_ptr += strlen(buf_ptr); } diff --git a/src/add-ons/kernel/drivers/network/usb_ecm/Driver.cpp b/src/add-ons/kernel/drivers/network/usb_ecm/Driver.cpp index b56daf0bcb..ac25820d04 100644 --- a/src/add-ons/kernel/drivers/network/usb_ecm/Driver.cpp +++ b/src/add-ons/kernel/drivers/network/usb_ecm/Driver.cpp @@ -38,7 +38,7 @@ usb_ecm_device_added(usb_device device, void **cookie) if (gECMDevices[i]->CompareAndReattach(device) != B_OK) continue; - TRACE_ALWAYS("ecm device %ld replugged\n", i); + TRACE_ALWAYS("ecm device %" B_PRId32 " replugged\n", i); *cookie = gECMDevices[i]; mutex_unlock(&gDriverLock); return B_OK; @@ -60,7 +60,7 @@ usb_ecm_device_added(usb_device device, void **cookie) gECMDevices[i] = ecmDevice; *cookie = ecmDevice; - TRACE_ALWAYS("ecm device %ld added\n", i); + TRACE_ALWAYS("ecm device %" B_PRId32 " added\n", i); mutex_unlock(&gDriverLock); return B_OK; } @@ -258,7 +258,8 @@ publish_devices() gDeviceNames[deviceCount] = (char *)malloc(strlen(sDeviceBaseName) + 4); if (gDeviceNames[deviceCount]) { - sprintf(gDeviceNames[deviceCount], "%s%ld", sDeviceBaseName, i); + sprintf(gDeviceNames[deviceCount], "%s%" B_PRId32, sDeviceBaseName, + i); TRACE("publishing %s\n", gDeviceNames[deviceCount]); deviceCount++; } else diff --git a/src/add-ons/kernel/drivers/network/usb_ecm/ECMDevice.cpp b/src/add-ons/kernel/drivers/network/usb_ecm/ECMDevice.cpp index 04c7adaa11..f9f00928ed 100644 --- a/src/add-ons/kernel/drivers/network/usb_ecm/ECMDevice.cpp +++ b/src/add-ons/kernel/drivers/network/usb_ecm/ECMDevice.cpp @@ -195,7 +195,7 @@ ECMDevice::Read(uint8 *buffer, size_t *numBytes) } if (fStatusRead != B_OK && fStatusRead != B_CANCELED && !fRemoved) { - TRACE_ALWAYS("device status error 0x%08lx\n", fStatusRead); + TRACE_ALWAYS("device status error 0x%08" B_PRIx32 "\n", fStatusRead); result = gUSBModule->clear_feature(fReadEndpoint, USB_FEATURE_ENDPOINT_HALT); if (result != B_OK) { @@ -232,7 +232,7 @@ ECMDevice::Write(const uint8 *buffer, size_t *numBytes) } if (fStatusWrite != B_OK && fStatusWrite != B_CANCELED && !fRemoved) { - TRACE_ALWAYS("device status error 0x%08lx\n", fStatusWrite); + TRACE_ALWAYS("device status error 0x%08" B_PRIx32 "\n", fStatusWrite); result = gUSBModule->clear_feature(fWriteEndpoint, USB_FEATURE_ENDPOINT_HALT); if (result != B_OK) { @@ -279,7 +279,7 @@ ECMDevice::Control(uint32 op, void *buffer, size_t length) #endif default: - TRACE_ALWAYS("unsupported ioctl %lu\n", op); + TRACE_ALWAYS("unsupported ioctl %" B_PRIu32 "\n", op); } return B_DEV_INVALID_IOCTL; @@ -506,7 +506,7 @@ ECMDevice::_ReadMACAddress(usb_device device, uint8 *buffer) void ECMDevice::_ReadCallback(void *cookie, int32 status, void *data, - uint32 actualLength) + size_t actualLength) { ECMDevice *device = (ECMDevice *)cookie; device->fActualLengthRead = actualLength; @@ -517,7 +517,7 @@ ECMDevice::_ReadCallback(void *cookie, int32 status, void *data, void ECMDevice::_WriteCallback(void *cookie, int32 status, void *data, - uint32 actualLength) + size_t actualLength) { ECMDevice *device = (ECMDevice *)cookie; device->fActualLengthWrite = actualLength; @@ -528,7 +528,7 @@ ECMDevice::_WriteCallback(void *cookie, int32 status, void *data, void ECMDevice::_NotifyCallback(void *cookie, int32 status, void *data, - uint32 actualLength) + size_t actualLength) { ECMDevice *device = (ECMDevice *)cookie; atomic_add(&device->fInsideNotify, 1); @@ -580,7 +580,7 @@ ECMDevice::_NotifyCallback(void *cookie, int32 status, void *data, } if (status != B_OK) { - TRACE_ALWAYS("device status error 0x%08lx\n", status); + TRACE_ALWAYS("device status error 0x%08" B_PRIx32 "\n", status); if (gUSBModule->clear_feature(device->fNotifyEndpoint, USB_FEATURE_ENDPOINT_HALT) != B_OK) TRACE_ALWAYS("failed to clear halt state in notify hook\n"); diff --git a/src/add-ons/kernel/drivers/network/usb_ecm/ECMDevice.h b/src/add-ons/kernel/drivers/network/usb_ecm/ECMDevice.h index 3a6801a4ea..2cc5b266d0 100644 --- a/src/add-ons/kernel/drivers/network/usb_ecm/ECMDevice.h +++ b/src/add-ons/kernel/drivers/network/usb_ecm/ECMDevice.h @@ -32,11 +32,11 @@ public: private: static void _ReadCallback(void *cookie, int32 status, - void *data, uint32 actualLength); + void *data, size_t actualLength); static void _WriteCallback(void *cookie, int32 status, - void *data, uint32 actualLength); + void *data, size_t actualLength); static void _NotifyCallback(void *cookie, int32 status, - void *data, uint32 actualLength); + void *data, size_t actualLength); status_t _SetupDevice(); status_t _ReadMACAddress(usb_device device, uint8 *buffer); diff --git a/src/add-ons/kernel/drivers/ports/usb_serial/Driver.cpp b/src/add-ons/kernel/drivers/ports/usb_serial/Driver.cpp index 77f9f74643..fb88813c9e 100644 --- a/src/add-ons/kernel/drivers/ports/usb_serial/Driver.cpp +++ b/src/add-ons/kernel/drivers/ports/usb_serial/Driver.cpp @@ -351,7 +351,7 @@ publish_devices() if (gSerialDevices[i]) { gDeviceNames[j] = (char *)malloc(strlen(sDeviceBaseName) + 4); if (gDeviceNames[j]) { - sprintf(gDeviceNames[j], "%s%ld", sDeviceBaseName, i); + sprintf(gDeviceNames[j], "%s%" B_PRId32, sDeviceBaseName, i); j++; } else TRACE_ALWAYS("publish_devices - no memory to allocate device names\n"); diff --git a/src/add-ons/kernel/drivers/ports/usb_serial/SerialDevice.cpp b/src/add-ons/kernel/drivers/ports/usb_serial/SerialDevice.cpp index e8bb192c35..4af8c16a30 100644 --- a/src/add-ons/kernel/drivers/ports/usb_serial/SerialDevice.cpp +++ b/src/add-ons/kernel/drivers/ports/usb_serial/SerialDevice.cpp @@ -669,7 +669,7 @@ SerialDevice::_WriteToDevice() void SerialDevice::_ReadCallbackFunction(void *cookie, status_t status, void *data, - uint32 actualLength) + size_t actualLength) { TRACE_FUNCALLS("read callback: cookie: 0x%08x status: 0x%08x data: 0x%08x " "length: %lu\n", cookie, status, data, actualLength); @@ -683,7 +683,7 @@ SerialDevice::_ReadCallbackFunction(void *cookie, status_t status, void *data, void SerialDevice::_WriteCallbackFunction(void *cookie, status_t status, void *data, - uint32 actualLength) + size_t actualLength) { TRACE_FUNCALLS("write callback: cookie: 0x%08x status: 0x%08x data: 0x%08x " "length: %lu\n", cookie, status, data, actualLength); @@ -697,7 +697,7 @@ SerialDevice::_WriteCallbackFunction(void *cookie, status_t status, void *data, void SerialDevice::_InterruptCallbackFunction(void *cookie, status_t status, - void *data, uint32 actualLength) + void *data, size_t actualLength) { TRACE_FUNCALLS("interrupt callback: cookie: 0x%08x status: 0x%08x data: " "0x%08x len: %lu\n", cookie, status, data, actualLength); diff --git a/src/add-ons/kernel/drivers/ports/usb_serial/SerialDevice.h b/src/add-ons/kernel/drivers/ports/usb_serial/SerialDevice.h index 57afc10cb7..213e2556d8 100644 --- a/src/add-ons/kernel/drivers/ports/usb_serial/SerialDevice.h +++ b/src/add-ons/kernel/drivers/ports/usb_serial/SerialDevice.h @@ -95,13 +95,13 @@ static int32 _InputThread(void *data); static void _ReadCallbackFunction(void *cookie, int32 status, void *data, - uint32 actualLength); + size_t actualLength); static void _WriteCallbackFunction(void *cookie, int32 status, void *data, - uint32 actualLength); + size_t actualLength); static void _InterruptCallbackFunction(void *cookie, int32 status, void *data, - uint32 actualLength); + size_t actualLength); usb_device fDevice; // USB device handle uint16 fVendorID; diff --git a/src/add-ons/kernel/drivers/printer/usb/usb_printer.cpp b/src/add-ons/kernel/drivers/printer/usb/usb_printer.cpp index be475d884e..c690db3339 100644 --- a/src/add-ons/kernel/drivers/printer/usb/usb_printer.cpp +++ b/src/add-ons/kernel/drivers/printer/usb/usb_printer.cpp @@ -18,7 +18,7 @@ #define DRIVER_NAME "usb_printer" #define DEVICE_NAME_BASE "printer/usb/" -#define DEVICE_NAME DEVICE_NAME_BASE"%ld" +#define DEVICE_NAME DEVICE_NAME_BASE "%" B_PRId32 #define SECONDS ((bigtime_t)1000 * 1000) #define MINUTES (60 * SECONDS) @@ -142,7 +142,7 @@ usb_printer_callback(void *cookie, status_t status, void *data, static status_t usb_printer_device_added(usb_device newDevice, void **cookie) { - TRACE("device_added(0x%08lx)\n", newDevice); + TRACE("device_added(0x%08" B_PRIx32 ")\n", newDevice); printer_device *device = (printer_device *)malloc(sizeof(printer_device)); device->device = newDevice; device->removed = false; @@ -261,7 +261,7 @@ usb_printer_device_added(usb_device newDevice, void **cookie) sprintf(device->name, DEVICE_NAME, deviceNumber); mutex_unlock(&gDeviceListLock); - TRACE("new device: 0x%08lx\n", (uint32)device); + TRACE("new device: 0x%p\n", device); *cookie = (void *)device; return B_OK; } @@ -270,7 +270,7 @@ usb_printer_device_added(usb_device newDevice, void **cookie) static status_t usb_printer_device_removed(void *cookie) { - TRACE("device_removed(0x%08lx)\n", (uint32)cookie); + TRACE("device_removed(0x%p)\n", cookie); printer_device *device = (printer_device *)cookie; mutex_lock(&gDeviceListLock); @@ -412,7 +412,7 @@ usb_printer_ioctl(void *cookie, uint32 op, void *buffer, size_t length) } default: - TRACE_ALWAYS("unhandled ioctl %ld\n", op); + TRACE_ALWAYS("unhandled ioctl %" B_PRIu32 "\n", op); break; } @@ -459,7 +459,7 @@ usb_printer_read(void *cookie, off_t position, void *buffer, size_t *length) if (buffer == NULL || length == NULL) return B_BAD_VALUE; - TRACE("read(%lld, %ld)\n", position, *length); + TRACE("read(%" B_PRIdOFF ", %" B_PRIuSIZE ")\n", position, *length); printer_device *device = (printer_device *)cookie; mutex_lock(&device->lock); if (device->removed) { @@ -472,12 +472,12 @@ usb_printer_read(void *cookie, off_t position, void *buffer, size_t *length) mutex_unlock(&device->lock); if (result == B_OK) { - TRACE("read successful with %ld bytes\n", *length); + TRACE("read successful with %" B_PRIuSIZE " bytes\n", *length); return B_OK; } *length = 0; - TRACE_ALWAYS("read fails with 0x%08lx\n", result); + TRACE_ALWAYS("read fails with 0x%08" B_PRIx32 "\n", result); return result; } @@ -489,7 +489,7 @@ usb_printer_write(void *cookie, off_t position, const void *buffer, if (buffer == NULL || length == NULL) return B_BAD_VALUE; - TRACE("write(%lld, %ld)\n", position, *length); + TRACE("write(%" B_PRIdOFF ", %" B_PRIuSIZE ")\n", position, *length); printer_device *device = (printer_device *)cookie; mutex_lock(&device->lock); if (device->removed) { @@ -503,12 +503,12 @@ usb_printer_write(void *cookie, off_t position, const void *buffer, mutex_unlock(&device->lock); if (result == B_OK) { - TRACE("write successful with %ld bytes\n", *length); + TRACE("write successful with %" B_PRIuSIZE " bytes\n", *length); return B_OK; } *length = 0; - TRACE_ALWAYS("write fails with 0x%08lx\n", result); + TRACE_ALWAYS("write fails with 0x%08" B_PRIx32 "\n", result); return result; } @@ -551,7 +551,7 @@ init_driver() status_t result = get_module(B_USB_MODULE_NAME, (module_info **)&gUSBModule); if (result < B_OK) { - TRACE_ALWAYS("getting module failed 0x%08lx\n", result); + TRACE_ALWAYS("getting module failed 0x%08" B_PRIx32 "\n", result); mutex_destroy(&gDeviceListLock); return result; } diff --git a/src/add-ons/kernel/file_systems/bfs/Inode.cpp b/src/add-ons/kernel/file_systems/bfs/Inode.cpp index c5e92c2949..d33970a614 100644 --- a/src/add-ons/kernel/file_systems/bfs/Inode.cpp +++ b/src/add-ons/kernel/file_systems/bfs/Inode.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2012, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2001-2013, Axel Dörfler, axeld@pinc-software.de. * This file may be used under the terms of the MIT License. */ @@ -206,7 +206,8 @@ InodeAllocator::New(block_run* parentRun, mode_t mode, block_run& run, } run = fRun; - fInode = new Inode(volume, *fTransaction, volume->ToVnode(run), mode, run); + fInode = new(std::nothrow) Inode(volume, *fTransaction, + volume->ToVnode(run), mode, run); if (fInode == NULL) RETURN_ERROR(B_NO_MEMORY); @@ -235,7 +236,8 @@ InodeAllocator::CreateTree() if ((fInode->Mode() & S_INDEX_TYPES) == 0) fInode->Node().mode |= HOST_ENDIAN_TO_BFS_INT32(S_STR_INDEX); - BPlusTree* tree = fInode->fTree = new BPlusTree(*fTransaction, fInode); + BPlusTree* tree = fInode->fTree + = new(std::nothrow) BPlusTree(*fTransaction, fInode); if (tree == NULL || tree->InitCheck() < B_OK) return B_ERROR; @@ -347,7 +349,7 @@ Inode::Inode(Volume* volume, ino_t id) fOldLastModified = LastModified(); if (IsContainer()) - fTree = new BPlusTree(this); + fTree = new(std::nothrow) BPlusTree(this); if (NeedsFileCache()) { SetFileCache(file_cache_create(fVolume->ID(), ID(), Size())); SetMap(file_map_create(volume->ID(), ID(), Size())); @@ -2881,7 +2883,7 @@ AttributeIterator::GetNext(char* name, size_t* _length, uint32* _type, BPlusTree* tree = fAttributes->Tree(); if (tree == NULL - || (fIterator = new TreeIterator(tree)) == NULL) { + || (fIterator = new(std::nothrow) TreeIterator(tree)) == NULL) { FATAL(("could not get tree in AttributeIterator::GetNext(ino_t" " = %" B_PRIdINO ",name = \"%s\")\n", fInode->ID(), name)); return B_ENTRY_NOT_FOUND; @@ -2892,7 +2894,7 @@ AttributeIterator::GetNext(char* name, size_t* _length, uint32* _type, ino_t id; status_t status = fIterator->GetNextEntry(name, &length, B_FILE_NAME_LENGTH, &id); - if (status < B_OK) + if (status != B_OK) return status; Vnode vnode(volume, id); diff --git a/src/add-ons/kernel/file_systems/bfs/Journal.cpp b/src/add-ons/kernel/file_systems/bfs/Journal.cpp index fa62b52afe..bac5a4342a 100644 --- a/src/add-ons/kernel/file_systems/bfs/Journal.cpp +++ b/src/add-ons/kernel/file_systems/bfs/Journal.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2010, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2001-2013, Axel Dörfler, axeld@pinc-software.de. * This file may be used under the terms of the MIT License. */ @@ -853,7 +853,7 @@ Journal::_WriteTransactionToLog() free(vecs); - LogEntry* logEntry = new LogEntry(this, fVolume->LogEnd(), + LogEntry* logEntry = new(std::nothrow) LogEntry(this, fVolume->LogEnd(), runArrays.LogEntryLength()); if (logEntry == NULL) { FATAL(("no memory to allocate log entries!")); diff --git a/src/add-ons/kernel/file_systems/bfs/Query.cpp b/src/add-ons/kernel/file_systems/bfs/Query.cpp index d6f213cd14..a5e593af34 100644 --- a/src/add-ons/kernel/file_systems/bfs/Query.cpp +++ b/src/add-ons/kernel/file_systems/bfs/Query.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2009, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2001-2013, Axel Dörfler, axeld@pinc-software.de. * Copyright 2010, Clemens Zeidler * This file may be used under the terms of the MIT License. */ @@ -971,7 +971,7 @@ Equation::PrepareQuery(Volume* /*volume*/, Index& index, if (tree == NULL) return B_ERROR; - *iterator = new TreeIterator(tree); + *iterator = new(std::nothrow) TreeIterator(tree); if (*iterator == NULL) return B_NO_MEMORY; @@ -1249,11 +1249,11 @@ Term* Operator::Copy() const { if (fEquation != NULL) { - Equation* equation = new Equation(*fEquation); + Equation* equation = new(std::nothrow) Equation(*fEquation); if (equation == NULL) return NULL; - Term* term = new Term(equation); + Term* term = new(std::nothrow) Term(equation); if (term == NULL) delete equation; @@ -1270,7 +1270,7 @@ Operator::Copy() const return NULL; } - Term* term = new Term(left, fOp, right); + Term* term = new(std::nothrow) Term(left, fOp, right); if (term == NULL) { delete left; delete right; @@ -1393,7 +1393,7 @@ Expression::ParseEquation(char** expr) return term; } - Equation* equation = new Equation(expr); + Equation* equation = new(std::nothrow) Equation(expr); if (equation == NULL || equation->InitCheck() < B_OK) { delete equation; return NULL; @@ -1413,8 +1413,8 @@ Expression::ParseAnd(char** expr) Term* right = ParseAnd(expr); Term* newParent = NULL; - if (right == NULL - || (newParent = new Operator(left, OP_AND, right)) == NULL) { + if (right == NULL || (newParent = new(std::nothrow) Operator(left, + OP_AND, right)) == NULL) { delete left; delete right; @@ -1438,8 +1438,8 @@ Expression::ParseOr(char** expr) Term* right = ParseAnd(expr); Term* newParent = NULL; - if (right == NULL - || (newParent = new Operator(left, OP_OR, right)) == NULL) { + if (right == NULL || (newParent = new(std::nothrow) Operator(left, + OP_OR, right)) == NULL) { delete left; delete right; diff --git a/src/add-ons/kernel/file_systems/bfs/system_dependencies.h b/src/add-ons/kernel/file_systems/bfs/system_dependencies.h index 6e8989670a..aa0773d1aa 100644 --- a/src/add-ons/kernel/file_systems/bfs/system_dependencies.h +++ b/src/add-ons/kernel/file_systems/bfs/system_dependencies.h @@ -18,7 +18,6 @@ #include #include #include -#include #include #include diff --git a/src/add-ons/kernel/file_systems/btrfs/Attribute.cpp b/src/add-ons/kernel/file_systems/btrfs/Attribute.cpp index abc0fc51f0..d6be6d3fcb 100644 --- a/src/add-ons/kernel/file_systems/btrfs/Attribute.cpp +++ b/src/add-ons/kernel/file_systems/btrfs/Attribute.cpp @@ -162,8 +162,8 @@ Attribute::_Lookup(const char* name, size_t nameLength, status_t status = fInode->GetVolume()->FSTree()->FindExact(key, (void**)&entries, &length); if (status != B_OK) { - TRACE("AttributeIterator::Lookup(): Couldn't find entry with hash %lu " - "\"%s\"\n", hash, name); + TRACE("AttributeIterator::Lookup(): Couldn't find entry with hash %" + B_PRIu32 " \"%s\"\n", hash, name); return status; } diff --git a/src/add-ons/kernel/file_systems/btrfs/BPlusTree.cpp b/src/add-ons/kernel/file_systems/btrfs/BPlusTree.cpp index 04609624af..0f1bf0115d 100644 --- a/src/add-ons/kernel/file_systems/btrfs/BPlusTree.cpp +++ b/src/add-ons/kernel/file_systems/btrfs/BPlusTree.cpp @@ -89,14 +89,14 @@ status_t BPlusTree::_Find(struct btrfs_key &key, void** _value, size_t* _size, bplustree_traversing type) { - TRACE("Find() objectid %lld type %d offset %lld \n", key.ObjectID(), - key.Type(), key.Offset()); + TRACE("Find() objectid %" B_PRId64 " type %d offset %" B_PRId64 " \n", + key.ObjectID(), key.Type(), key.Offset()); btrfs_stream *stream = fStream; CachedBlock cached(fVolume); fsblock_t physical; if (stream == NULL) { if (fVolume->FindBlock(fRootBlock, physical) != B_OK) { - ERROR("Find() unmapped block %lld\n", fRootBlock); + ERROR("Find() unmapped block %" B_PRId64 "\n", fRootBlock); return B_ERROR; } stream = (btrfs_stream *)cached.SetTo(physical); @@ -107,19 +107,19 @@ BPlusTree::_Find(struct btrfs_key &key, void** _value, size_t* _size, uint32 i = 1; for (; i < stream->header.ItemCount(); i++) { int32 comp = _CompareKeys(stream->index[i].key, key); - TRACE("Find() found index %ld at %lld comp %ld\n", i, - stream->index[i].BlockNum(), comp); + TRACE("Find() found index %" B_PRIu32 " at %" B_PRId64 " comp %" + B_PRId32 "\n", i, stream->index[i].BlockNum(), comp); if (comp < 0) continue; if (comp > 0 || type == BPLUSTREE_BACKWARD) break; } - TRACE("Find() getting index %ld at %lld\n", i - 1, + TRACE("Find() getting index %" B_PRIu32 " at %" B_PRId64 "\n", i - 1, stream->index[i - 1].BlockNum()); if (fVolume->FindBlock(stream->index[i - 1].BlockNum(), physical) != B_OK) { - ERROR("Find() unmapped block %lld\n", + ERROR("Find() unmapped block %" B_PRId64 "\n", stream->index[i - 1].BlockNum()); return B_ERROR; } @@ -128,18 +128,19 @@ BPlusTree::_Find(struct btrfs_key &key, void** _value, size_t* _size, uint32 i; #ifdef TRACE_BTRFS - TRACE("Find() dump count %ld\n", stream->header.ItemCount()); + TRACE("Find() dump count %" B_PRId32 "\n", stream->header.ItemCount()); for (i = 0; i < stream->header.ItemCount(); i++) { int32 comp = _CompareKeys(key, stream->entries[i].key); - TRACE("Find() dump %ld %ld offset %lld comp %ld\n", - stream->entries[i].Offset(), + TRACE("Find() dump %" B_PRIu32 " %" B_PRIu32 " offset %" B_PRId64 + " comp %" B_PRId32 "\n", stream->entries[i].Offset(), stream->entries[i].Size(), stream->entries[i].key.Offset(), comp); } #endif for (i = 0; i < stream->header.ItemCount(); i++) { int32 comp = _CompareKeys(key, stream->entries[i].key); - TRACE("Find() found %ld %ld oid %lld type %d offset %lld comp %ld\n", + TRACE("Find() found %" B_PRIu32 " %" B_PRIu32 " oid %" B_PRId64 + " type %d offset %" B_PRId64 " comp %" B_PRId32 "\n", stream->entries[i].Offset(), stream->entries[i].Size(), stream->entries[i].key.ObjectID(), stream->entries[i].key.Type(), stream->entries[i].key.Offset(), comp); @@ -163,8 +164,8 @@ BPlusTree::_Find(struct btrfs_key &key, void** _value, size_t* _size, if (i < stream->header.ItemCount() && stream->entries[i].key.Type() == key.Type()) { - TRACE("Find() found %ld %ld\n", stream->entries[i].Offset(), - stream->entries[i].Size()); + TRACE("Find() found %" B_PRIu32 " %" B_PRIu32 "\n", + stream->entries[i].Offset(), stream->entries[i].Size()); if (_value != NULL) { *_value = malloc(stream->entries[i].Size()); memcpy(*_value, ((uint8 *)&stream->entries[0] @@ -178,7 +179,8 @@ BPlusTree::_Find(struct btrfs_key &key, void** _value, size_t* _size, } - TRACE("Find() not found %lld %lld\n", key.Offset(), key.ObjectID()); + TRACE("Find() not found %" B_PRId64 " %" B_PRId64 "\n", key.Offset(), + key.ObjectID()); return B_ENTRY_NOT_FOUND; } diff --git a/src/add-ons/kernel/file_systems/btrfs/Chunk.cpp b/src/add-ons/kernel/file_systems/btrfs/Chunk.cpp index d9b39e21a7..95d82a4b5b 100644 --- a/src/add-ons/kernel/file_systems/btrfs/Chunk.cpp +++ b/src/add-ons/kernel/file_systems/btrfs/Chunk.cpp @@ -35,13 +35,15 @@ Chunk::Chunk(struct btrfs_chunk* chunk, fsblock_t offset) memcpy(fChunk, chunk, sizeof(struct btrfs_chunk) + chunk->StripeCount() * sizeof(struct btrfs_stripe)); - TRACE("chunk[0] length %llu owner %llu stripe_length %llu type %llu " - "stripe_count %u sub_stripes %u sector_size %lu\n", chunk->Length(), - chunk->Owner(), chunk->StripeLength(), chunk->Type(), - chunk->StripeCount(), chunk->SubStripes(), chunk->SectorSize()); + TRACE("chunk[0] length %" B_PRIu64 " owner %" B_PRIu64 " stripe_length %" + B_PRIu64 " type %" B_PRIu64 " stripe_count %u sub_stripes %u " + "sector_size %" B_PRIu32 "\n", chunk->Length(), chunk->Owner(), + chunk->StripeLength(), chunk->Type(), chunk->StripeCount(), + chunk->SubStripes(), chunk->SectorSize()); for(int32 i = 0; i < chunk->StripeCount(); i++) { - TRACE("chunk.stripe[%ld].physical %lld deviceid %lld\n", i, - chunk->stripes[i].Offset(), chunk->stripes[i].DeviceID()); + TRACE("chunk.stripe[%" B_PRId32 "].physical %" B_PRId64 " deviceid %" + B_PRId64 "\n", i, chunk->stripes[i].Offset(), + chunk->stripes[i].DeviceID()); } } @@ -66,8 +68,8 @@ Chunk::FindBlock(off_t logical, off_t &physical) if (fChunk == NULL) return B_NO_INIT; - if (logical < fChunkOffset - || logical > (fChunkOffset + fChunk->Length())) + if (logical < (off_t)fChunkOffset + || logical > (off_t)(fChunkOffset + fChunk->Length())) return B_BAD_VALUE; // only one stripe diff --git a/src/add-ons/kernel/file_systems/btrfs/DirectoryIterator.cpp b/src/add-ons/kernel/file_systems/btrfs/DirectoryIterator.cpp index 6ea65249bd..01eb9884eb 100644 --- a/src/add-ons/kernel/file_systems/btrfs/DirectoryIterator.cpp +++ b/src/add-ons/kernel/file_systems/btrfs/DirectoryIterator.cpp @@ -132,8 +132,8 @@ DirectoryIterator::Lookup(const char* name, size_t nameLength, ino_t* _id) status_t status = fInode->GetVolume()->FSTree()->FindExact(key, (void**)&entries, &length); if (status != B_OK) { - TRACE("DirectoryIterator::Lookup(): Couldn't find entry with hash %lu " - "\"%s\"\n", hash, name); + TRACE("DirectoryIterator::Lookup(): Couldn't find entry with hash %" B_PRIu32 + " \"%s\"\n", hash, name); return status; } diff --git a/src/add-ons/kernel/file_systems/btrfs/Inode.cpp b/src/add-ons/kernel/file_systems/btrfs/Inode.cpp index 6c231f0160..757353f2a0 100644 --- a/src/add-ons/kernel/file_systems/btrfs/Inode.cpp +++ b/src/add-ons/kernel/file_systems/btrfs/Inode.cpp @@ -133,7 +133,6 @@ Inode::CheckPermissions(int accessMode) const } return (accessMode & ~permissions) == 0 ? B_OK : B_NOT_ALLOWED; - return B_OK; } @@ -149,12 +148,13 @@ Inode::FindBlock(off_t pos, off_t& physical, off_t *_length) status_t status = fVolume->FSTree()->FindPrevious(search_key, (void**)&extent_data); if (status != B_OK) { - ERROR("Inode::FindBlock(): Couldn't find extent_data 0x%lx\n", status); + ERROR("Inode::FindBlock(): Couldn't find extent_data 0x%" B_PRIx32 + "\n", status); return status; } - TRACE("Inode::FindBlock(%" B_PRIdINO ") key.Offset() %lld\n", ID(), - search_key.Offset()); + TRACE("Inode::FindBlock(%" B_PRIdINO ") key.Offset() %" B_PRId64 "\n", + ID(), search_key.Offset()); off_t diff = pos - search_key.Offset(); off_t logical = 0; @@ -165,8 +165,8 @@ Inode::FindBlock(off_t pos, off_t& physical, off_t *_length) status = fVolume->FindBlock(logical, physical); if (_length != NULL) *_length = extent_data->Size() - diff; - TRACE("Inode::FindBlock(%" B_PRIdINO ") %lld physical %lld\n", ID(), - pos, physical); + TRACE("Inode::FindBlock(%" B_PRIdINO ") %" B_PRIdOFF " physical %" + B_PRIdOFF "\n", ID(), pos, physical); free(extent_data); return status; @@ -180,14 +180,14 @@ Inode::ReadAt(off_t pos, uint8* buffer, size_t* _length) // set/check boundaries for pos/length if (pos < 0) { - ERROR("inode %" B_PRIdINO ": ReadAt failed(pos %lld, length %lu)\n", - ID(), pos, length); + ERROR("inode %" B_PRIdINO ": ReadAt failed(pos %" B_PRIdOFF + ", length %lu)\n", ID(), pos, length); return B_BAD_VALUE; } if (pos >= Size() || length == 0) { - TRACE("inode %" B_PRIdINO ": ReadAt 0 (pos %lld, length %lu)\n", - ID(), pos, length); + TRACE("inode %" B_PRIdINO ": ReadAt 0 (pos %" B_PRIdOFF + ", length %lu)\n", ID(), pos, length); *_length = 0; return B_NO_ERROR; } @@ -204,14 +204,15 @@ Inode::ReadAt(off_t pos, uint8* buffer, size_t* _length) status_t status = fVolume->FSTree()->FindPrevious(search_key, (void**)&extent_data, &item_size); if (status != B_OK) { - ERROR("Inode::FindBlock(): Couldn't find extent_data 0x%lx\n", status); + ERROR("Inode::FindBlock(): Couldn't find extent_data 0x%" B_PRIx32 + "\n", status); return status; } uint8 compression = extent_data->Compression(); if (FileCache() != NULL && extent_data->Type() == BTRFS_EXTENT_DATA_REGULAR) { - TRACE("inode %" B_PRIdINO ": ReadAt cache (pos %lld, length %lu)\n", + TRACE("inode %" B_PRIdINO ": ReadAt cache (pos %" B_PRIdOFF ", length %lu)\n", ID(), pos, length); free(extent_data); if (compression == BTRFS_EXTENT_COMPRESS_NONE) @@ -222,7 +223,7 @@ Inode::ReadAt(off_t pos, uint8* buffer, size_t* _length) panic("unknown extent compression; %d\n", compression); } - TRACE("Inode::ReadAt(%" B_PRIdINO ") key.Offset() %lld\n", ID(), + TRACE("Inode::ReadAt(%" B_PRIdINO ") key.Offset() %" B_PRId64 "\n", ID(), search_key.Offset()); off_t diff = pos - search_key.Offset(); @@ -256,8 +257,8 @@ Inode::ReadAt(off_t pos, uint8* buffer, size_t* _length) size_t inline_size = item_size - 13; bool headerRead = false; - TRACE("Inode::ReadAt(%" B_PRIdINO ") diff %lld size %ld\n", ID(), - diff, item_size); + TRACE("Inode::ReadAt(%" B_PRIdINO ") diff %" B_PRIdOFF " size %" + B_PRIuSIZE "\n", ID(), diff, item_size); do { ssize_t bytesRead = min_c(sizeof(in), inline_size - offset); diff --git a/src/add-ons/kernel/file_systems/btrfs/Volume.cpp b/src/add-ons/kernel/file_systems/btrfs/Volume.cpp index 0afac4c96f..5b994474d1 100644 --- a/src/add-ons/kernel/file_systems/btrfs/Volume.cpp +++ b/src/add-ons/kernel/file_systems/btrfs/Volume.cpp @@ -278,14 +278,15 @@ Volume::Mount(const char* deviceName, uint32 flags) } fBlockSize = fSuperBlock.BlockSize(); - TRACE("block size %ld\n", fBlockSize); + TRACE("block size %" B_PRIu32 "\n", fBlockSize); uint8* start = (uint8*)&fSuperBlock.system_chunk_array[0]; uint8* end = (uint8*)&fSuperBlock.system_chunk_array[2048]; while (start < end) { struct btrfs_key* key = (struct btrfs_key*)start; - TRACE("system_chunk_array object_id 0x%llx offset 0x%llx type 0x%x\n", - key->ObjectID(), key->Offset(), key->Type()); + TRACE("system_chunk_array object_id 0x%" B_PRIx64 " offset 0x%" + B_PRIx64 " type 0x%x\n", key->ObjectID(), key->Offset(), + key->Type()); if (key->Type() != BTRFS_KEY_TYPE_CHUNK_ITEM) { break; } @@ -297,16 +298,17 @@ Volume::Mount(const char* deviceName, uint32 flags) start += sizeof(struct btrfs_key) + fChunk->Size(); } - TRACE("Volume::Mount() generation: %lld\n", fSuperBlock.Generation()); + TRACE("Volume::Mount() generation: %" B_PRIu64 "\n", + fSuperBlock.Generation()); fsblock_t physical = 0; FindBlock(fSuperBlock.Root(), physical); - TRACE("Volume::Mount() root: %lld (physical %lld)\n", + TRACE("Volume::Mount() root: %" B_PRIu64 " (physical %" B_PRIu64 ")\n", fSuperBlock.Root(), physical); FindBlock(fSuperBlock.ChunkRoot(), physical); - TRACE("Volume::Mount() chunk_root: %lld (physical %lld)\n", - fSuperBlock.ChunkRoot(), physical); + TRACE("Volume::Mount() chunk_root: %" B_PRIu64 " (physical %" B_PRIu64 + ")\n", fSuperBlock.ChunkRoot(), physical); FindBlock(fSuperBlock.LogRoot(), physical); - TRACE("Volume::Mount() log_root: %lld (physical %lld)\n", + TRACE("Volume::Mount() log_root: %" B_PRIu64 " (physical %" B_PRIu64 ")\n", fSuperBlock.LogRoot(), physical); // check if the device size is large enough to hold the file system @@ -329,13 +331,13 @@ Volume::Mount(const char* deviceName, uint32 flags) return B_NO_MEMORY; FindBlock(fSuperBlock.Root(), physical); - TRACE("Volume::Mount() root: %lld (physical %lld)\n", + TRACE("Volume::Mount() root: %" B_PRIu64 " (physical %" B_PRIu64 ")\n", fSuperBlock.Root(), physical); FindBlock(fSuperBlock.ChunkRoot(), physical); - TRACE("Volume::Mount() chunk_root: %lld (physical %lld)\n", - fSuperBlock.ChunkRoot(), physical); + TRACE("Volume::Mount() chunk_root: %" B_PRIu64 " (physical %" B_PRIu64 + ")\n", fSuperBlock.ChunkRoot(), physical); FindBlock(fSuperBlock.LogRoot(), physical); - TRACE("Volume::Mount() log_root: %lld (physical %lld)\n", + TRACE("Volume::Mount() log_root: %" B_PRIu64 " (physical %" B_PRIu64 ")\n", fSuperBlock.LogRoot(), physical); fRootTree = new(std::nothrow) BPlusTree(this, fSuperBlock.Root()); @@ -351,7 +353,8 @@ Volume::Mount(const char* deviceName, uint32 flags) ERROR("Volume::Mount(): Couldn't find extent root\n"); return B_ERROR; } - TRACE("Volume::Mount(): Found extent root: %lld\n", root->BlockNum()); + TRACE("Volume::Mount(): Found extent root: %" B_PRIu64 "\n", + root->BlockNum()); fExtentTree = new(std::nothrow) BPlusTree(this, root->BlockNum()); free(root); if (fExtentTree == NULL) @@ -363,7 +366,7 @@ Volume::Mount(const char* deviceName, uint32 flags) ERROR("Volume::Mount(): Couldn't find fs root\n"); return B_ERROR; } - TRACE("Volume::Mount(): Found fs root: %lld\n", root->BlockNum()); + TRACE("Volume::Mount(): Found fs root: %" B_PRIu64 "\n", root->BlockNum()); fFSTree = new(std::nothrow) BPlusTree(this, root->BlockNum()); free(root); if (fFSTree == NULL) @@ -375,7 +378,8 @@ Volume::Mount(const char* deviceName, uint32 flags) ERROR("Volume::Mount(): Couldn't find dev root\n"); return B_ERROR; } - TRACE("Volume::Mount(): Found dev root: %lld\n", root->BlockNum()); + TRACE("Volume::Mount(): Found dev root: %" B_PRIu64 "\n", + root->BlockNum()); fDevTree = new(std::nothrow) BPlusTree(this, root->BlockNum()); free(root); if (fDevTree == NULL) @@ -387,7 +391,8 @@ Volume::Mount(const char* deviceName, uint32 flags) ERROR("Volume::Mount(): Couldn't find checksum root\n"); return B_ERROR; } - TRACE("Volume::Mount(): Found checksum root: %lld\n", root->BlockNum()); + TRACE("Volume::Mount(): Found checksum root: %" B_PRIu64 "\n", + root->BlockNum()); fChecksumTree = new(std::nothrow) BPlusTree(this, root->BlockNum()); free(root); if (fChecksumTree == NULL) @@ -401,8 +406,8 @@ Volume::Mount(const char* deviceName, uint32 flags) return status; } - TRACE("Volume::Mount(): Found root node: %lld (%s)\n", fRootNode->ID(), - strerror(fRootNode->InitCheck())); + TRACE("Volume::Mount(): Found root node: %" B_PRIu64 " (%s)\n", + fRootNode->ID(), strerror(fRootNode->InitCheck())); // all went fine opener.Keep(); @@ -488,7 +493,8 @@ status_t Volume::FindBlock(off_t logical, off_t &physical) { if (fChunkTree == NULL - || (logical >= fChunk->Offset() && logical < fChunk->End())) { + || (logical >= (off_t)fChunk->Offset() + && logical < (off_t)fChunk->End())) { // try with fChunk return fChunk->FindBlock(logical, physical); } @@ -509,8 +515,8 @@ Volume::FindBlock(off_t logical, off_t &physical) status = _chunk.FindBlock(logical, physical); if (status != B_OK) return status; - TRACE("Volume::FindBlock(): logical: %lld, physical: %lld\n", logical, - physical); + TRACE("Volume::FindBlock(): logical: %" B_PRIdOFF ", physical: %" B_PRIdOFF + "\n", logical, physical); return B_OK; } diff --git a/src/add-ons/kernel/file_systems/btrfs/kernel_interface.cpp b/src/add-ons/kernel/file_systems/btrfs/kernel_interface.cpp index eaac2c97c6..1de0f486d8 100644 --- a/src/add-ons/kernel/file_systems/btrfs/kernel_interface.cpp +++ b/src/add-ons/kernel/file_systems/btrfs/kernel_interface.cpp @@ -235,7 +235,7 @@ btrfs_read_pages(fs_volume* _volume, fs_vnode* _node, void* _cookie, while (true) { file_io_vec fileVecs[8]; - uint32 fileVecCount = 8; + size_t fileVecCount = 8; status = file_map_translate(inode->Map(), pos, bytesLeft, fileVecs, &fileVecCount, 0); @@ -321,10 +321,10 @@ btrfs_get_file_map(fs_volume* _volume, fs_vnode* _node, off_t offset, offset += blockLength; size -= blockLength; - if (size <= vecs[index - 1].length || offset >= inode->Size()) { + if ((off_t)size <= vecs[index - 1].length || offset >= inode->Size()) { // We're done! *_count = index; - TRACE("btrfs_get_file_map for inode %lld\n", inode->ID()); + TRACE("btrfs_get_file_map for inode %" B_PRIdINO "\n", inode->ID()); return B_OK; } } @@ -362,7 +362,7 @@ static status_t btrfs_ioctl(fs_volume* _volume, fs_vnode* _node, void* _cookie, uint32 cmd, void* buffer, size_t bufferLength) { - TRACE("ioctl: %lu\n", cmd); + TRACE("ioctl: %" B_PRIu32 "\n", cmd); /*Volume* volume = (Volume*)_volume->private_volume;*/ return B_DEV_INVALID_IOCTL; diff --git a/src/add-ons/kernel/file_systems/cdda/cdda.cpp b/src/add-ons/kernel/file_systems/cdda/cdda.cpp index 77320a9c8f..605b5ca099 100644 --- a/src/add-ons/kernel/file_systems/cdda/cdda.cpp +++ b/src/add-ons/kernel/file_systems/cdda/cdda.cpp @@ -557,7 +557,7 @@ read_cdtext(int fd, struct cdtext &cdtext) scsi_toc_general *header = (scsi_toc_general *)buffer; - size_t packLength = B_BENDIAN_TO_HOST_INT16(header->data_length) - 2; + uint32 packLength = B_BENDIAN_TO_HOST_INT16(header->data_length) - 2; cdtext_pack_data *pack = (cdtext_pack_data *)(header + 1); cdtext_pack_data *lastPack = NULL; uint8 state = 0; @@ -656,8 +656,8 @@ status_t read_cdda_data(int fd, off_t endFrame, off_t offset, void *data, size_t length, off_t bufferOffset, void *buffer, size_t bufferSize) { - if (bufferOffset >= 0 && bufferOffset <= offset + length - && bufferOffset + bufferSize > offset) { + if (bufferOffset >= 0 && bufferOffset <= offset + (off_t)length + && bufferOffset + (off_t)bufferSize > offset) { if (offset >= bufferOffset) { // buffer reaches into the beginning of the request off_t dataOffset = offset - bufferOffset; diff --git a/src/add-ons/kernel/file_systems/cdda/kernel_interface.cpp b/src/add-ons/kernel/file_systems/cdda/kernel_interface.cpp index 1a78ad4b66..fafd3a635d 100644 --- a/src/add-ons/kernel/file_systems/cdda/kernel_interface.cpp +++ b/src/add-ons/kernel/file_systems/cdda/kernel_interface.cpp @@ -153,7 +153,7 @@ public: status_t SetSize(off_t size); const char* Name() const { return fName; } - size_t Size() const { return fSize; } + off_t Size() const { return fSize; } type_code Type() const { return fType; } uint8* Data() const { return fData; } @@ -164,7 +164,7 @@ private: char* fName; type_code fType; uint8* fData; - size_t fSize; + off_t fSize; }; class Inode { @@ -473,7 +473,7 @@ open_attributes(uint32 cddbID, int deviceFD, int mode, if (attrMode == kDiscIDAttributes) { char id[64]; - snprintf(id, sizeof(id), "/%08lx", cddbID); + snprintf(id, sizeof(id), "/%08" B_PRIx32, cddbID); strlcat(path, id, B_PATH_NAME_LENGTH); } else if (attrMode == kDeviceAttributes) { uint32 length = strlen(path); @@ -528,9 +528,12 @@ fill_stat_buffer(Volume* volume, Inode* inode, Attribute* attribute, stat.st_uid = inode->UserID(); stat.st_gid = inode->GroupID(); - stat.st_atime = time(NULL); - stat.st_mtime = stat.st_ctime = inode->ModificationTime(); - stat.st_crtime = inode->CreationTime(); + stat.st_atim.tv_sec = time(NULL); + stat.st_atim.tv_nsec = 0; + stat.st_mtim.tv_sec = stat.st_ctim.tv_sec = inode->ModificationTime(); + stat.st_ctim.tv_nsec = stat.st_mtim.tv_nsec = 0; + stat.st_crtim.tv_sec = inode->CreationTime(); + stat.st_crtim.tv_nsec = 0; } @@ -690,14 +693,14 @@ Volume::Mount(const char* device) if (text.titles[i] != NULL) { if (text.artists[i] != NULL) { - snprintf(title, sizeof(title), "%02ld. %s - %s.wav", track, - text.artists[i], text.titles[i]); + snprintf(title, sizeof(title), "%02" B_PRId32 ". %s - %s.wav", + track, text.artists[i], text.titles[i]); } else { - snprintf(title, sizeof(title), "%02ld. %s.wav", track, - text.titles[i]); + snprintf(title, sizeof(title), "%02" B_PRId32 ". %s.wav", + track, text.titles[i]); } } else - snprintf(title, sizeof(title), "Track %02ld.wav", track); + snprintf(title, sizeof(title), "Track %02" B_PRId32 ".wav", track); // remove '/' and '\n' from title for (int32 j = 0; title[j]; j++) { @@ -722,7 +725,7 @@ Volume::Mount(const char* device) inode->AddAttribute("Audio:Track", B_INT32_TYPE, (uint32)track); inode->AddAttribute("Audio:Bitrate", B_STRING_TYPE, "1411 kbps"); inode->AddAttribute("Media:Length", B_INT64_TYPE, - inode->FrameCount() * 1000000LL / kFramesPerSecond); + inode->FrameCount() * 1000000L / kFramesPerSecond); inode->AddAttribute("BEOS:TYPE", B_MIME_STRING_TYPE, "audio/x-wav"); } @@ -1044,7 +1047,7 @@ Attribute::ReadAt(off_t offset, uint8* buffer, size_t* _length) *_length = 0; return B_OK; } - if (offset + length > fSize) + if (offset + (off_t)length > fSize) length = fSize - offset; if (user_memcpy(buffer, fData + offset, length) < B_OK) @@ -1710,13 +1713,13 @@ cdda_read(fs_volume* _volume, fs_vnode* _node, void* _cookie, off_t offset, } size_t length = *_length; - if (offset + length > maxSize) + if (offset + (off_t)length > maxSize) length = maxSize - offset; status_t status = B_OK; size_t bytesRead = 0; - if (offset < sizeof(wav_header)) { + if (offset < (off_t)sizeof(wav_header)) { // read fake WAV header size_t size = sizeof(wav_header) - offset; size = min_c(size, length); diff --git a/src/add-ons/kernel/file_systems/exfat/DataStream.cpp b/src/add-ons/kernel/file_systems/exfat/DataStream.cpp index 48edf05709..5a9647e7c8 100644 --- a/src/add-ons/kernel/file_systems/exfat/DataStream.cpp +++ b/src/add-ons/kernel/file_systems/exfat/DataStream.cpp @@ -62,8 +62,8 @@ DataStream::FindBlock(off_t pos, off_t& physical, off_t *_length) } *_length = min_c((cluster - clusterIndex + 1) * kClusterSize - offset, fSize - pos); - TRACE("inode %" B_PRIdINO ": cluster %ld, pos %lld, %lld\n", - fInode->ID(), clusterIndex, pos, physical); + TRACE("inode %" B_PRIdINO ": cluster %" B_PRIu32 ", pos %" B_PRIdOFF ", %" + B_PRIdOFF "\n", fInode->ID(), clusterIndex, pos, physical); return B_OK; } diff --git a/src/add-ons/kernel/file_systems/exfat/DirectoryIterator.cpp b/src/add-ons/kernel/file_systems/exfat/DirectoryIterator.cpp index ffeaff1bac..2c33bbab3d 100644 --- a/src/add-ons/kernel/file_systems/exfat/DirectoryIterator.cpp +++ b/src/add-ons/kernel/file_systems/exfat/DirectoryIterator.cpp @@ -27,7 +27,7 @@ DirectoryIterator::DirectoryIterator(Inode* inode) fBlock(inode->GetVolume()), fCurrent(NULL) { - TRACE("DirectoryIterator::DirectoryIterator() %ld\n", fCluster); + TRACE("DirectoryIterator::DirectoryIterator() %" B_PRIu32 "\n", fCluster); } @@ -47,9 +47,13 @@ status_t DirectoryIterator::GetNext(char* name, size_t* _nameLength, ino_t* _id, EntryVisitor* visitor) { + if (fCluster == EXFAT_CLUSTER_END) + return B_ENTRY_NOT_FOUND; if (fOffset == -2) { - *_nameLength = 3; - strlcpy(name, "..", *_nameLength); + if (*_nameLength < 3) + return B_BUFFER_OVERFLOW; + *_nameLength = 2; + strlcpy(name, "..", *_nameLength + 1); if (fInode->ID() == 1) *_id = fInode->ID(); else @@ -58,20 +62,23 @@ DirectoryIterator::GetNext(char* name, size_t* _nameLength, ino_t* _id, TRACE("DirectoryIterator::GetNext() found ..\n"); return B_OK; } else if (fOffset == -1) { - *_nameLength = 2; - strlcpy(name, ".", *_nameLength); + if (*_nameLength < 2) + return B_BUFFER_OVERFLOW; + *_nameLength = 1; + strlcpy(name, ".", *_nameLength + 1); *_id = fInode->ID(); fOffset = 0; TRACE("DirectoryIterator::GetNext() found .\n"); return B_OK; } - uchar unicodeName[EXFAT_FILENAME_MAX_LENGTH]; + uchar unicodeName[EXFAT_FILENAME_MAX_LENGTH + 1]; size_t nameLength = EXFAT_FILENAME_MAX_LENGTH; status_t status = _GetNext(unicodeName, &nameLength, _id, visitor); if (status == B_OK && name != NULL) { - unicode_to_utf8(unicodeName, nameLength, (uint8 *)name , _nameLength); - TRACE("DirectoryIterator::GetNext() %ld %s, %" B_PRIdINO "\n", + status = unicode_to_utf8(unicodeName, nameLength, (uint8 *)name, + _nameLength); + TRACE("DirectoryIterator::GetNext() %" B_PRIu32 " %s, %" B_PRIdINO "\n", fInode->Cluster(), name, *_id); } @@ -96,7 +103,7 @@ DirectoryIterator::Lookup(const char* name, size_t nameLength, ino_t* _id) Rewind(); fOffset = 0; - uchar currentName[EXFAT_FILENAME_MAX_LENGTH]; + uchar currentName[EXFAT_FILENAME_MAX_LENGTH + 1]; size_t currentLength = EXFAT_FILENAME_MAX_LENGTH; while (_GetNext((uchar*)currentName, ¤tLength, _id) == B_OK) { char utfName[EXFAT_FILENAME_MAX_LENGTH]; @@ -122,7 +129,7 @@ DirectoryIterator::LookupEntry(EntryVisitor* visitor) fCluster = fInode->Cluster(); fOffset = fInode->Offset(); - uchar unicodeName[EXFAT_FILENAME_MAX_LENGTH]; + uchar unicodeName[EXFAT_FILENAME_MAX_LENGTH + 1]; size_t nameLength = EXFAT_FILENAME_MAX_LENGTH; return _GetNext(unicodeName, &nameLength, NULL, visitor); } @@ -177,8 +184,9 @@ DirectoryIterator::_GetNext(uchar* name, size_t* _nameLength, ino_t* _id, status_t status; int32 chunkCount = 1; while ((status = _NextEntry()) == B_OK) { - TRACE("DirectoryIterator::_GetNext() %ld/%p, type 0x%x, offset %lld\n", - fInode->Cluster(), fCurrent, fCurrent->type, fOffset); + TRACE("DirectoryIterator::_GetNext() %" B_PRIu32 "/%p, type 0x%x, " + "offset %" B_PRId64 "\n", fInode->Cluster(), fCurrent, + fCurrent->type, fOffset); if (fCurrent->type == EXFAT_ENTRY_TYPE_FILE) { chunkCount = fCurrent->file.chunkCount; if (_id != NULL) { @@ -187,8 +195,8 @@ DirectoryIterator::_GetNext(uchar* name, size_t* _nameLength, ino_t* _id, } if (visitor != NULL) visitor->VisitFile(fCurrent); - TRACE("DirectoryIterator::_GetNext() File chunkCount %ld\n", - chunkCount); + TRACE("DirectoryIterator::_GetNext() File chunkCount %" B_PRId32 + "\n", chunkCount); } else if (fCurrent->type == EXFAT_ENTRY_TYPE_FILEINFO) { chunkCount--; TRACE("DirectoryIterator::_GetNext() Filename length %d\n", @@ -234,7 +242,8 @@ DirectoryIterator::_NextEntry() fInode->GetVolume()->ClusterToBlock(fCluster, block); block += (fOffset / fInode->GetVolume()->EntriesPerBlock()) % (1 << fInode->GetVolume()->SuperBlock().BlocksPerClusterShift()); - TRACE("DirectoryIterator::_NextEntry() init to block %lld\n", block); + TRACE("DirectoryIterator::_NextEntry() init to block %" B_PRIu64 "\n", + block); fCurrent = (struct exfat_entry*)fBlock.SetTo(block) + fOffset % fInode->GetVolume()->EntriesPerBlock(); } else if ((fOffset % fInode->GetVolume()->EntriesPerBlock()) == 0) { @@ -246,7 +255,7 @@ DirectoryIterator::_NextEntry() fInode->GetVolume()->ClusterToBlock(fCluster, block); } else block = fBlock.BlockNumber() + 1; - TRACE("DirectoryIterator::_NextEntry() block %lld\n", block); + TRACE("DirectoryIterator::_NextEntry() block %" B_PRIu64 "\n", block); fCurrent = (struct exfat_entry*)fBlock.SetTo(block); } else fCurrent++; diff --git a/src/add-ons/kernel/file_systems/exfat/Inode.cpp b/src/add-ons/kernel/file_systems/exfat/Inode.cpp index a03c13cceb..c2548437de 100644 --- a/src/add-ons/kernel/file_systems/exfat/Inode.cpp +++ b/src/add-ons/kernel/file_systems/exfat/Inode.cpp @@ -37,8 +37,8 @@ Inode::Inode(Volume* volume, cluster_t cluster, uint32 offset) fCache(NULL), fMap(NULL) { - TRACE("Inode::Inode(%ld, %d) inode %" B_PRIdINO "\n", Cluster(), Offset(), - ID()); + TRACE("Inode::Inode(%" B_PRIu32 ", %" B_PRIu32 ") inode %" B_PRIdINO "\n", + Cluster(), Offset(), ID()); _Init(); if (ID() == 1) { @@ -72,7 +72,8 @@ Inode::Inode(Volume* volume, ino_t ino) fOffset = key->offset; fInitStatus = B_OK; } - TRACE("Inode::Inode(%" B_PRIdINO ") cluster %ld\n", ID(), Cluster()); + TRACE("Inode::Inode(%" B_PRIdINO ") cluster %" B_PRIu32 "\n", ID(), + Cluster()); _Init(); if (fInitStatus == B_OK && ID() != 1) { @@ -204,14 +205,14 @@ Inode::ReadAt(off_t pos, uint8* buffer, size_t* _length) // set/check boundaries for pos/length if (pos < 0) { - ERROR("inode %" B_PRIdINO ": ReadAt failed(pos %lld, length %lu)\n", - ID(), pos, length); + ERROR("inode %" B_PRIdINO ": ReadAt failed(pos %" B_PRIdOFF", length %" + B_PRIuSIZE ")\n", ID(), pos, length); return B_BAD_VALUE; } if (pos >= Size() || length == 0) { - TRACE("inode %" B_PRIdINO ": ReadAt 0 (pos %lld, length %lu)\n", - ID(), pos, length); + TRACE("inode %" B_PRIdINO ": ReadAt 0 (pos %" B_PRIdOFF", length %" + B_PRIuSIZE ")\n", ID(), pos, length); *_length = 0; return B_NO_ERROR; } @@ -269,9 +270,11 @@ Inode::_GetTimespec(uint16 date, uint16 time, struct timespec ×pec) const if (tzoffset == -1) tzoffset = get_timezone_offset() / 60; - time_t days = daze[(date>>5)&15] + ((date>>9)+10)*365 + leaps((date>>9)+10,((date>>5)&15)-1)+(date&31)-1; + time_t days = daze[(date >> 5) & 15] + ((date >> 9) + 10) * 365 + + leaps((date >> 9) + 10, ((date >> 5) & 15) - 1) + (date & 31) -1; - timespec.tv_sec = ((days * 24 + (time >> 11)) * 60 + ((time>>5)&63) + tzoffset) * 60 + 2*(time&31); + timespec.tv_sec = ((days * 24 + (time >> 11)) * 60 + ((time >> 5) & 63) + - tzoffset) * 60 + 2 * (time & 31); timespec.tv_nsec = 0; } diff --git a/src/add-ons/kernel/file_systems/exfat/Inode.h b/src/add-ons/kernel/file_systems/exfat/Inode.h index 9c0ee1628e..26bc92fa0d 100644 --- a/src/add-ons/kernel/file_systems/exfat/Inode.h +++ b/src/add-ons/kernel/file_systems/exfat/Inode.h @@ -40,7 +40,7 @@ public: ino_t ID() const { return fID; } ino_t Parent() const { return fParent; } cluster_t Cluster() const { return fCluster; } - uint32_t Offset() const { return fOffset; } + uint32 Offset() const { return fOffset; } cluster_t StartCluster() const { return fFileInfoEntry.file_info.StartCluster(); } bool IsContiguous() const diff --git a/src/add-ons/kernel/file_systems/exfat/Volume.cpp b/src/add-ons/kernel/file_systems/exfat/Volume.cpp index 1881909751..feea51b48d 100644 --- a/src/add-ons/kernel/file_systems/exfat/Volume.cpp +++ b/src/add-ons/kernel/file_systems/exfat/Volume.cpp @@ -218,7 +218,7 @@ LabelVisitor::LabelVisitor(Volume* volume) bool LabelVisitor::VisitLabel(struct exfat_entry* entry) { - dprintf("LabelVisitor::VisitLabel()\n"); + TRACE("LabelVisitor::VisitLabel()\n"); char utfName[30]; size_t utfLength = 30; unicode_to_utf8((const uchar*)entry->name_label.name, @@ -318,7 +318,7 @@ Volume::Mount(const char* deviceName, uint32 flags) } fBlockSize = 1 << fSuperBlock.BlockShift(); - TRACE("block size %ld\n", fBlockSize); + TRACE("block size %" B_PRIu32 "\n", fBlockSize); fEntriesPerBlock = (fBlockSize / sizeof(struct exfat_entry)); // check if the device size is large enough to hold the file system @@ -348,7 +348,7 @@ Volume::Mount(const char* deviceName, uint32 flags) return status; } - TRACE("Volume::Mount(): Found root node: %lld (%s)\n", fRootNode->ID(), + TRACE("Volume::Mount(): Found root node: %" B_PRIdINO " (%s)\n", fRootNode->ID(), strerror(fRootNode->InitCheck())); // all went fine @@ -418,9 +418,12 @@ Volume::LoadSuperBlock() status_t Volume::ClusterToBlock(cluster_t cluster, fsblock_t &block) { + if (cluster < 2) + return B_BAD_VALUE; block = ((cluster - 2) << SuperBlock().BlocksPerClusterShift()) + SuperBlock().FirstDataBlock(); - TRACE("Volume::ClusterToBlock() cluster %lu %u %lu: %llu, %lu\n", cluster, + TRACE("Volume::ClusterToBlock() cluster %" B_PRIu32 " %u %" B_PRIu32 ": %" + B_PRIu64 ", %" B_PRIu32 "\n", cluster, SuperBlock().BlocksPerClusterShift(), SuperBlock().FirstDataBlock(), block, SuperBlock().FirstFatBlock()); return B_OK; @@ -436,7 +439,8 @@ Volume::NextCluster(cluster_t _cluster) + _cluster / clusterPerBlock; cluster_t *cluster = (cluster_t *)block.SetTo(blockNum); cluster += _cluster % clusterPerBlock; - TRACE("Volume::NextCluster() cluster %lu next %lu\n", _cluster, *cluster); + TRACE("Volume::NextCluster() cluster %" B_PRIu32 " next %" B_PRIu32 "\n", + _cluster, *cluster); return *cluster; } @@ -463,8 +467,8 @@ Volume::GetIno(cluster_t cluster, uint32 offset, ino_t parent) key.offset = offset; struct node* node = fNodeTree.Lookup(key); if (node != NULL) { - TRACE("Volume::GetIno() cached cluster %lu offset %lu ino %" B_PRIdINO - "\n", cluster, offset, node->ino); + TRACE("Volume::GetIno() cached cluster %" B_PRIu32 " offset %" B_PRIu32 + " ino %" B_PRIdINO "\n", cluster, offset, node->ino); return node->ino; } node = new struct node(); @@ -473,8 +477,8 @@ Volume::GetIno(cluster_t cluster, uint32 offset, ino_t parent) node->parent = parent; fNodeTree.Insert(node); fInoTree.Insert(node); - TRACE("Volume::GetIno() new cluster %lu offset %lu ino %" B_PRIdINO "\n", - cluster, offset, node->ino); + TRACE("Volume::GetIno() new cluster %" B_PRIu32 " offset %" B_PRIu32 + " ino %" B_PRIdINO "\n", cluster, offset, node->ino); return node->ino; } diff --git a/src/add-ons/kernel/file_systems/exfat/encodings.cpp b/src/add-ons/kernel/file_systems/exfat/encodings.cpp index 53e5b35b95..0393fab255 100644 --- a/src/add-ons/kernel/file_systems/exfat/encodings.cpp +++ b/src/add-ons/kernel/file_systems/exfat/encodings.cpp @@ -98,14 +98,15 @@ static status_t _lendian_unicode_to_utf8( const char *src, - int32 *srcLen, + size_t *srcLen, char *dst, - uint32 *dstLen) + size_t *dstLen) { - int32 srcLimit = *srcLen; - int32 dstLimit = *dstLen; - int32 srcCount = 0; - int32 dstCount = 0; + size_t srcLimit = *srcLen; + size_t dstLimit = *dstLen; + size_t srcCount = 0; + size_t dstCount = 0; + status_t status = B_ERROR; for (srcCount = 0; srcCount < srcLimit; srcCount += 2) { uint16 *UNICODE = (uint16 *)&src[srcCount]; @@ -119,33 +120,37 @@ _lendian_unicode_to_utf8( u_lendian_to_utf8(UTF8, UNICODE); utf8Len = UTF8 - utf8; - if ((dstCount + utf8Len) > dstLimit) + if ((dstCount + utf8Len) > dstLimit) { + status = B_BUFFER_OVERFLOW; break; + } for (j = 0; j < utf8Len; j++) dst[dstCount + j] = utf8[j]; dstCount += utf8Len; + status = B_OK; } *srcLen = srcCount; *dstLen = dstCount; dst[dstCount] = '\0'; - return ((dstCount > 0) ? B_NO_ERROR : B_ERROR); + return status; } // utf8 to LENDIAN unicode static status_t _utf8_to_lendian_unicode( const char *src, - int32 *srcLen, + size_t *srcLen, char *dst, - uint32 *dstLen) + size_t *dstLen) { - int32 srcLimit = *srcLen; - int32 dstLimit = *dstLen - 1; - int32 srcCount = 0; - int32 dstCount = 0; + size_t srcLimit = *srcLen; + size_t dstLimit = *dstLen - 1; + size_t srcCount = 0; + size_t dstCount = 0; + status_t status = B_ERROR; while ((srcCount < srcLimit) && (dstCount < dstLimit)) { uint16 unicode; @@ -157,31 +162,36 @@ _utf8_to_lendian_unicode( break; utf8_to_u_hostendian(UTF8, UNICODE, err_flag); - if(err_flag == 1) + if (err_flag == 1) return EINVAL; unicode = B_HOST_TO_LENDIAN_INT16(unicode); + if ((dstCount + 1) > dstLimit) { + status = B_BUFFER_OVERFLOW; + break; + } dst[dstCount++] = unicode & 0xFF; dst[dstCount++] = unicode >> 8; srcCount += UTF8 - ((uchar *)(src + srcCount)); + status = B_OK; } *srcLen = srcCount; *dstLen = dstCount; - return ((dstCount > 0) ? B_NO_ERROR : B_ERROR); + return status; } // takes a unicode name of unilen uchar's and converts to a utf8 name of at // most utf8len uint8's -status_t unicode_to_utf8(const uchar *uni, uint32 unilen, uint8 *utf8, - uint32 *utf8len) +status_t unicode_to_utf8(const uchar *uni, size_t unilen, uint8 *utf8, + size_t *utf8len) { - uint32 origlen = unilen; + //size_t origlen = unilen; status_t result = _lendian_unicode_to_utf8((char *)uni, - (int32 *)&unilen, (char *)utf8, utf8len); + &unilen, (char *)utf8, utf8len); /*if (unilen < origlen) { panic("Name is too long (%lx < %lx)\n", unilen, origlen); @@ -192,13 +202,13 @@ status_t unicode_to_utf8(const uchar *uni, uint32 unilen, uint8 *utf8, } -status_t utf8_to_unicode(const char *utf8, uchar *uni, uint32 *unilen) +status_t utf8_to_unicode(const char *utf8, uchar *uni, size_t *unilen) { - uint32 origlen = strlen(utf8) + 1; - uint32 utf8len = origlen; + size_t origlen = strlen(utf8) + 1; + size_t utf8len = origlen; status_t result = _utf8_to_lendian_unicode(utf8, - (int32 *)&utf8len, (char *)uni, unilen); + &utf8len, (char *)uni, unilen); /*if (origlen < utf8len) { panic("Name is too long (%lx < %lx)\n", *unilen, origlen); diff --git a/src/add-ons/kernel/file_systems/exfat/encodings.h b/src/add-ons/kernel/file_systems/exfat/encodings.h index 2d4fdcd33a..eaddd918bd 100644 --- a/src/add-ons/kernel/file_systems/exfat/encodings.h +++ b/src/add-ons/kernel/file_systems/exfat/encodings.h @@ -9,9 +9,9 @@ extern "C" { #endif -status_t unicode_to_utf8(const uchar *uni, uint32 unilen, uint8 *utf8, - uint32 *utf8len); -status_t utf8_to_unicode(const char *utf8, uchar *uni, uint32 *unilen); +status_t unicode_to_utf8(const uchar *uni, size_t unilen, uint8 *utf8, + size_t *utf8len); +status_t utf8_to_unicode(const char *utf8, uchar *uni, size_t *unilen); #ifdef __cplusplus } diff --git a/src/add-ons/kernel/file_systems/exfat/kernel_interface.cpp b/src/add-ons/kernel/file_systems/exfat/kernel_interface.cpp index 2d0a6b2b6b..c2110e713a 100644 --- a/src/add-ons/kernel/file_systems/exfat/kernel_interface.cpp +++ b/src/add-ons/kernel/file_systems/exfat/kernel_interface.cpp @@ -179,7 +179,7 @@ static status_t exfat_get_vnode(fs_volume* _volume, ino_t id, fs_vnode* _node, int* _type, uint32* _flags, bool reenter) { - TRACE("get_vnode %lu\n", id); + TRACE("get_vnode %" B_PRIdINO "\n", id); Volume* volume = (Volume*)_volume->private_volume; Inode* inode = new(std::nothrow) Inode(volume, id); @@ -236,7 +236,7 @@ exfat_read_pages(fs_volume* _volume, fs_vnode* _node, void* _cookie, while (true) { file_io_vec fileVecs[8]; - uint32 fileVecCount = 8; + size_t fileVecCount = 8; status = file_map_translate(inode->Map(), pos, bytesLeft, fileVecs, &fileVecCount, 0); @@ -322,10 +322,10 @@ exfat_get_file_map(fs_volume* _volume, fs_vnode* _node, off_t offset, offset += blockLength; size -= blockLength; - if (size <= vecs[index - 1].length || offset >= inode->Size()) { + if ((off_t)size <= vecs[index - 1].length || offset >= inode->Size()) { // We're done! *_count = index; - TRACE("exfat_get_file_map for inode %lld\n", inode->ID()); + TRACE("exfat_get_file_map for inode %" B_PRIdINO"\n", inode->ID()); return B_OK; } } @@ -357,7 +357,7 @@ exfat_lookup(fs_volume* _volume, fs_vnode* _directory, const char* name, return status; } - TRACE("exfat_lookup: ID %d\n", *_vnodeID); + TRACE("exfat_lookup: ID %" B_PRIdINO "\n", *_vnodeID); return get_vnode(volume->FSVolume(), *_vnodeID, NULL); } @@ -367,7 +367,7 @@ static status_t exfat_ioctl(fs_volume* _volume, fs_vnode* _node, void* _cookie, uint32 cmd, void* buffer, size_t bufferLength) { - TRACE("ioctl: %lu\n", cmd); + TRACE("ioctl: %" B_PRIu32 "\n", cmd); /*Volume* volume = (Volume*)_volume->private_volume;*/ return B_DEV_INVALID_IOCTL; @@ -526,24 +526,40 @@ exfat_read_dir(fs_volume *_volume, fs_vnode *_node, void *_cookie, { TRACE("exfat_read_dir\n"); DirectoryIterator* iterator = (DirectoryIterator*)_cookie; - - size_t length = bufferSize; - ino_t id; - status_t status = iterator->GetNext(dirent->d_name, &length, &id); - if (status == B_ENTRY_NOT_FOUND) { - *_num = 0; - return B_OK; - } else if (status != B_OK) - return status; - Volume* volume = (Volume*)_volume->private_volume; - dirent->d_dev = volume->ID(); - dirent->d_ino = id; - dirent->d_reclen = sizeof(struct dirent) + length; - *_num = 1; + + uint32 maxCount = *_num; + uint32 count = 0; + while (count < maxCount && bufferSize > sizeof(struct dirent)) { + ino_t id; + size_t length = bufferSize - sizeof(struct dirent) + 1; + + status_t status = iterator->GetNext(dirent->d_name, &length, &id); + if (status == B_ENTRY_NOT_FOUND) + break; + + if (status == B_BUFFER_OVERFLOW) { + // the remaining name buffer length was too small + if (count == 0) + return B_BUFFER_OVERFLOW; + break; + } + + if (status != B_OK) + return status; + + dirent->d_dev = volume->ID(); + dirent->d_ino = id; + dirent->d_reclen = sizeof(struct dirent) + length; + + bufferSize -= dirent->d_reclen; + dirent = (struct dirent*)((uint8*)dirent + dirent->d_reclen); + count++; + } + + *_num = count; TRACE("exfat_read_dir end\n"); - return B_OK; } diff --git a/src/add-ons/kernel/file_systems/ext2/Attribute.cpp b/src/add-ons/kernel/file_systems/ext2/Attribute.cpp index 746b13ad9c..713d8b23fc 100644 --- a/src/add-ons/kernel/file_systems/ext2/Attribute.cpp +++ b/src/add-ons/kernel/file_systems/ext2/Attribute.cpp @@ -211,7 +211,7 @@ Attribute::Read(attr_cookie* cookie, off_t pos, uint8* buffer, size_t* _length) start += EXT2_INODE_NORMAL_SIZE + fInode->Node().ExtraInodeSize() + sizeof(uint32); pos += fBodyEntry->ValueOffset(); - if ((pos + length) > (end - start) || length > fBodyEntry->ValueSize()) + if ((off_t)(pos + length) > (end - start) || length > fBodyEntry->ValueSize()) return ERANGE; } memcpy(buffer, start + (uint32)pos, length); diff --git a/src/add-ons/kernel/file_systems/ext2/BitmapBlock.cpp b/src/add-ons/kernel/file_systems/ext2/BitmapBlock.cpp index a048eb25f0..fcd5147640 100644 --- a/src/add-ons/kernel/file_systems/ext2/BitmapBlock.cpp +++ b/src/add-ons/kernel/file_systems/ext2/BitmapBlock.cpp @@ -28,7 +28,7 @@ BitmapBlock::BitmapBlock(Volume* volume, uint32 numBits) fNumBits(numBits), fMaxIndex(fNumBits >> 5) { - TRACE("BitmapBlock::BitmapBlock(): num bits: %lu\n", fNumBits); + TRACE("BitmapBlock::BitmapBlock(): num bits: %" B_PRIu32 "\n", fNumBits); } @@ -95,7 +95,8 @@ BitmapBlock::_Check(uint32 start, uint32 length, bool marked) uint32 bits = B_LENDIAN_TO_HOST_INT32(data[index]); if ((bits & mask) != (marked ? mask : 0)) { - TRACE("BitmapBlock::_Check(): start %lx mask %lx\n", bits, mask); + TRACE("BitmapBlock::_Check(): start %" B_PRIx32 " mask %" B_PRIx32 + "\n", bits, mask); return false; } @@ -105,8 +106,8 @@ BitmapBlock::_Check(uint32 start, uint32 length, bool marked) for (; iterations > 0; --iterations) { if (data[index++] != (marked ? 0xFFFFFFFF : 0)) { - TRACE("BitmapBlock::_Check(): iterations %lu bits: %lX\n", iterations, - data[index - 1]); + TRACE("BitmapBlock::_Check(): iterations %" B_PRIu32 " bits: %" + B_PRIx32 "\n", iterations, data[index - 1]); return false; } } @@ -116,8 +117,9 @@ BitmapBlock::_Check(uint32 start, uint32 length, bool marked) uint32 bits = B_LENDIAN_TO_HOST_INT32(data[index]); if ((bits & mask) != (marked ? mask : 0)) { - TRACE("BitmapBlock::_Check(): remainingBits %ld remaining %lX mask %lX\n", - remainingBits, bits, mask); + TRACE("BitmapBlock::_Check(): remainingBits %" B_PRIu32 + " remaining %" B_PRIx32 " mask %" B_PRIx32 "\n", remainingBits, + bits, mask); return false; } } @@ -129,8 +131,8 @@ BitmapBlock::_Check(uint32 start, uint32 length, bool marked) bool BitmapBlock::_Update(uint32 start, uint32 length, bool mark, bool force) { - TRACE("BitmapBlock::_Update(%lu, %lu, %c, %c)\n", start, length, - unmark ? 't' : 'f', force ? 't' : 'f'); + TRACE("BitmapBlock::_Update(%" B_PRIu32 ", %" B_PRIu32 ", %c, %c)\n", + start, length, mark ? 't' : 'f', force ? 't' : 'f'); if (fData == NULL || start + length > fNumBits) return false; @@ -139,23 +141,24 @@ BitmapBlock::_Update(uint32 start, uint32 length, bool mark, bool force) uint32 startBit = start & 0x1F; uint32 remainingBits = (length + startBit) & 0x1F; - TRACE("BitmapBlock::_Update(): start index: %lu, start bit: %lu, remaining " - "bits: %lu)\n", startIndex, startBit, remainingBits); + TRACE("BitmapBlock::_Update(): start index: %" B_PRIu32 ", start bit: %" + B_PRIu32 ", remaining bits: %" B_PRIu32 ")\n", startIndex, startBit, + remainingBits); uint32 iterations; if (length < 32) { if (startBit + length < 32) { uint32 bits = B_LENDIAN_TO_HOST_INT32(fData[startIndex]); - TRACE("BitmapBlock::_Update(): bits: %lx\n", bits); + TRACE("BitmapBlock::_Update(): bits: %" B_PRIx32 "\n", bits); uint32 mask = (1 << (startBit + length)) - 1; mask &= ~((1 << startBit) - 1); - TRACE("BitmapBlock::_Update(): mask: %lx\n", mask); + TRACE("BitmapBlock::_Update(): mask: %" B_PRIx32 "\n", mask); if ((bits & mask) != (mark ? 0 : mask)) { - ERROR("BitmapBlock::_Update() Marking failed bits %lx " - "startBit %ld\n", bits, startBit); + ERROR("BitmapBlock::_Update() Marking failed bits %" B_PRIx32 + " startBit %" B_PRIu32 "\n", bits, startBit); return false; } @@ -164,7 +167,8 @@ BitmapBlock::_Update(uint32 start, uint32 length, bool mark, bool force) else bits &= ~mask; - TRACE("BitmapBlock::_Update(): updated bits: %lx\n", bits); + TRACE("BitmapBlock::_Update(): updated bits: %" B_PRIx32 "\n", + bits); fData[startIndex] = B_HOST_TO_LENDIAN_INT32(bits); return true; @@ -173,14 +177,15 @@ BitmapBlock::_Update(uint32 start, uint32 length, bool mark, bool force) } else iterations = (length - 32 + startBit) >> 5; - TRACE("BitmapBlock::_Update(): iterations: %lu\n", iterations); + TRACE("BitmapBlock::_Update(): iterations: %" B_PRIu32 "\n", iterations); uint32 index = startIndex; if (startBit != 0) { uint32 mask = ~((1 << startBit) - 1); uint32 bits = B_LENDIAN_TO_HOST_INT32(fData[index]); - TRACE("BitmapBlock::_Update(): mask: %lx, bits: %lx\n", mask, bits); + TRACE("BitmapBlock::_Update(): mask: %" B_PRIx32 ", bits: %" B_PRIx32 + "\n", mask, bits); if (!force && (bits & mask) != (mark ? 0 : mask)) return false; @@ -191,7 +196,7 @@ BitmapBlock::_Update(uint32 start, uint32 length, bool mark, bool force) bits &= ~mask; fData[index] = B_HOST_TO_LENDIAN_INT32(bits); - TRACE("BitmapBlock::_Update(): updated bits: %lx\n", bits); + TRACE("BitmapBlock::_Update(): updated bits: %" B_PRIx32 "\n", bits); index += 1; } else iterations++; @@ -199,7 +204,8 @@ BitmapBlock::_Update(uint32 start, uint32 length, bool mark, bool force) for (; iterations > 0; --iterations) { if (!force && fData[index] != (mark ? 0 : 0xFFFFFFFF)) { ERROR("BitmapBlock::_Update() Marking failed " - "index %ld, iterations %ld\n", index, iterations); + "index %" B_PRIu32 ", iterations %" B_PRId32 "\n", index, + iterations); return false; } fData[index++] = (mark ? 0xFFFFFFFF : 0); @@ -211,7 +217,8 @@ BitmapBlock::_Update(uint32 start, uint32 length, bool mark, bool force) uint32 mask = (1 << remainingBits) - 1; uint32 bits = B_LENDIAN_TO_HOST_INT32(fData[index]); - TRACE("BitmapBlock::_Update(): mask: %lx, bits: %lx\n", mask, bits); + TRACE("BitmapBlock::_Update(): mask: %" B_PRIx32 ", bits: %" B_PRIx32 + "\n", mask, bits); if (!force && (bits & mask) != (mark ? 0 : mask)) { ERROR("BitmapBlock::_Update() Marking failed remaining\n"); @@ -224,7 +231,7 @@ BitmapBlock::_Update(uint32 start, uint32 length, bool mark, bool force) bits &= ~mask; fData[index] = B_HOST_TO_LENDIAN_INT32(bits); - TRACE("BitmapBlock::_Update(): updated bits: %lx\n", bits); + TRACE("BitmapBlock::_Update(): updated bits: %" B_PRIx32 "\n", bits); } return true; @@ -234,7 +241,7 @@ BitmapBlock::_Update(uint32 start, uint32 length, bool mark, bool force) void BitmapBlock::_FindNext(uint32& pos, bool marked) { - TRACE("BitmapBlock::_FindNext(): pos: %lu\n", pos); + TRACE("BitmapBlock::_FindNext(): pos: %" B_PRIu32 "\n", pos); const uint32* data = fData == NULL ? fReadOnlyData : fData; if (data == NULL) @@ -252,8 +259,9 @@ BitmapBlock::_FindNext(uint32& pos, bool marked) uint32 mask = ~((1 << bit) - 1); uint32 bits = B_LENDIAN_TO_HOST_INT32(data[index]); - TRACE("BitmapBlock::_FindNext(): index: %lu, bit: %lu, mask: %lX, " - "bits: %lX\n", index, bit, mask, bits); + TRACE("BitmapBlock::_FindNext(): index: %" B_PRIu32 ", bit: %" B_PRIu32 + ", mask: %" B_PRIx32 ", bits: %" B_PRIx32 "\n", index, bit, mask, + bits); bits &= mask; if (bits == (marked ? 0 : mask) && index < fMaxIndex) { @@ -271,7 +279,7 @@ BitmapBlock::_FindNext(uint32& pos, bool marked) if (maxBit == 0) { // Not found TRACE("BitmapBlock::_FindNext(): reached end of block, " - "num bits: %lu\n", fNumBits); + "num bits: %" B_PRIu32 "\n", fNumBits); pos = fNumBits; return; } @@ -279,7 +287,7 @@ BitmapBlock::_FindNext(uint32& pos, bool marked) mask &= (1 << maxBit) - 1; if ((bits & mask) == (marked ? 0 : mask)) { TRACE("BitmapBlock::_FindNext(): reached end of block, " - "num bits: %lu\n", fNumBits); + "num bits: %" B_PRIu32 "\n", fNumBits); pos = fNumBits; return; } @@ -291,19 +299,19 @@ BitmapBlock::_FindNext(uint32& pos, bool marked) // Find the marked bit if ((bits >> bit & 1) != (marked ? 0U : 1U)) { pos = index << 5 | bit; - TRACE("BitmapBlock::_FindNext(): found bit: %lu\n", pos); + TRACE("BitmapBlock::_FindNext(): found bit: %" B_PRIu32 "\n", pos); return; } } - panic("Couldn't find bit inside an uint32 (%lx)\n", bits); + panic("Couldn't find bit inside an uint32 (%" B_PRIx32 ")\n", bits); } void BitmapBlock::FindPreviousMarked(uint32& pos) { - TRACE("BitmapBlock::FindPreviousMarked(%lu)\n", pos); + TRACE("BitmapBlock::FindPreviousMarked(%" B_PRIu32 ")\n", pos); const uint32* data = fData == NULL ? fReadOnlyData : fData; if (data == NULL) return; @@ -321,8 +329,8 @@ BitmapBlock::FindPreviousMarked(uint32& pos) uint32 bits = B_LENDIAN_TO_HOST_INT32(data[index]); bits = bits & mask; - TRACE("BitmapBlock::FindPreviousMarked(): index: %lu bit: %lu bits: %lx\n", - index, bit, bits); + TRACE("BitmapBlock::FindPreviousMarked(): index: %" B_PRIu32 " bit: %" + B_PRIu32 " bits: %" B_PRIx32 "\n", index, bit, bits); if (bits == 0) { // Find an block of 32 bits that has a marked bit @@ -340,8 +348,8 @@ BitmapBlock::FindPreviousMarked(uint32& pos) bit = 31; } - TRACE("BitmapBlock::FindPreviousMarked(): index: %lu bit: %lu bits: %lx\n", - index, bit, bits); + TRACE("BitmapBlock::FindPreviousMarked(): index: %" B_PRIu32 " bit: %" + B_PRIu32 " bits: %" B_PRIx32 "\n", index, bit, bits); for (; bit >= 0; --bit) { // Find the marked bit @@ -368,9 +376,10 @@ BitmapBlock::FindLargestUnmarkedRange(uint32& start, uint32& length) uint32 index = 0; uint32 bits = B_LENDIAN_TO_HOST_INT32(data[0]); - TRACE("BitmapBlock::FindLargestUnmarkedRange(): word span: %lu, last " - "index: %lu, start index: %lu, index: %lu, bits: %lX, start: %lu, " - "length: %lu\n", wordSpan, fMaxIndex, startIndex, index, bits, start, + TRACE("BitmapBlock::FindLargestUnmarkedRange(): word span: %" B_PRIu32 + ", last index: %" B_PRIu32 ", start index: %" B_PRIu32 ", index: %" + B_PRIu32 ", bits: %" B_PRIx32 ", start: %" B_PRIu32 ", length: %" + B_PRIu32 "\n", wordSpan, fMaxIndex, startIndex, index, bits, start, length); if (wordSpan == 0) { @@ -390,7 +399,8 @@ BitmapBlock::FindLargestUnmarkedRange(uint32& start, uint32& length) start = startPos; length = newLength; TRACE("BitmapBlock::FindLargestUnmarkedRange(): Found " - "larger length %lu starting at %lu\n", length, start); + "larger length %" B_PRIu32 " starting at %" B_PRIu32 + "\n", length, start); } startPos = endPos; @@ -442,8 +452,9 @@ BitmapBlock::FindLargestUnmarkedRange(uint32& start, uint32& length) wordSpan = length >> 5; TRACE("BitmapBlock::FindLargestUnmarkedRange(): Found " - "larger length %lu starting at %lu; word span: " - "%lu\n", length, start, wordSpan); + "larger length %" B_PRIu32 " starting at %" B_PRIu32 + "; word span: %" B_PRIu32 "\n", length, start, + wordSpan); } } @@ -458,15 +469,16 @@ BitmapBlock::FindLargestUnmarkedRange(uint32& start, uint32& length) uint32 newStart = (startIndex + 1) << 5; TRACE("BitmapBlock::FindLargestUnmarkedRange(): Possibly found a " - "larger range. index: %lu, start index: %lu, word span: %lu, " - "new length: %lu, new start: %lu\n", index, startIndex, wordSpan, + "larger range. index: %" B_PRIu32 ", start index: %" B_PRIu32 + ", word span: %" B_PRIu32 ", new length: %" B_PRIu32 + ", new start: %" B_PRIu32 "\n", index, startIndex, wordSpan, newLength, newStart); if (newStart != 0) { uint32 startBits = B_LENDIAN_TO_HOST_INT32(data[startIndex]); - TRACE("BitmapBlock::FindLargestUnmarkedRange(): start bits: %lu\n", - startBits); + TRACE("BitmapBlock::FindLargestUnmarkedRange(): start bits: %" + B_PRIu32 "\n", startBits); for (int32 bit = 31; bit >= 0; --bit) { if ((startBits >> bit & 1) != 0) @@ -477,7 +489,8 @@ BitmapBlock::FindLargestUnmarkedRange(uint32& start, uint32& length) } TRACE("BitmapBlock::FindLargestUnmarkedRange(): updated new start " - "to %lu and new length to %lu\n", newStart, newLength); + "to %" B_PRIu32 " and new length to %" B_PRIu32 "\n", newStart, + newLength); } for (int32 bit = 0; bit < 32; ++bit) { @@ -488,13 +501,14 @@ BitmapBlock::FindLargestUnmarkedRange(uint32& start, uint32& length) } TRACE("BitmapBlock::FindLargestUnmarkedRange(): updated new length to " - "%lu\n", newLength); + "%" B_PRIu32 "\n", newLength); if (newLength > length) { start = newStart; length = newLength; TRACE("BitmapBlock::FindLargestUnmarkedRange(): Found " - "largest length %lu starting at %lu\n", length, start); + "largest length %" B_PRIu32 " starting at %" B_PRIu32 "\n", + length, start); } } } diff --git a/src/add-ons/kernel/file_systems/ext2/BlockAllocator.cpp b/src/add-ons/kernel/file_systems/ext2/BlockAllocator.cpp index 934f4eaa39..bb4f85edfc 100644 --- a/src/add-ons/kernel/file_systems/ext2/BlockAllocator.cpp +++ b/src/add-ons/kernel/file_systems/ext2/BlockAllocator.cpp @@ -136,7 +136,7 @@ AllocationBlockGroup::Initialize(Volume* volume, uint32 blockGroup, fFreeBits = fGroupDescriptor->FreeBlocks(fVolume->Has64bitFeature()); fLargestLength = fFreeBits; fLargestStart = _FirstFreeBlock(); - TRACE("Group %ld is uninit\n", fBlockGroup); + TRACE("Group %" B_PRIu32 " is uninit\n", fBlockGroup); return B_OK; } @@ -146,11 +146,11 @@ AllocationBlockGroup::Initialize(Volume* volume, uint32 blockGroup, if (fGroupDescriptor->FreeBlocks(fVolume->Has64bitFeature()) != fFreeBits) { - ERROR("AllocationBlockGroup(%lu,%lld)::Initialize(): Mismatch between " - "counted free blocks (%lu/%lu) and what is set on the group " - "descriptor (%lu)\n", fBlockGroup, fBitmapBlock, fFreeBits, - fNumBits, fGroupDescriptor->FreeBlocks( - fVolume->Has64bitFeature())); + ERROR("AllocationBlockGroup(%" B_PRIu32 ",%" B_PRIu64 ")::Initialize()" + ": Mismatch between counted free blocks (%" B_PRIu32 "/%" B_PRIu32 + ") and what is set on the group descriptor (%" B_PRIu32 ")\n", + fBlockGroup, fBitmapBlock, fFreeBits, fNumBits, + fGroupDescriptor->FreeBlocks(fVolume->Has64bitFeature())); return B_BAD_DATA; } @@ -166,7 +166,7 @@ AllocationBlockGroup::Initialize(Volume* volume, uint32 blockGroup, status_t AllocationBlockGroup::_ScanFreeRanges() { - TRACE("AllocationBlockGroup::_ScanFreeRanges() for group %ld\n", + TRACE("AllocationBlockGroup::_ScanFreeRanges() for group %" B_PRIu32 "\n", fBlockGroup); BitmapBlock block(fVolume, fNumBits); @@ -206,7 +206,8 @@ AllocationBlockGroup::Allocate(Transaction& transaction, fsblock_t _start, uint32 length) { uint32 start = _start - fStart; - TRACE("AllocationBlockGroup::Allocate(%ld,%ld)\n", start, length); + TRACE("AllocationBlockGroup::Allocate(%" B_PRIu32 ",%" B_PRIu32 ")\n", + start, length); if (length == 0) return B_OK; @@ -222,13 +223,13 @@ AllocationBlockGroup::Allocate(Transaction& transaction, fsblock_t _start, if (!block.SetToWritable(transaction, fBitmapBlock)) return B_ERROR; - TRACE("AllocationBlockGroup::Allocate(): Largest range in %lu-%lu\n", - fLargestStart, fLargestStart + fLargestLength); + TRACE("AllocationBlockGroup::Allocate(): Largest range in %" B_PRIu32 "-%" + B_PRIu32 "\n", fLargestStart, fLargestStart + fLargestLength); ASSERT(block.CheckUnmarked(fLargestStart, fLargestLength)); if (!block.Mark(start, length)) { - ERROR("Failed to allocate blocks from %lu to %lu. Some were " - "already allocated.\n", start, start + length); + ERROR("Failed to allocate blocks from %" B_PRIu32 " to %" B_PRIu32 + ". Some were already allocated.\n", start, start + length); return B_ERROR; } @@ -261,8 +262,8 @@ AllocationBlockGroup::Allocate(Transaction& transaction, fsblock_t _start, return B_OK; } - TRACE("AllocationBlockGroup::Allocate(): Largest range in %lu-%lu\n", - fLargestStart, fLargestStart + fLargestLength); + TRACE("AllocationBlockGroup::Allocate(): Largest range in %" B_PRIu32 "-%" + B_PRIu32 "\n", fLargestStart, fLargestStart + fLargestLength); ASSERT(block.CheckUnmarked(fLargestStart, fLargestLength)); if (fLargestLength < fNumBits / 2) @@ -277,8 +278,8 @@ status_t AllocationBlockGroup::Free(Transaction& transaction, uint32 start, uint32 length) { - TRACE("AllocationBlockGroup::Free(): start: %lu, length %lu\n", start, - length); + TRACE("AllocationBlockGroup::Free(): start: %" B_PRIu32 ", length %" + B_PRIu32 "\n", start, length); if (length == 0) return B_OK; @@ -296,13 +297,13 @@ AllocationBlockGroup::Free(Transaction& transaction, uint32 start, if (!block.SetToWritable(transaction, fBitmapBlock)) return B_ERROR; - TRACE("AllocationBlockGroup::Free(): Largest range in %lu-%lu\n", - fLargestStart, fLargestStart + fLargestLength); + TRACE("AllocationBlockGroup::Free(): Largest range in %" B_PRIu32 "-%" + B_PRIu32 "\n", fLargestStart, fLargestStart + fLargestLength); ASSERT(block.CheckUnmarked(fLargestStart, fLargestLength)); if (!block.Unmark(start, length)) { - ERROR("Failed to free blocks from %lu to %lu. Some were " - "already freed.\n", start, start + length); + ERROR("Failed to free blocks from %" B_PRIu32 " to %" B_PRIu32 + ". Some were already freed.\n", start, start + length); return B_ERROR; } @@ -331,8 +332,8 @@ AllocationBlockGroup::Free(Transaction& transaction, uint32 start, } } - TRACE("AllocationBlockGroup::Free(): Largest range in %lu-%lu\n", - fLargestStart, fLargestStart + fLargestLength); + TRACE("AllocationBlockGroup::Free(): Largest range in %" B_PRIu32 "-%" + B_PRIu32 "\n", fLargestStart, fLargestStart + fLargestLength); ASSERT(block.CheckUnmarked(fLargestStart, fLargestLength)); fFreeBits += length; @@ -445,11 +446,11 @@ AllocationBlockGroup::_InitGroup(Transaction& transaction) if (fGroupDescriptor->FreeBlocks(fVolume->Has64bitFeature()) != fFreeBits) { - ERROR("AllocationBlockGroup(%lu,%lld)::_InitGroup(): Mismatch between " - "counted free blocks (%lu/%lu) and what is set on the group " - "descriptor (%lu)\n", fBlockGroup, fBitmapBlock, fFreeBits, - fNumBits, fGroupDescriptor->FreeBlocks( - fVolume->Has64bitFeature())); + ERROR("AllocationBlockGroup(%" B_PRIu32 ",%" B_PRIu64 ")::_InitGroup()" + ": Mismatch between counted free blocks (%" B_PRIu32 "/%" B_PRIu32 + ") and what is set on the group descriptor (%" B_PRIu32 ")\n", + fBlockGroup, fBitmapBlock, fFreeBits, fNumBits, + fGroupDescriptor->FreeBlocks(fVolume->Has64bitFeature())); return B_BAD_DATA; } @@ -561,9 +562,10 @@ BlockAllocator::Initialize() fFirstBlock = fVolume->FirstDataBlock(); fNumBlocks = fVolume->NumBlocks(); - TRACE("BlockAllocator::Initialize(): blocks per group: %lu, block groups: " - "%lu, first block: %llu, num blocks: %llu\n", fBlocksPerGroup, - fNumGroups, fFirstBlock, fNumBlocks); + TRACE("BlockAllocator::Initialize(): blocks per group: %" B_PRIu32 + ", block groups: %" B_PRIu32 ", first block: %" B_PRIu64 + ", num blocks: %" B_PRIu64 "\n", fBlocksPerGroup, fNumGroups, + fFirstBlock, fNumBlocks); fGroups = new(std::nothrow) AllocationBlockGroup[fNumGroups]; if (fGroups == NULL) @@ -597,9 +599,10 @@ BlockAllocator::AllocateBlocks(Transaction& transaction, uint32 minimum, MutexLocker lock(fLock); TRACE("BlockAllocator::AllocateBlocks(): Acquired lock\n"); - TRACE("BlockAllocator::AllocateBlocks(): transaction: %ld, min: %lu, " - "max: %lu, block group: %lu, start: %llu, num groups: %lu\n", - transaction.ID(), minimum, maximum, blockGroup, start, fNumGroups); + TRACE("BlockAllocator::AllocateBlocks(): transaction: %" B_PRId32 ", min: " + "%" B_PRIu32 ", max: %" B_PRIu32 ", block group: %" B_PRIu32 ", start:" + " %" B_PRIu64 ", num groups: %" B_PRIu32 "\n", transaction.ID(), + minimum, maximum, blockGroup, start, fNumGroups); fsblock_t bestStart = 0; uint32 bestLength = 0; @@ -612,8 +615,9 @@ BlockAllocator::AllocateBlocks(Transaction& transaction, uint32 minimum, for (int32 iterations = 0; iterations < 2; iterations++) { for (; group < last; ++group, ++groupNum) { - TRACE("BlockAllocator::AllocateBlocks(): Group %lu has largest " - "length of %lu\n", groupNum, group->LargestLength()); + TRACE("BlockAllocator::AllocateBlocks(): Group %" B_PRIu32 + " has largest length of %" B_PRIu32 "\n", groupNum, + group->LargestLength()); if (group->LargestLength() > bestLength) { if (start <= group->LargestStart()) { @@ -622,8 +626,9 @@ BlockAllocator::AllocateBlocks(Transaction& transaction, uint32 minimum, bestGroup = groupNum; TRACE("BlockAllocator::AllocateBlocks(): Found a better " - "range: block group: %lu, %llu-%llu\n", groupNum, - bestStart, bestStart + bestLength); + "range: block group: %" B_PRIu32 ", %" B_PRIu64 "-%" + B_PRIu64 "\n", groupNum, bestStart, + bestStart + bestLength); if (bestLength >= maximum) break; @@ -643,22 +648,24 @@ BlockAllocator::AllocateBlocks(Transaction& transaction, uint32 minimum, } if (bestLength < minimum) { - TRACE("BlockAllocator::AllocateBlocks(): best range (length %lu) " - "doesn't have minimum length of %lu\n", bestLength, minimum); + TRACE("BlockAllocator::AllocateBlocks(): best range (length %" B_PRIu32 + ") doesn't have minimum length of %" B_PRIu32 "\n", bestLength, + minimum); return B_DEVICE_FULL; } if (bestLength > maximum) bestLength = maximum; - TRACE("BlockAllocator::AllocateBlocks(): Selected range: block group %lu, " - "%llu-%llu\n", bestGroup, bestStart, bestStart + bestLength); + TRACE("BlockAllocator::AllocateBlocks(): Selected range: block group %" + B_PRIu32 ", %" B_PRIu64 "-%" B_PRIu64 "\n", bestGroup, bestStart, + bestStart + bestLength); status_t status = fGroups[bestGroup].Allocate(transaction, bestStart, bestLength); if (status != B_OK) { - TRACE("BlockAllocator::AllocateBlocks(): Failed to allocate %lu blocks " - "inside block group %lu.\n", bestLength, bestGroup); + TRACE("BlockAllocator::AllocateBlocks(): Failed to allocate %" B_PRIu32 + " blocks inside block group %" B_PRIu32 ".\n", bestLength, bestGroup); return status; } @@ -753,7 +760,8 @@ BlockAllocator::Allocate(Transaction& transaction, Inode* inode, status_t BlockAllocator::Free(Transaction& transaction, fsblock_t start, uint32 length) { - TRACE("BlockAllocator::Free(%llu, %lu)\n", start, length); + TRACE("BlockAllocator::Free(%" B_PRIu64 ", %" B_PRIu32 ")\n", start, + length); MutexLocker lock(fLock); if (start <= fFirstBlock) { @@ -766,16 +774,16 @@ BlockAllocator::Free(Transaction& transaction, fsblock_t start, uint32 length) if (start > fNumBlocks || length > fNumBlocks) return B_BAD_VALUE; - TRACE("BlockAllocator::Free(): first block: %llu, blocks per group: %lu\n", - fFirstBlock, fBlocksPerGroup); + TRACE("BlockAllocator::Free(): first block: %" B_PRIu64 + ", blocks per group: %" B_PRIu32 "\n", fFirstBlock, fBlocksPerGroup); start -= fFirstBlock; off_t end = start + length - 1; uint32 group = start / fBlocksPerGroup; if (group >= fNumGroups) { - panic("BlockAllocator::Free() group %ld too big (fNumGroups %ld)\n", - group, fNumGroups); + panic("BlockAllocator::Free() group %" B_PRIu32 " too big (fNumGroups " + "%" B_PRIu32 ")\n", group, fNumGroups); } uint32 lastGroup = end / fBlocksPerGroup; start = start % fBlocksPerGroup; @@ -783,7 +791,8 @@ BlockAllocator::Free(Transaction& transaction, fsblock_t start, uint32 length) if (group == lastGroup) return fGroups[group].Free(transaction, start, length); - TRACE("BlockAllocator::Free(): Freeing from group %lu: %llu, %llu\n", group, + TRACE("BlockAllocator::Free(): Freeing from group %" B_PRIu32 ": %" + B_PRIu64 ", %" B_PRIu64 "\n", group, start, fGroups[group].NumBits() - start); status_t status = fGroups[group].Free(transaction, start, @@ -792,14 +801,15 @@ BlockAllocator::Free(Transaction& transaction, fsblock_t start, uint32 length) return status; for (++group; group < lastGroup; ++group) { - TRACE("BlockAllocator::Free(): Freeing all from group %lu\n", group); + TRACE("BlockAllocator::Free(): Freeing all from group %" B_PRIu32 "\n", + group); status = fGroups[group].FreeAll(transaction); if (status != B_OK) return status; } - TRACE("BlockAllocator::Free(): Freeing from group %lu: 0-%llu \n", group, - end % fBlocksPerGroup); + TRACE("BlockAllocator::Free(): Freeing from group %" B_PRIu32 ": 0-%" + B_PRIu64 " \n", group, end % fBlocksPerGroup); return fGroups[group].Free(transaction, 0, (end + 1) % fBlocksPerGroup); } @@ -815,7 +825,8 @@ BlockAllocator::_Initialize(BlockAllocator* allocator) uint32 numGroups = allocator->fNumGroups - 1; off_t freeBlocks = 0; - TRACE("BlockAllocator::_Initialize(): free blocks: %llu\n", freeBlocks); + TRACE("BlockAllocator::_Initialize(): free blocks: %" B_PRIdOFF "\n", + freeBlocks); for (uint32 i = 0; i < numGroups; ++i) { status_t status = groups[i].Initialize(volume, i, @@ -826,7 +837,8 @@ BlockAllocator::_Initialize(BlockAllocator* allocator) } freeBlocks += groups[i].FreeBits(); - TRACE("BlockAllocator::_Initialize(): free blocks: %llu\n", freeBlocks); + TRACE("BlockAllocator::_Initialize(): free blocks: %" B_PRIdOFF "\n", + freeBlocks); } // Last block group may have less blocks @@ -840,13 +852,15 @@ BlockAllocator::_Initialize(BlockAllocator* allocator) freeBlocks += groups[numGroups].FreeBits(); - TRACE("BlockAllocator::_Initialize(): free blocks: %llu\n", freeBlocks); + TRACE("BlockAllocator::_Initialize(): free blocks: %" B_PRIdOFF "\n", + freeBlocks); mutex_unlock(&allocator->fLock); if (freeBlocks != volume->NumFreeBlocks()) { - TRACE("Counted free blocks (%llu) doesn't match value in the " - "superblock (%llu).\n", freeBlocks, volume->NumFreeBlocks()); + TRACE("Counted free blocks (%" B_PRIdOFF ") doesn't match value in the" + " superblock (%" B_PRIdOFF ").\n", freeBlocks, + volume->NumFreeBlocks()); return B_BAD_DATA; } diff --git a/src/add-ons/kernel/file_systems/ext2/DataStream.cpp b/src/add-ons/kernel/file_systems/ext2/DataStream.cpp index 6a28b87715..54ed139f56 100644 --- a/src/add-ons/kernel/file_systems/ext2/DataStream.cpp +++ b/src/add-ons/kernel/file_systems/ext2/DataStream.cpp @@ -170,8 +170,8 @@ DataStream::FindBlock(off_t offset, fsblock_t& block, uint32 *_count) return B_ERROR; } - TRACE("inode %Ld: FindBlock(offset %lld): %lld %ld\n", ID(), offset, block, - _count != NULL ? *_count : 1); + TRACE("FindBlock(offset %" B_PRIdOFF "): %" B_PRIu64" %" B_PRIu32 "\n", offset, + block, _count != NULL ? *_count : 1); return B_OK; } @@ -179,8 +179,8 @@ DataStream::FindBlock(off_t offset, fsblock_t& block, uint32 *_count) status_t DataStream::Enlarge(Transaction& transaction, off_t& numBlocks) { - TRACE("DataStream::Enlarge(): current size: %llu, target size: %llu\n", - fNumBlocks, numBlocks); + TRACE("DataStream::Enlarge(): current size: %" B_PRIdOFF ", target size: %" + B_PRIdOFF "\n", fNumBlocks, numBlocks); off_t targetBlocks = numBlocks; fWaiting = _BlocksNeeded(numBlocks); @@ -196,15 +196,15 @@ DataStream::Enlarge(Transaction& transaction, off_t& numBlocks) return status; } - TRACE("DataStream::Enlarge(): current size: %llu, target size: %llu\n", - fNumBlocks, targetBlocks); + TRACE("DataStream::Enlarge(): current size: %" B_PRIdOFF + ", target size: %" B_PRIdOFF "\n", fNumBlocks, targetBlocks); if (fNumBlocks == targetBlocks) return B_OK; } - TRACE("DataStream::Enlarge(): indirect current size: %llu, target size: %llu\n", - fNumBlocks, targetBlocks); + TRACE("DataStream::Enlarge(): indirect current size: %" B_PRIdOFF + ", target size: %" B_PRIdOFF "\n", fNumBlocks, targetBlocks); if (fNumBlocks <= kMaxIndirect) { status = _AddForIndirectBlock(transaction, targetBlocks); @@ -214,15 +214,15 @@ DataStream::Enlarge(Transaction& transaction, off_t& numBlocks) return status; } - TRACE("DataStream::Enlarge(): current size: %llu, target size: %llu\n", - fNumBlocks, targetBlocks); + TRACE("DataStream::Enlarge(): current size: %" B_PRIdOFF + ", target size: %" B_PRIdOFF "\n", fNumBlocks, targetBlocks); if (fNumBlocks == targetBlocks) return B_OK; } - TRACE("DataStream::Enlarge(): indirect2 current size: %llu, target size: %llu\n", - fNumBlocks, targetBlocks); + TRACE("DataStream::Enlarge(): indirect2 current size: %" B_PRIdOFF + ", target size: %" B_PRIdOFF "\n", fNumBlocks, targetBlocks); if (fNumBlocks <= kMaxDoubleIndirect) { status = _AddForDoubleIndirectBlock(transaction, targetBlocks); @@ -232,18 +232,18 @@ DataStream::Enlarge(Transaction& transaction, off_t& numBlocks) return status; } - TRACE("DataStream::Enlarge(): current size: %llu, target size: %llu\n", - fNumBlocks, targetBlocks); + TRACE("DataStream::Enlarge(): current size: %" B_PRIdOFF + ", target size: %" B_PRIdOFF "\n", fNumBlocks, targetBlocks); if (fNumBlocks == targetBlocks) return B_OK; } - TRACE("DataStream::Enlarge(): indirect3 current size: %llu, target size: %llu\n", - fNumBlocks, targetBlocks); + TRACE("DataStream::Enlarge(): indirect3 current size: %" B_PRIdOFF + ", target size: %" B_PRIdOFF "\n", fNumBlocks, targetBlocks); - TRACE("DataStream::Enlarge(): allocated: %lu, waiting: %lu\n", fAllocated, - fWaiting); + TRACE("DataStream::Enlarge(): allocated: %" B_PRIu32 ", waiting: %" + B_PRIu32 "\n", fAllocated, fWaiting); return _AddForTripleIndirectBlock(transaction, targetBlocks); } @@ -252,8 +252,8 @@ DataStream::Enlarge(Transaction& transaction, off_t& numBlocks) status_t DataStream::Shrink(Transaction& transaction, off_t& numBlocks) { - TRACE("DataStream::Shrink(): current size: %llu, target size: %llu\n", - fNumBlocks, numBlocks); + TRACE("DataStream::Shrink(): current size: %" B_PRIdOFF ", target size: %" + B_PRIdOFF "\n", fNumBlocks, numBlocks); fFreeStart = 0; fFreeCount = 0; @@ -329,7 +329,7 @@ DataStream::Shrink(Transaction& transaction, off_t& numBlocks) uint32 DataStream::_BlocksNeeded(off_t numBlocks) { - TRACE("DataStream::BlocksNeeded(): num blocks %llu\n", numBlocks); + TRACE("DataStream::BlocksNeeded(): num blocks %" B_PRIdOFF "\n", numBlocks); off_t blocksNeeded = 0; if (numBlocks > fNumBlocks) { @@ -363,7 +363,7 @@ DataStream::_BlocksNeeded(off_t numBlocks) } } - TRACE("DataStream::BlocksNeeded(): %llu\n", blocksNeeded); + TRACE("DataStream::BlocksNeeded(): %" B_PRIdOFF "\n", blocksNeeded); return blocksNeeded; } @@ -371,8 +371,8 @@ DataStream::_BlocksNeeded(off_t numBlocks) status_t DataStream::_GetBlock(Transaction& transaction, uint32& blockNum) { - TRACE("DataStream::_GetBlock(): allocated: %lu, pos: %llu, waiting: %lu\n", - fAllocated, fAllocatedPos, fWaiting); + TRACE("DataStream::_GetBlock(): allocated: %" B_PRIu32 ", pos: %" B_PRIu64 + ", waiting: %" B_PRIu32 "\n", fAllocated, fAllocatedPos, fWaiting); if (fAllocated == 0) { uint32 blockGroup = (fAllocatedPos - fFirstBlock) @@ -387,8 +387,9 @@ DataStream::_GetBlock(Transaction& transaction, uint32& blockNum) fWaiting -= fAllocated; - TRACE("DataStream::_GetBlock(): newAllocated: %lu, newpos: %llu," - "newwaiting: %lu\n", fAllocated, fAllocatedPos, fWaiting); + TRACE("DataStream::_GetBlock(): newAllocated: %" B_PRIu32 ", newpos: %" + B_PRIu64 ", newwaiting: %" B_PRIu32 "\n", fAllocated, + fAllocatedPos, fWaiting); } fAllocated--; @@ -408,7 +409,8 @@ DataStream::_PrepareBlock(Transaction& transaction, uint32* pos, if (blockNum == 0) { status_t status = _GetBlock(transaction, blockNum); if (status != B_OK) { - ERROR("DataStream::_PrepareBlock() _GetBlock() failed blockNum %ld\n", blockNum); + ERROR("DataStream::_PrepareBlock() _GetBlock() failed blockNum %" + B_PRIu32 "\n", blockNum); return status; } @@ -424,7 +426,7 @@ status_t DataStream::_AddBlocks(Transaction& transaction, uint32* block, off_t _count) { off_t count = _count; - TRACE("DataStream::_AddBlocks(): count: %llu\n", count); + TRACE("DataStream::_AddBlocks(): count: %" B_PRIdOFF "\n", count); while (count > 0) { uint32 blockNum; @@ -446,8 +448,8 @@ status_t DataStream::_AddBlocks(Transaction& transaction, uint32* block, off_t start, off_t end, int recursion) { - TRACE("DataStream::_AddBlocks(): start: %llu, end %llu, recursion: %d\n", - start, end, recursion); + TRACE("DataStream::_AddBlocks(): start: %" B_PRIdOFF ", end %" B_PRIdOFF + ", recursion: %d\n", start, end, recursion); bool clear; uint32 blockNum; @@ -477,8 +479,8 @@ DataStream::_AddBlocks(Transaction& transaction, uint32* block, off_t start, uint32 elementPos = start / elementWidth; uint32 endPos = end / elementWidth; - TRACE("DataStream::_AddBlocks(): element pos: %lu, end pos: %lu\n", - elementPos, endPos); + TRACE("DataStream::_AddBlocks(): element pos: %" B_PRIu32 ", end pos: %" + B_PRIu32 "\n", elementPos, endPos); recursion--; @@ -525,8 +527,8 @@ DataStream::_AddBlocks(Transaction& transaction, uint32* block, off_t start, status_t DataStream::_AddForDirectBlocks(Transaction& transaction, uint32 numBlocks) { - TRACE("DataStream::_AddForDirectBlocks(): current size: %llu, target size: " - "%lu\n", fNumBlocks, numBlocks); + TRACE("DataStream::_AddForDirectBlocks(): current size: %" B_PRIdOFF + ", target size: %" B_PRIu32 "\n", fNumBlocks, numBlocks); uint32* direct = &fStream->direct[fNumBlocks]; uint32 end = numBlocks > kMaxDirect ? kMaxDirect : numBlocks; @@ -537,8 +539,8 @@ DataStream::_AddForDirectBlocks(Transaction& transaction, uint32 numBlocks) status_t DataStream::_AddForIndirectBlock(Transaction& transaction, uint32 numBlocks) { - TRACE("DataStream::_AddForIndirectBlocks(): current size: %llu, target " - "size: %lu\n", fNumBlocks, numBlocks); + TRACE("DataStream::_AddForIndirectBlocks(): current size: %" B_PRIdOFF + ", target size: %" B_PRIu32 "\n", fNumBlocks, numBlocks); uint32 *indirect = &fStream->indirect; uint32 start = fNumBlocks - kMaxDirect; uint32 end = numBlocks - kMaxDirect; @@ -554,8 +556,8 @@ status_t DataStream::_AddForDoubleIndirectBlock(Transaction& transaction, uint32 numBlocks) { - TRACE("DataStream::_AddForDoubleIndirectBlock(): current size: %llu, " - "target size: %lu\n", fNumBlocks, numBlocks); + TRACE("DataStream::_AddForDoubleIndirectBlock(): current size: %" B_PRIdOFF + ", target size: %" B_PRIu32 "\n", fNumBlocks, numBlocks); uint32 *doubleIndirect = &fStream->double_indirect; uint32 start = fNumBlocks - kMaxIndirect; uint32 end = numBlocks - kMaxIndirect; @@ -571,8 +573,8 @@ status_t DataStream::_AddForTripleIndirectBlock(Transaction& transaction, uint32 numBlocks) { - TRACE("DataStream::_AddForTripleIndirectBlock(): current size: %llu, " - "target size: %lu\n", fNumBlocks, numBlocks); + TRACE("DataStream::_AddForTripleIndirectBlock(): current size: %" B_PRIdOFF + ", target size: %" B_PRIu32 "\n", fNumBlocks, numBlocks); uint32 *tripleIndirect = &fStream->triple_indirect; uint32 start = fNumBlocks - kMaxDoubleIndirect; uint32 end = numBlocks - kMaxDoubleIndirect; @@ -584,8 +586,8 @@ DataStream::_AddForTripleIndirectBlock(Transaction& transaction, status_t DataStream::_PerformFree(Transaction& transaction) { - TRACE("DataStream::_PerformFree(): start: %lu, count: %lu\n", fFreeStart, - fFreeCount); + TRACE("DataStream::_PerformFree(): start: %" B_PRIu32 ", count: %" B_PRIu32 + "\n", fFreeStart, fFreeCount); status_t status; if (fFreeCount == 0) @@ -604,9 +606,9 @@ status_t DataStream::_MarkBlockForRemoval(Transaction& transaction, uint32* block) { - TRACE("DataStream::_MarkBlockForRemoval(*(%p) = %lu): free start: %lu, " - "free count: %lu\n", block, B_LENDIAN_TO_HOST_INT32(*block), - fFreeStart, fFreeCount); + TRACE("DataStream::_MarkBlockForRemoval(*(%p) = %" B_PRIu32 + "): free start: %" B_PRIu32 ", free count: %" B_PRIu32 "\n", block, + B_LENDIAN_TO_HOST_INT32(*block), fFreeStart, fFreeCount); uint32 blockNum = B_LENDIAN_TO_HOST_INT32(*block); *block = 0; @@ -632,7 +634,7 @@ status_t DataStream::_FreeBlocks(Transaction& transaction, uint32* block, uint32 _count) { uint32 count = _count; - TRACE("DataStream::_FreeBlocks(%p, %lu)\n", block, count); + TRACE("DataStream::_FreeBlocks(%p, %" B_PRIu32 ")\n", block, count); while (count > 0) { status_t status = _MarkBlockForRemoval(transaction, block); @@ -654,8 +656,8 @@ DataStream::_FreeBlocks(Transaction& transaction, uint32* block, off_t start, off_t end, bool freeParent, int recursion) { // TODO: Designed specifically for shrinking. Perhaps make it more general? - TRACE("DataStream::_FreeBlocks(%p, %llu, %llu, %c, %d)\n", - block, start, end, freeParent ? 't' : 'f', recursion); + TRACE("DataStream::_FreeBlocks(%p, %" B_PRIdOFF ", %" B_PRIdOFF + ", %c, %d)\n", block, start, end, freeParent ? 't' : 'f', recursion); uint32 blockNum = B_LENDIAN_TO_HOST_INT32(*block); @@ -726,8 +728,8 @@ DataStream::_FreeBlocks(Transaction& transaction, uint32* block, off_t start, status_t DataStream::_RemoveFromDirectBlocks(Transaction& transaction, uint32 numBlocks) { - TRACE("DataStream::_RemoveFromDirectBlocks(): current size: %llu, " - "target size: %lu\n", fNumBlocks, numBlocks); + TRACE("DataStream::_RemoveFromDirectBlocks(): current size: %" B_PRIdOFF + ", target size: %" B_PRIu32 "\n", fNumBlocks, numBlocks); uint32* direct = &fStream->direct[numBlocks]; off_t end = fNumBlocks > kMaxDirect ? kMaxDirect : fNumBlocks; @@ -738,8 +740,8 @@ DataStream::_RemoveFromDirectBlocks(Transaction& transaction, uint32 numBlocks) status_t DataStream::_RemoveFromIndirectBlock(Transaction& transaction, uint32 numBlocks) { - TRACE("DataStream::_RemoveFromIndirectBlock(): current size: %llu, " - "target size: %lu\n", fNumBlocks, numBlocks); + TRACE("DataStream::_RemoveFromIndirectBlock(): current size: %" B_PRIdOFF + ", target size: %" B_PRIu32 "\n", fNumBlocks, numBlocks); uint32* indirect = &fStream->indirect; off_t start = numBlocks <= kMaxDirect ? 0 : numBlocks - kMaxDirect; off_t end = fNumBlocks - kMaxDirect; @@ -757,8 +759,8 @@ status_t DataStream::_RemoveFromDoubleIndirectBlock(Transaction& transaction, uint32 numBlocks) { - TRACE("DataStream::_RemoveFromDoubleIndirectBlock(): current size: %llu, " - "target size: %lu\n", fNumBlocks, numBlocks); + TRACE("DataStream::_RemoveFromDoubleIndirectBlock(): current size: %" B_PRIdOFF + ", target size: %" B_PRIu32 "\n", fNumBlocks, numBlocks); uint32* doubleIndirect = &fStream->double_indirect; off_t start = numBlocks <= kMaxIndirect ? 0 : numBlocks - kMaxIndirect; off_t end = fNumBlocks - kMaxIndirect; @@ -776,8 +778,8 @@ status_t DataStream::_RemoveFromTripleIndirectBlock(Transaction& transaction, uint32 numBlocks) { - TRACE("DataStream::_RemoveFromTripleIndirectBlock(): current size: %llu, " - "target size: %lu\n", fNumBlocks, numBlocks); + TRACE("DataStream::_RemoveFromTripleIndirectBlock(): current size: %" B_PRIdOFF + ", target size: %" B_PRIu32 "\n", fNumBlocks, numBlocks); uint32* tripleIndirect = &fStream->triple_indirect; off_t start = numBlocks <= kMaxDoubleIndirect ? 0 : numBlocks - kMaxDoubleIndirect; diff --git a/src/add-ons/kernel/file_systems/ext2/DirectoryIterator.cpp b/src/add-ons/kernel/file_systems/ext2/DirectoryIterator.cpp index 4082367928..a1e4eb312e 100644 --- a/src/add-ons/kernel/file_systems/ext2/DirectoryIterator.cpp +++ b/src/add-ons/kernel/file_systems/ext2/DirectoryIterator.cpp @@ -56,8 +56,8 @@ DirectoryIterator::DirectoryIterator(Inode* directory, off_t start, fStartLogicalBlock(fLogicalBlock), fStartDisplacement(fDisplacement) { - TRACE("DirectoryIterator::DirectoryIterator() %lld: num blocks: %lu\n", - fDirectory->ID(), fNumBlocks); + TRACE("DirectoryIterator::DirectoryIterator() %" B_PRIdINO ": num blocks: " + "%" B_PRIu32 "\n", fDirectory->ID(), fNumBlocks); fIndexing = parent != NULL; fInitStatus = fDirectory->FindBlock(start, fPhysicalBlock); fStartPhysicalBlock = fPhysicalBlock; @@ -83,7 +83,7 @@ DirectoryIterator::InitCheck() status_t DirectoryIterator::Get(char* name, size_t* _nameLength, ino_t* _id) { - TRACE("DirectoryIterator::Get() ID %lld\n", fDirectory->ID()); + TRACE("DirectoryIterator::Get() ID %" B_PRIdINO "\n", fDirectory->ID()); if (_Offset() >= fDirectory->Size()) { TRACE("DirectoryIterator::Get() out of entries\n"); return B_ENTRY_NOT_FOUND; @@ -94,7 +94,8 @@ DirectoryIterator::Get(char* name, size_t* _nameLength, ino_t* _id) if (block == NULL) return B_IO_ERROR; - TRACE("DirectoryIterator::Get(): Displacement: %lu\n", fDisplacement); + TRACE("DirectoryIterator::Get(): Displacement: %" B_PRIu32 "\n", + fDisplacement); const ext2_dir_entry* entry = (const ext2_dir_entry*)&block[fDisplacement]; if (entry->Length() == 0 || entry->InodeID() == 0) @@ -103,9 +104,10 @@ DirectoryIterator::Get(char* name, size_t* _nameLength, ino_t* _id) if (entry->NameLength() != 0) { size_t length = entry->NameLength(); - TRACE("block %lu, displacement %lu: entry ino %lu, length %u, " - "name length %lu, type %u\n", fLogicalBlock, fDisplacement, - entry->InodeID(), entry->Length(), length, entry->FileType()); + TRACE("block %" B_PRIu32 ", displacement %" B_PRIu32 ": entry ino %" + B_PRIu32 ", length %u, name length %" B_PRIuSIZE ", type %u\n", + fLogicalBlock, fDisplacement, entry->InodeID(), entry->Length(), + length, entry->FileType()); if (*_nameLength > 0) { if (length + 1 > *_nameLength) @@ -141,7 +143,8 @@ DirectoryIterator::GetNext(char* name, size_t* _nameLength, ino_t* _id) status_t DirectoryIterator::Next() { - TRACE("DirectoryIterator::Next() fDirectory->ID() %lld\n", fDirectory->ID()); + TRACE("DirectoryIterator::Next() fDirectory->ID() %" B_PRIdINO "\n", + fDirectory->ID()); if (_Offset() >= fDirectory->Size()) { TRACE("DirectoryIterator::Next() out of entries\n"); @@ -161,8 +164,9 @@ DirectoryIterator::Next() entry = (ext2_dir_entry*)(block + fDisplacement); do { - TRACE("Checking entry at block %llu, displacement %lu entry inodeid %ld\n", fPhysicalBlock, - fDisplacement, entry->InodeID()); + TRACE("Checking entry at block %" B_PRIu64 ", displacement %" B_PRIu32 + " entry inodeid %" B_PRIu32 "\n", fPhysicalBlock, fDisplacement, + entry->InodeID()); if (entry->Length() != 0) { if (!entry->IsValid()) { @@ -183,7 +187,7 @@ DirectoryIterator::Next() if (status != B_OK) return status; - if (_Offset() + ext2_dir_entry::MinimumSize() + if ((off_t)(_Offset() + ext2_dir_entry::MinimumSize()) >= fDirectory->Size()) { TRACE("DirectoryIterator::Next() end of directory file\n"); return B_ENTRY_NOT_FOUND; @@ -203,7 +207,8 @@ DirectoryIterator::Next() entry = (ext2_dir_entry*)(block + fDisplacement); - TRACE("DirectoryIterator::Next() skipping entry %d %ld\n", entry->Length(), entry->InodeID()); + TRACE("DirectoryIterator::Next() skipping entry %d %" B_PRIu32 "\n", + entry->Length(), entry->InodeID()); } while (entry->Length() == 0 || entry->InodeID() == 0); TRACE("DirectoryIterator::Next() entry->Length() %d entry->name %*s\n", @@ -228,7 +233,8 @@ void DirectoryIterator::Restart() { TRACE("DirectoryIterator::Restart(): (logical, physical, displacement): " - "current: (%lu, %llu, %lu), start: (%lu, %llu, %lu)\n", fLogicalBlock, + "current: (%" B_PRIu32 ", %" B_PRIu64 ", %" B_PRIu32 "), start: (%" + B_PRIu32 ", %" B_PRIu64 ", %" B_PRIu32 ")\n", fLogicalBlock, fPhysicalBlock, fDisplacement, fStartLogicalBlock, fStartPhysicalBlock, fStartDisplacement); fLogicalBlock = fStartLogicalBlock; @@ -365,7 +371,8 @@ DirectoryIterator::RemoveEntry(Transaction& transaction) return B_OK; } - TRACE("DirectoryIterator::RemoveEntry() fDisplacement %ld\n", fDisplacement); + TRACE("DirectoryIterator::RemoveEntry() fDisplacement %" B_PRIu32 "\n", + fDisplacement); if (fPreviousDisplacement == fDisplacement) { char buffer[EXT2_NAME_LENGTH + 1]; @@ -471,8 +478,9 @@ DirectoryIterator::_AddEntry(Transaction& transaction, const char* name, uint8 nameLength, ino_t id, uint8 type, uint16 newLength, uint16 pos, bool hasPrevious) { - TRACE("DirectoryIterator::_AddEntry(%s, %d, %llu, %d, %d, %d, %c)\n", - name, nameLength, id, type, newLength, pos, hasPrevious ? 't' : 'f'); + TRACE("DirectoryIterator::_AddEntry(%s, %d, %" B_PRIdINO ", %d, %d, %d, " + "%c)\n", name, nameLength, id, type, newLength, pos, + hasPrevious ? 't' : 'f'); CachedBlock cached(fVolume); uint8* block = cached.SetToWritable(transaction, fPhysicalBlock); @@ -507,8 +515,8 @@ DirectoryIterator::_SplitIndexedBlock(Transaction& transaction, uint32 newBlocksPos, bool firstSplit) { // Block is full, split required - TRACE("DirectoryIterator::_SplitIndexedBlock(.., %s, %u, %llu, %lu, %c)\n", - name, nameLength, id, newBlocksPos, + TRACE("DirectoryIterator::_SplitIndexedBlock(.., %s, %u, %" B_PRIdINO ", %" + B_PRIu32 ", %c)\n", name, nameLength, id, newBlocksPos, firstSplit ? 't' : 'f'); // Allocate a buffer for the entries in the block @@ -598,14 +606,14 @@ DirectoryIterator::_SplitIndexedBlock(Transaction& transaction, TRACE("DirectoryIterator::_SplitIndexedBlock(): pos: %p, name " "length: %u, entry length: %u\n", entry.position, - (unsigned int)dirEntry->name_length, - (unsigned int)dirEntry->Length()); + dirEntry->name_length, + dirEntry->Length()); char cbuffer[256]; memcpy(cbuffer, dirEntry->name, dirEntry->name_length); cbuffer[dirEntry->name_length] = '\0'; entry.hash = htree.Hash(dirEntry->name, dirEntry->name_length); - TRACE("DirectoryIterator::_SplitIndexedBlock(): %s -> %lu\n", + TRACE("DirectoryIterator::_SplitIndexedBlock(): %s -> %" B_PRIu32 "\n", cbuffer, entry.hash); status = entrySet.Insert(entry); @@ -630,7 +638,7 @@ DirectoryIterator::_SplitIndexedBlock(Transaction& transaction, entry.position = (uint8*)&newEntry; entry.hash = htree.Hash(name, nameLength); - TRACE("DirectoryIterator::_SplitIndexedBlock(): %s -> %lu\n", + TRACE("DirectoryIterator::_SplitIndexedBlock(): %s -> %" B_PRIu32 "\n", name, entry.hash); entrySet.Insert(entry); @@ -639,8 +647,8 @@ DirectoryIterator::_SplitIndexedBlock(Transaction& transaction, VectorSet::Iterator iterator = entrySet.Begin(); int32 median = entrySet.Count() / 2; displacement = 0; - TRACE("DirectoryIterator::_SplitIndexedBlock(): Count: %ld, median: %ld\n", - entrySet.Count(), median); + TRACE("DirectoryIterator::_SplitIndexedBlock(): Count: %" B_PRId32 + ", median: %" B_PRId32 "\n", entrySet.Count(), median); uint32 previousHash = (*iterator).hash; diff --git a/src/add-ons/kernel/file_systems/ext2/ExtentStream.cpp b/src/add-ons/kernel/file_systems/ext2/ExtentStream.cpp index 491ff15f07..6bf7ff62f9 100644 --- a/src/add-ons/kernel/file_systems/ext2/ExtentStream.cpp +++ b/src/add-ons/kernel/file_systems/ext2/ExtentStream.cpp @@ -49,7 +49,7 @@ status_t ExtentStream::FindBlock(off_t offset, fsblock_t& block, uint32 *_count) { fileblock_t index = offset >> fVolume->BlockShift(); - TRACE("FindBlock(%lld, %lld)\n", offset, index); + TRACE("FindBlock(%" B_PRIdOFF ", %" B_PRIu64 ")\n", offset, index); if (offset >= fSize) { TRACE("FindBlock: offset larger than inode size\n"); @@ -69,8 +69,8 @@ ExtentStream::FindBlock(off_t offset, fsblock_t& block, uint32 *_count) && stream->extent_index[i].LogicalBlock() <= index) { i++; } - TRACE("FindBlock() getting index %ld at %lld\n", i - 1, - stream->extent_index[i - 1].PhysicalBlock()); + TRACE("FindBlock() getting index %" B_PRId32 " at %" B_PRIu64 "\n", + i - 1, stream->extent_index[i - 1].PhysicalBlock()); stream = (ext2_extent_stream *)cached.SetTo( stream->extent_index[i - 1].PhysicalBlock()); if (!stream->extent_header.IsValid()) @@ -97,8 +97,8 @@ ExtentStream::FindBlock(off_t offset, fsblock_t& block, uint32 *_count) - stream->extent_entries[middle].LogicalBlock(); if (diff > stream->extent_entries[middle].Length()) { // sparse block - TRACE("FindBlock() sparse block index %lld at %ld\n", index, - stream->extent_entries[middle].LogicalBlock()); + TRACE("FindBlock() sparse block index %" B_PRIu64 " at %" B_PRIu32 + "\n", index, stream->extent_entries[middle].LogicalBlock()); block = 0xffffffff; return B_OK; } @@ -106,16 +106,16 @@ ExtentStream::FindBlock(off_t offset, fsblock_t& block, uint32 *_count) block = stream->extent_entries[middle].PhysicalBlock() + diff; if (_count) *_count = stream->extent_entries[middle].Length() - diff; - TRACE("FindBlock(offset %lld): %lld %ld\n", offset, - block, _count != NULL ? *_count : 1); + TRACE("FindBlock(offset %" B_PRIdOFF "): %" B_PRIu64 " %" B_PRIu32 + "\n", offset, block, _count != NULL ? *_count : 1); return B_OK; } for (int32 i = 0; i < stream->extent_header.NumEntries(); i++) { if (stream->extent_entries[i].LogicalBlock() > index) { // sparse block - TRACE("FindBlock() sparse block index %lld at %ld\n", index, - stream->extent_entries[i].LogicalBlock()); + TRACE("FindBlock() sparse block index %" B_PRIu64 " at %" B_PRIu32 + "\n", index, stream->extent_entries[i].LogicalBlock()); block = 0xffffffff; return B_OK; } @@ -124,8 +124,8 @@ ExtentStream::FindBlock(off_t offset, fsblock_t& block, uint32 *_count) block = stream->extent_entries[i].PhysicalBlock() + diff; if (_count) *_count = stream->extent_entries[i].Length() - diff; - TRACE("FindBlock(offset %lld): %lld %ld\n", offset, - block, _count != NULL ? *_count : 1); + TRACE("FindBlock(offset %" B_PRIdOFF "): %" B_PRIu64 " %" B_PRIu32 + "\n", offset, block, _count != NULL ? *_count : 1); return B_OK; } } @@ -137,8 +137,8 @@ ExtentStream::FindBlock(off_t offset, fsblock_t& block, uint32 *_count) status_t ExtentStream::Enlarge(Transaction& transaction, off_t& numBlocks) { - TRACE("Enlarge(): current size: %llu, target size: %llu\n", - fNumBlocks, numBlocks); + TRACE("Enlarge(): current size: %" B_PRIdOFF ", target size: %" B_PRIdOFF + "\n", fNumBlocks, numBlocks); off_t targetBlocks = numBlocks; numBlocks = targetBlocks - fNumBlocks; @@ -172,8 +172,8 @@ ExtentStream::Enlarge(Transaction& transaction, off_t& numBlocks) panic("stream->extent_header.NumEntries() == 0\n"); int32 lastIndex = stream->extent_header.NumEntries() - 1; TRACE("Enlarge() depth %d\n", stream->extent_header.Depth()); - TRACE("Enlarge() getting index %ld at %lld\n", lastIndex, - stream->extent_index[lastIndex].PhysicalBlock()); + TRACE("Enlarge() getting index %" B_PRId32 " at %" B_PRIu64 "\n", + lastIndex, stream->extent_index[lastIndex].PhysicalBlock()); path[++level] = stream->extent_index[lastIndex].PhysicalBlock(); stream = (ext2_extent_stream *)cached.SetTo(path[level]); if (stream == NULL) @@ -184,7 +184,7 @@ ExtentStream::Enlarge(Transaction& transaction, off_t& numBlocks) if (stream->extent_header.NumEntries() > 0) { ext2_extent_entry &last = stream->extent_entries[ stream->extent_header.NumEntries() - 1]; - TRACE("Enlarge() last %lld allocatedPos %lld\n", + TRACE("Enlarge() last %" B_PRIu64 " allocatedPos %" B_PRIu64 "\n", last.PhysicalBlock() + last.Length(), fAllocatedPos); if (last.PhysicalBlock() + last.Length() == fAllocatedPos && (last.Length() + allocated) <= EXT2_EXTENT_MAX_LENGTH) { @@ -205,8 +205,8 @@ ExtentStream::Enlarge(Transaction& transaction, off_t& numBlocks) if (stream->extent_header.NumEntries() >= stream->extent_header.MaxEntries()) { - TRACE("Enlarge() adding leaf and indexes at depth %d level %ld\n", - stream->extent_header.Depth(), level); + TRACE("Enlarge() adding leaf and indexes at depth %d level %" + B_PRId32 "\n", stream->extent_header.Depth(), level); // try to add a leaf and indexes while (--level >= 0) { stream = (ext2_extent_stream *)cached.SetTo(path[level]); @@ -216,7 +216,7 @@ ExtentStream::Enlarge(Transaction& transaction, off_t& numBlocks) < stream->extent_header.MaxEntries()) { break; } - TRACE("Enlarge() going up from level %ld\n", level); + TRACE("Enlarge() going up from level %" B_PRId32 "\n", level); } if (level < 0 && fStream->extent_header.NumEntries() @@ -231,7 +231,8 @@ ExtentStream::Enlarge(Transaction& transaction, off_t& numBlocks) return status; } ASSERT(_CheckBlock(fStream, newBlock) == B_OK); - TRACE("Enlarge() move root to block %lld\n", newBlock); + TRACE("Enlarge() move root to block %" B_PRIu64 "\n", + newBlock); numBlocks++; stream = (ext2_extent_stream *)cached.SetToWritable( transaction, newBlock); @@ -277,7 +278,7 @@ ExtentStream::Enlarge(Transaction& transaction, off_t& numBlocks) path[level++] = newBlock; depth = stream->extent_header.Depth() - 1; - TRACE("Enlarge() init index block %lld at depth %d\n", + TRACE("Enlarge() init index block %" B_PRIu64 " at depth %d\n", newBlock, depth); stream = (ext2_extent_stream *)cached.SetToWritable( transaction, newBlock); @@ -293,12 +294,12 @@ ExtentStream::Enlarge(Transaction& transaction, off_t& numBlocks) ASSERT(Check()); } - TRACE("Enlarge() depth %d level %ld\n", + TRACE("Enlarge() depth %d level %" B_PRId32 "\n", stream->extent_header.Depth(), level); if (stream->extent_header.Depth() == 1) { - TRACE("Enlarge() adding an entry block at depth %d level %ld\n", - depth, level); + TRACE("Enlarge() adding an entry block at depth %d level %" + B_PRId32 "\n", depth, level); fsblock_t newBlock; if (level >= 0) newBlock = path[level]; @@ -319,8 +320,8 @@ ExtentStream::Enlarge(Transaction& transaction, off_t& numBlocks) stream->extent_index[index].SetPhysicalBlock(newBlock); stream->extent_header.SetNumEntries(index + 1); - TRACE("Enlarge() init entry block %lld at depth %d\n", - newBlock, depth); + TRACE("Enlarge() init entry block %" B_PRIu64 + " at depth %d\n", newBlock, depth); stream = (ext2_extent_stream *)cached.SetToWritable( transaction, newBlock); if (stream == NULL) @@ -336,7 +337,7 @@ ExtentStream::Enlarge(Transaction& transaction, off_t& numBlocks) } // add a new entry - TRACE("Enlarge() add entry %lld\n", fAllocatedPos); + TRACE("Enlarge() add entry %" B_PRIu64 "\n", fAllocatedPos); if (stream != fStream) { stream = (ext2_extent_stream *)cached.SetToWritable( transaction, cached.BlockNumber()); @@ -348,7 +349,7 @@ ExtentStream::Enlarge(Transaction& transaction, off_t& numBlocks) stream->extent_entries[index].SetLength(allocated); stream->extent_entries[index].SetPhysicalBlock(fAllocatedPos); stream->extent_header.SetNumEntries(index + 1); - TRACE("Enlarge() entry added at index %ld\n", index); + TRACE("Enlarge() entry added at index %" B_PRId32 "\n", index); ASSERT(stream->extent_header.IsValid()); fNumBlocks += allocated; @@ -362,8 +363,8 @@ ExtentStream::Enlarge(Transaction& transaction, off_t& numBlocks) status_t ExtentStream::Shrink(Transaction& transaction, off_t& numBlocks) { - TRACE("DataStream::Shrink(): current size: %llu, target size: %llu\n", - fNumBlocks, numBlocks); + TRACE("DataStream::Shrink(): current size: %" B_PRIdOFF ", target size: %" + B_PRIdOFF "\n", fNumBlocks, numBlocks); off_t targetBlocks = numBlocks; numBlocks = fNumBlocks - targetBlocks; @@ -380,8 +381,8 @@ ExtentStream::Shrink(Transaction& transaction, off_t& numBlocks) panic("stream->extent_header.NumEntries() == 0\n"); int32 lastIndex = stream->extent_header.NumEntries() - 1; TRACE("Shrink() depth %d\n", stream->extent_header.Depth()); - TRACE("Shrink() getting index %ld at %lld\n", lastIndex, - stream->extent_index[lastIndex].PhysicalBlock()); + TRACE("Shrink() getting index %" B_PRId32 " at %" B_PRIu64 "\n", + lastIndex, stream->extent_index[lastIndex].PhysicalBlock()); path[++level] = stream->extent_index[lastIndex].PhysicalBlock(); stream = (ext2_extent_stream *)cached.SetToWritable(transaction, path[level]); @@ -401,19 +402,20 @@ ExtentStream::Shrink(Transaction& transaction, off_t& numBlocks) } uint16 length = min_c(last.Length(), fNumBlocks - targetBlocks); fsblock_t block = last.PhysicalBlock() + last.Length() - length; - TRACE("Shrink() free block %lld length %d\n", block, length); + TRACE("Shrink() free block %" B_PRIu64 " length %d\n", block, + length); status = fVolume->FreeBlocks(transaction, block, length); if (status != B_OK) break; fNumBlocks -= length; stream->extent_entries[index].SetLength(last.Length() - length); - TRACE("Shrink() new length for %ld: %d\n", index, last.Length()); + TRACE("Shrink() new length for %" B_PRId32 ": %d\n", index, last.Length()); if (last.Length() != 0) break; index--; - TRACE("Shrink() next index: %ld\n", index); + TRACE("Shrink() next index: %" B_PRId32 "\n", index); } - TRACE("Shrink() new entry count: %ld\n", index + 1); + TRACE("Shrink() new entry count: %" B_PRId32 "\n", index + 1); stream->extent_header.SetNumEntries(index + 1); ASSERT(Check()); @@ -476,8 +478,8 @@ ExtentStream::_Check(ext2_extent_stream *stream, fileblock_t &block) for (int32 i = 0; i < stream->extent_header.NumEntries(); i++) { ext2_extent_entry &entry = stream->extent_entries[i]; if (entry.LogicalBlock() < block) { - panic("_Check() entry %ld %lld %ld\n", i, block, - entry.LogicalBlock()); + panic("_Check() entry %" B_PRId32 " %" B_PRIu64 " %" B_PRIu32 + "\n", i, block, entry.LogicalBlock()); return B_BAD_VALUE; } block = entry.LogicalBlock() + entry.Length(); @@ -489,8 +491,8 @@ ExtentStream::_Check(ext2_extent_stream *stream, fileblock_t &block) for (int32 i = 0; i < stream->extent_header.NumEntries(); i++) { ext2_extent_index &index = stream->extent_index[i]; if (index.LogicalBlock() < block) { - panic("_Check() index %ld %lld %ld\n", i, block, - index.LogicalBlock()); + panic("_Check() index %" B_PRId32 " %" B_PRIu64 " %" B_PRIu32 + "\n", i, block, index.LogicalBlock()); return B_BAD_VALUE; } ext2_extent_stream *child = (ext2_extent_stream *)cached.SetTo( @@ -519,8 +521,9 @@ ExtentStream::_CheckBlock(ext2_extent_stream *stream, fsblock_t block) ext2_extent_entry &entry = stream->extent_entries[i]; if (entry.PhysicalBlock() <= block && (entry.PhysicalBlock() + entry.Length()) > block) { - panic("_CheckBlock() entry %ld %lld %lld %d\n", i, block, - entry.PhysicalBlock(), entry.Length()); + panic("_CheckBlock() entry %" B_PRId32 " %" B_PRIu64 " %" + B_PRIu64 " %d\n", i, block, entry.PhysicalBlock(), + entry.Length()); return B_BAD_VALUE; } } @@ -531,7 +534,7 @@ ExtentStream::_CheckBlock(ext2_extent_stream *stream, fsblock_t block) for (int32 i = 0; i < stream->extent_header.NumEntries(); i++) { ext2_extent_index &index = stream->extent_index[i]; if (index.PhysicalBlock() == block) { - panic("_CheckBlock() index %ld %lld\n", i, block); + panic("_CheckBlock() index %" B_PRId32 " %" B_PRIu64 "\n", i, block); return B_BAD_VALUE; } ext2_extent_stream *child = (ext2_extent_stream *)cached.SetTo( diff --git a/src/add-ons/kernel/file_systems/ext2/HTree.cpp b/src/add-ons/kernel/file_systems/ext2/HTree.cpp index ad13fffc5f..07acc7e7fe 100644 --- a/src/add-ons/kernel/file_systems/ext2/HTree.cpp +++ b/src/add-ons/kernel/file_systems/ext2/HTree.cpp @@ -62,8 +62,8 @@ HTree::HTree(Volume* volume, Inode* directory) fHashSeed[2] = superBlock.HashSeed(2); fHashSeed[3] = superBlock.HashSeed(3); - TRACE("HTree::HTree() %lx %lx %lx %lx\n", fHashSeed[0], - fHashSeed[1], fHashSeed[2], fHashSeed[3]); + TRACE("HTree::HTree() %" B_PRIx32 " %" B_PRIx32 " %" B_PRIx32 " %" B_PRIx32 + "\n", fHashSeed[0], fHashSeed[1], fHashSeed[2], fHashSeed[3]); if (fHashSeed[0] == 0 && fHashSeed[1] == 0 && fHashSeed[2] == 0 && fHashSeed[3] == 0) { @@ -179,7 +179,7 @@ HTree::Hash(const char* name, uint8 length) hash = 0; #endif - TRACE("HTree::_Hash(): filename hash 0x%lX\n", hash); + TRACE("HTree::_Hash(): filename hash 0x%" B_PRIx32 "\n", hash); return hash & ~1; } @@ -366,7 +366,8 @@ HTree::_HashTEA(const char* name, uint8 _length) uint32 blocks[4]; _PrepareBlocksForHash(name, (uint32)length, blocks, 4); - TRACE("_HashTEA %lx %lx %lx\n", blocks[0], blocks[1], blocks[2]); + TRACE("_HashTEA %" B_PRIx32 " %" B_PRIx32 " %" B_PRIx32 "\n", + blocks[0], blocks[1], blocks[2]); _TEATransform(buffer, blocks); name += 16; diff --git a/src/add-ons/kernel/file_systems/ext2/HTreeEntryIterator.cpp b/src/add-ons/kernel/file_systems/ext2/HTreeEntryIterator.cpp index 09299f9246..8f4bf2d0a6 100644 --- a/src/add-ons/kernel/file_systems/ext2/HTreeEntryIterator.cpp +++ b/src/add-ons/kernel/file_systems/ext2/HTreeEntryIterator.cpp @@ -41,8 +41,8 @@ HTreeEntryIterator::HTreeEntryIterator(off_t offset, Inode* directory) fCurrentEntry = fFirstEntry; } - TRACE("HTreeEntryIterator::HTreeEntryIterator(): created %p, block %llu, " - "entry no. %lu, parent: %p\n", this, fBlockNum, (uint32)fCurrentEntry, + TRACE("HTreeEntryIterator::HTreeEntryIterator(): created %p, block %" B_PRIu64 ", " + "entry no. %u, parent: %p\n", this, fBlockNum, fCurrentEntry, fParent); } @@ -63,16 +63,16 @@ HTreeEntryIterator::HTreeEntryIterator(uint32 block, uint32 blockSize, // fCurrentEntry is initialized to 1 to skip the fake directory entry fInitStatus = B_OK; - TRACE("HTreeEntryIterator::HTreeEntryIterator(): created %p, block %lu, " - "parent: %p\n", this, block, fParent); + TRACE("HTreeEntryIterator::HTreeEntryIterator(): created %p, block %" + B_PRIu32 ", parent: %p\n", this, block, fParent); } status_t HTreeEntryIterator::Init() { - TRACE("HTreeEntryIterator::Init() first entry: %lu\n", - (uint32)fFirstEntry); + TRACE("HTreeEntryIterator::Init() first entry: %u\n", + fFirstEntry); if (fInitStatus != B_OK) return fInitStatus; @@ -99,15 +99,15 @@ HTreeEntryIterator::Init() } if (fLimit != fBlockSize / sizeof(HTreeEntry) - fFirstEntry) { - ERROR("HTreeEntryIterator::Init() bad fLimit %lu should be %lu " - "at block %llu\n", (uint32)fLimit, fBlockSize / sizeof(HTreeEntry) - - fFirstEntry, fBlockNum); + ERROR("HTreeEntryIterator::Init() bad fLimit %u should be %" B_PRIu32 + " at block %" B_PRIu64 "\n", fLimit, + (uint32)(fBlockSize / sizeof(HTreeEntry) - fFirstEntry), fBlockNum); fCount = fLimit = 0; return B_ERROR; } - TRACE("HTreeEntryIterator::Init() count %lu limit %lu\n", - (uint32)fCount, (uint32)fLimit); + TRACE("HTreeEntryIterator::Init() count %u limit %u\n", + fCount, fLimit); return B_OK; } @@ -149,8 +149,8 @@ HTreeEntryIterator::Lookup(uint32 hash, int indirections, HTreeEntry* end = (HTreeEntry*)block + fCount + fFirstEntry - 1; HTreeEntry* middle = start; - TRACE("HTreeEntryIterator::Lookup() current entry: %lu\n", - (uint32)fCurrentEntry); + TRACE("HTreeEntryIterator::Lookup() current entry: %u\n", + fCurrentEntry); TRACE("HTreeEntryIterator::Lookup() indirections: %d s:%p m:%p e:%p\n", indirections, start, middle, end); @@ -161,7 +161,8 @@ HTreeEntryIterator::Lookup(uint32 hash, int indirections, TRACE("HTreeEntryIterator::Lookup() indirections: %d s:%p m:%p e:%p\n", indirections, start, middle, end); - TRACE("HTreeEntryIterator::Lookup() %lx %lx\n", hash, middle->Hash()); + TRACE("HTreeEntryIterator::Lookup() %" B_PRIx32 " %" B_PRIx32 "\n", + hash, middle->Hash()); if (hash >= middle->Hash()) start = middle + 1; @@ -175,8 +176,8 @@ HTreeEntryIterator::Lookup(uint32 hash, int indirections, if (indirections == 0) { TRACE("HTreeEntryIterator::Lookup(): Creating an indexed directory " - "iterator starting at block: %lu, hash: 0x%lX\n", start->Block(), - start->Hash()); + "iterator starting at block: %" B_PRIu32 ", hash: 0x%" B_PRIx32 + "\n", start->Block(), start->Hash()); *directoryIterator = new(std::nothrow) DirectoryIterator(fDirectory, start->Block() * fBlockSize, this); @@ -188,7 +189,8 @@ HTreeEntryIterator::Lookup(uint32 hash, int indirections, } TRACE("HTreeEntryIterator::Lookup(): Creating a HTree entry iterator " - "starting at block: %lu, hash: 0x%lX\n", start->Block(), start->Hash()); + "starting at block: %" B_PRIu32 ", hash: 0x%" B_PRIx32 "\n", + start->Block(), start->Hash()); fsblock_t blockNum; status_t status = fDirectory->FindBlock(start->Block() * fBlockSize, blockNum); @@ -215,8 +217,8 @@ status_t HTreeEntryIterator::GetNext(uint32& childBlock) { fCurrentEntry++; - TRACE("HTreeEntryIterator::GetNext(): current entry: %lu count: %lu, " - "limit: %lu\n", (uint32)fCurrentEntry, (uint32)fCount, (uint32)fLimit); + TRACE("HTreeEntryIterator::GetNext(): current entry: %u count: %u, " + "limit: %u\n", fCurrentEntry, fCount, fLimit); bool endOfBlock = fCurrentEntry >= (fCount + fFirstEntry); if (endOfBlock) { @@ -231,8 +233,8 @@ HTreeEntryIterator::GetNext(uint32& childBlock) if (status != B_OK) return status; - TRACE("HTreeEntryIterator::GetNext(): moving to next block: %lu\n", - logicalBlock); + TRACE("HTreeEntryIterator::GetNext(): moving to next block: %" B_PRIx32 + "\n", logicalBlock); status = fDirectory->FindBlock(logicalBlock * fBlockSize, fBlockNum); if (status != B_OK) @@ -257,7 +259,7 @@ HTreeEntryIterator::GetNext(uint32& childBlock) if (!endOfBlock) fHasCollision = (entry[fCurrentEntry].Hash() & 1) == 1; - TRACE("HTreeEntryIterator::GetNext(): next block: %lu\n", + TRACE("HTreeEntryIterator::GetNext(): next block: %" B_PRIu32 "\n", entry->Block()); childBlock = entry->Block(); @@ -269,8 +271,8 @@ HTreeEntryIterator::GetNext(uint32& childBlock) uint32 HTreeEntryIterator::BlocksNeededForNewEntry() { - TRACE("HTreeEntryIterator::BlocksNeededForNewEntry(): block num: %llu, " - "volume: %p\n", fBlockNum, fVolume); + TRACE("HTreeEntryIterator::BlocksNeededForNewEntry(): block num: %" + B_PRIu64 ", volume: %p\n", fBlockNum, fVolume); CachedBlock cached(fVolume); const uint8* blockData = cached.SetTo(fBlockNum); @@ -305,7 +307,8 @@ status_t HTreeEntryIterator::InsertEntry(Transaction& transaction, uint32 hash, off_t blockNum, off_t newBlocksPos, bool hasCollision) { - TRACE("HTreeEntryIterator::InsertEntry(): block num: %llu\n", fBlockNum); + TRACE("HTreeEntryIterator::InsertEntry(): block num: %" B_PRIu64 "\n", + fBlockNum); CachedBlock cached(fVolume); uint8* blockData = cached.SetToWritable(transaction, fBlockNum); diff --git a/src/add-ons/kernel/file_systems/ext2/HashRevokeManager.cpp b/src/add-ons/kernel/file_systems/ext2/HashRevokeManager.cpp index 9fdaf7a887..10f3981714 100644 --- a/src/add-ons/kernel/file_systems/ext2/HashRevokeManager.cpp +++ b/src/add-ons/kernel/file_systems/ext2/HashRevokeManager.cpp @@ -134,8 +134,8 @@ HashRevokeManager::Compare(void* _revoked, const void *_block) /*static*/ uint32 HashRevokeManager::Hash(void* _revoked, const void* _block, uint32 range) { - TRACE("HashRevokeManager::Hash(): revoked: %p, block: %p, range: %lu\n", - _revoked, _block, range); + TRACE("HashRevokeManager::Hash(): revoked: %p, block: %p, range: %" + B_PRIu32 "\n", _revoked, _block, range); RevokeElement* revoked = (RevokeElement*)_revoked; if (revoked != NULL) @@ -161,8 +161,8 @@ HashRevokeManager::_ForceInsert(uint32 block, uint32 commitID) if (retValue == B_OK) { fRevokeCount++; - TRACE("HashRevokeManager::_ForceInsert(): revoke count: %lu\n", - fRevokeCount); + TRACE("HashRevokeManager::_ForceInsert(): revoke count: %" B_PRIu32 + "\n", fRevokeCount); } return retValue; diff --git a/src/add-ons/kernel/file_systems/ext2/Inode.cpp b/src/add-ons/kernel/file_systems/ext2/Inode.cpp index 6bffe52dcf..3a07a8c4c8 100644 --- a/src/add-ons/kernel/file_systems/ext2/Inode.cpp +++ b/src/add-ons/kernel/file_systems/ext2/Inode.cpp @@ -43,8 +43,8 @@ Inode::Inode(Volume* volume, ino_t id) rw_lock_init(&fLock, "ext2 inode"); recursive_lock_init(&fSmallDataLock, "ext2 inode small data"); - TRACE("Inode::Inode(): ext2_inode: %lu, disk inode: %lu\n", - sizeof(ext2_inode), fVolume->InodeSize()); + TRACE("Inode::Inode(): ext2_inode: %lu, disk inode: %" B_PRIu32 + "\n", sizeof(ext2_inode), fVolume->InodeSize()); fNodeSize = sizeof(ext2_inode) > fVolume->InodeSize() ? fVolume->InodeSize() : sizeof(ext2_inode); @@ -78,7 +78,7 @@ Inode::Inode(Volume* volume) rw_lock_init(&fLock, "ext2 inode"); recursive_lock_init(&fSmallDataLock, "ext2 inode small data"); - TRACE("Inode::Inode(): ext2_inode: %lu, disk inode: %lu\n", + TRACE("Inode::Inode(): ext2_inode: %lu, disk inode: %" B_PRIu32 "\n", sizeof(ext2_inode), fVolume->InodeSize()); fNodeSize = sizeof(ext2_inode) > fVolume->InodeSize() ? fVolume->InodeSize() : sizeof(ext2_inode); @@ -138,15 +138,16 @@ Inode::WriteBack(Transaction& transaction) if (inodeBlockData == NULL) return B_IO_ERROR; - TRACE("Inode::WriteBack(): Inode ID: %lld, inode block: %llu, data: %p, " - "index: %lu, inode size: %lu, node size: %lu, this: %p, node: %p\n", + TRACE("Inode::WriteBack(): Inode ID: %" B_PRIdINO ", inode block: %" + B_PRIdOFF ", data: %p, index: %" B_PRIu32 ", inode size: %" B_PRIu32 + ", node size: %" B_PRIu32 ", this: %p, node: %p\n", fID, blockNum, inodeBlockData, fVolume->InodeBlockIndex(fID), fVolume->InodeSize(), fNodeSize, this, &fNode); memcpy(inodeBlockData + fVolume->InodeBlockIndex(fID) * fVolume->InodeSize(), (uint8*)&fNode, fNodeSize); - TRACE("Inode::WriteBack() finished %ld\n", Node().stream.direct[0]); + TRACE("Inode::WriteBack() finished %" B_PRId32 "\n", Node().stream.direct[0]); return B_OK; } @@ -161,7 +162,7 @@ Inode::UpdateNodeFromDisk() if (status != B_OK) return status; - TRACE("inode %lld at block %llu\n", fID, blockNum); + TRACE("inode %" B_PRIdINO " at block %" B_PRIdOFF "\n", fID, blockNum); CachedBlock cached(fVolume); const uint8* inodeBlock = cached.SetTo(blockNum); @@ -169,13 +170,13 @@ Inode::UpdateNodeFromDisk() if (inodeBlock == NULL) return B_IO_ERROR; - TRACE("Inode size: %lu, inode index: %lu\n", fVolume->InodeSize(), - fVolume->InodeBlockIndex(fID)); + TRACE("Inode size: %" B_PRIu32 ", inode index: %" B_PRIu32 "\n", + fVolume->InodeSize(), fVolume->InodeBlockIndex(fID)); ext2_inode* inode = (ext2_inode*)(inodeBlock + fVolume->InodeBlockIndex(fID) * fVolume->InodeSize()); TRACE("Attempting to copy inode data from %p to %p, ext2_inode " - "size: %lu\n", inode, &fNode, fNodeSize); + "size: %" B_PRIu32 "\n", inode, &fNode, fNodeSize); memcpy(&fNode, inode, fNodeSize); @@ -244,13 +245,14 @@ Inode::ReadAt(off_t pos, uint8* buffer, size_t* _length) // set/check boundaries for pos/length if (pos < 0) { - ERROR("inode %lld: ReadAt failed(pos %lld, length %lu)\n", ID(), pos, - length); + ERROR("inode %" B_PRIdINO ": ReadAt failed(pos %" B_PRIdOFF + ", length %" B_PRIuSIZE ")\n", ID(), pos, length); return B_BAD_VALUE; } if (pos >= Size() || length == 0) { - TRACE("inode %lld: ReadAt 0 (pos %lld, length %lu)\n", ID(), pos, length); + TRACE("inode %" B_PRIdINO ": ReadAt 0 (pos %" B_PRIdOFF ", length %" + B_PRIuSIZE ")\n", ID(), pos, length); *_length = 0; return B_NO_ERROR; } @@ -263,8 +265,8 @@ status_t Inode::WriteAt(Transaction& transaction, off_t pos, const uint8* buffer, size_t* _length) { - TRACE("Inode::WriteAt(%lld, %p, *(%p) = %ld)\n", pos, buffer, - _length, *_length); + TRACE("Inode::WriteAt(%" B_PRIdOFF ", %p, *(%p) = %" B_PRIuSIZE ")\n", pos, + buffer, _length, *_length); ReadLocker readLocker(fLock); if (IsFileCacheDisabled()) @@ -296,9 +298,10 @@ Inode::WriteAt(Transaction& transaction, off_t pos, const uint8* buffer, off_t end = pos + (off_t)length; off_t oldSize = Size(); - TRACE("Inode::WriteAt(): Old size: %x:%x, new size: %x:%x\n", - (int)(oldSize >> 32), (int)(oldSize & 0xFFFFFFFF), - (int)(end >> 32), (int)(end & 0xFFFFFFFF)); + TRACE("Inode::WriteAt(): Old size: %" B_PRIdOFF ":%" B_PRIdOFF + ", new size: %" B_PRIdOFF ":%" B_PRIdOFF "\n", + oldSize >> 32, oldSize & 0xFFFFFFFF, + end >> 32, end & 0xFFFFFFFF); if (end > oldSize) { status_t status = Resize(transaction, end); @@ -326,9 +329,10 @@ Inode::WriteAt(Transaction& transaction, off_t pos, const uint8* buffer, return B_OK; } - TRACE("Inode::WriteAt(): Performing write: %p, %lld, %p, %ld\n", - FileCache(), pos, buffer, *_length); - status_t status = file_cache_write(FileCache(), NULL, pos, buffer, _length); + TRACE("Inode::WriteAt(): Performing write: %p, %" B_PRIdOFF ", %p, %" + B_PRIuSIZE "\n", FileCache(), pos, buffer, *_length); + status_t status = file_cache_write(FileCache(), NULL, pos, buffer, + _length); WriteLockInTransaction(transaction); @@ -341,7 +345,8 @@ Inode::WriteAt(Transaction& transaction, off_t pos, const uint8* buffer, status_t Inode::FillGapWithZeros(off_t start, off_t end) { - TRACE("Inode::FileGapWithZeros(%lld - %lld)\n", start, end); + TRACE("Inode::FileGapWithZeros(%" B_PRIdOFF " - %" B_PRIdOFF ")\n", start, + end); while (start < end) { size_t size; @@ -352,7 +357,8 @@ Inode::FillGapWithZeros(off_t start, off_t end) size = end - start; TRACE("Inode::FillGapWithZeros(): Calling file_cache_write(%p, NULL, " - "%lld, NULL, &(%ld) = %p)\n", fCache, start, size, &size); + "%" B_PRIdOFF ", NULL, &(%" B_PRIuSIZE ") = %p)\n", fCache, start, + size, &size); status_t status = file_cache_write(fCache, NULL, start, NULL, &size); if (status != B_OK) @@ -368,7 +374,8 @@ Inode::FillGapWithZeros(off_t start, off_t end) status_t Inode::Resize(Transaction& transaction, off_t size) { - TRACE("Inode::Resize() ID:%lld size: %lld\n", ID(), size); + TRACE("Inode::Resize() ID:%" B_PRIdINO " size: %" B_PRIdOFF "\n", ID(), + size); if (size < 0) return B_BAD_VALUE; @@ -377,7 +384,8 @@ Inode::Resize(Transaction& transaction, off_t size) if (size == oldSize) return B_OK; - TRACE("Inode::Resize(): old size: %lld, new size: %lld\n", oldSize, size); + TRACE("Inode::Resize(): old size: %" B_PRIdOFF ", new size: %" B_PRIdOFF + "\n", oldSize, size); status_t status; if (size > oldSize) { @@ -397,7 +405,8 @@ Inode::Resize(Transaction& transaction, off_t size) file_cache_set_size(FileCache(), size); file_map_set_size(Map(), size); - TRACE("Inode::Resize(): Writing back inode changes. Size: %lld\n", Size()); + TRACE("Inode::Resize(): Writing back inode changes. Size: %" B_PRIdOFF + "\n", Size()); return WriteBack(transaction); } @@ -451,7 +460,7 @@ status_t Inode::Unlink(Transaction& transaction) { uint32 numLinks = fNode.NumLinks(); - TRACE("Inode::Unlink(): Current links: %lu\n", numLinks); + TRACE("Inode::Unlink(): Current links: %" B_PRIu32 "\n", numLinks); if (numLinks == 0) return B_BAD_VALUE; @@ -727,8 +736,8 @@ Inode::EnableFileCache() return B_OK; } - TRACE("Inode::EnableFileCache(): Creating file cache: %ld, %lld, %lld\n", - fVolume->ID(), ID(), Size()); + TRACE("Inode::EnableFileCache(): Creating file cache: %" B_PRIu32 ", %" + B_PRIdINO ", %" B_PRIdOFF "\n", fVolume->ID(), ID(), Size()); fCache = file_cache_create(fVolume->ID(), ID(), Size()); fMap = file_map_create(fVolume->ID(), ID(), Size()); @@ -819,7 +828,8 @@ Inode::_EnlargeDataStream(Transaction& transaction, off_t size) if (size <= maxSize) { // No need to allocate more blocks TRACE("Inode::_EnlargeDataStream(): No need to allocate more blocks\n"); - TRACE("Inode::_EnlargeDataStream(): Setting size to %Ld\n", size); + TRACE("Inode::_EnlargeDataStream(): Setting size to %" B_PRIdOFF "\n", + size); fNode.SetSize(size); return B_OK; } @@ -833,10 +843,11 @@ Inode::_EnlargeDataStream(Transaction& transaction, off_t size) DataStream stream(fVolume, &fNode.stream, oldSize); stream.Enlarge(transaction, end); } - TRACE("Inode::_EnlargeDataStream(): Setting size to %lld\n", size); + TRACE("Inode::_EnlargeDataStream(): Setting size to %" B_PRIdOFF "\n", + size); fNode.SetSize(size); - TRACE("Inode::_EnlargeDataStream(): Setting allocated block count to %llu\n", - end); + TRACE("Inode::_EnlargeDataStream(): Setting allocated block count to %" + B_PRIdOFF "\n", end); return _SetNumBlocks(_NumBlocks() + end * (fVolume->BlockSize() / 512)); } @@ -858,7 +869,8 @@ Inode::_ShrinkDataStream(Transaction& transaction, off_t size) if (size > minSize) { // No need to allocate more blocks TRACE("Inode::_ShrinkDataStream(): No need to allocate more blocks\n"); - TRACE("Inode::_ShrinkDataStream(): Setting size to %lld\n", size); + TRACE("Inode::_ShrinkDataStream(): Setting size to %" B_PRIdOFF "\n", + size); fNode.SetSize(size); return B_OK; } diff --git a/src/add-ons/kernel/file_systems/ext2/Inode.h b/src/add-ons/kernel/file_systems/ext2/Inode.h index b126996f90..098f83542b 100644 --- a/src/add-ons/kernel/file_systems/ext2/Inode.h +++ b/src/add-ons/kernel/file_systems/ext2/Inode.h @@ -224,10 +224,10 @@ public: status_t status = B_OK; if (!inode->IsSymLink() && volume->ID() >= 0) { - TRACEI("Vnode::Publish(): Publishing vnode: %d, %d, %p, %p, %x, " - "%x\n", (int)volume->FSVolume(), (int)inode->ID(), inode, - vnodeOps != NULL ? vnodeOps : &gExt2VnodeOps, (int)inode->Mode(), - (int)publishFlags); + TRACEI("Vnode::Publish(): Publishing volume: %p, %" B_PRIdINO + ", %p, %p, %" B_PRIu16 ", %" B_PRIx32 "\n", volume->FSVolume(), + inode->ID(), inode, vnodeOps != NULL ? vnodeOps : &gExt2VnodeOps, + inode->Mode(), publishFlags); status = publish_vnode(volume->FSVolume(), inode->ID(), inode, vnodeOps != NULL ? vnodeOps : &gExt2VnodeOps, inode->Mode(), publishFlags); diff --git a/src/add-ons/kernel/file_systems/ext2/InodeAllocator.cpp b/src/add-ons/kernel/file_systems/ext2/InodeAllocator.cpp index 9ac91ee79a..04186c45d7 100644 --- a/src/add-ons/kernel/file_systems/ext2/InodeAllocator.cpp +++ b/src/add-ons/kernel/file_systems/ext2/InodeAllocator.cpp @@ -139,7 +139,7 @@ InodeAllocator::_AllocateInGroup(Transaction& transaction, uint32 blockGroup, uint32 freeInodes = group->FreeInodes(fVolume->Has64bitFeature()); if (freeInodes == 0) return B_DEVICE_FULL; - TRACE("InodeAllocator::_Allocate() freeInodes %ld\n", + TRACE("InodeAllocator::_Allocate() freeInodes %" B_PRId32 "\n", freeInodes); group->SetFreeInodes(freeInodes - 1, fVolume->Has64bitFeature()); if (isDirectory) { @@ -177,8 +177,8 @@ InodeAllocator::_MarkInBitmap(Transaction& transaction, fsblock_t bitmapBlock, BitmapBlock inodeBitmap(fVolume, numInodes); if (!inodeBitmap.SetToWritable(transaction, bitmapBlock)) { - ERROR("Unable to open inode bitmap (block number: %llu) for block group " - "%lu\n", bitmapBlock, blockGroup); + ERROR("Unable to open inode bitmap (block number: %" B_PRIu64 + ") for block group %" B_PRIu32 "\n", bitmapBlock, blockGroup); return B_IO_ERROR; } @@ -186,15 +186,16 @@ InodeAllocator::_MarkInBitmap(Transaction& transaction, fsblock_t bitmapBlock, inodeBitmap.FindNextUnmarked(pos); if (pos == inodeBitmap.NumBits()) { - ERROR("Even though the block group %lu indicates there are free " - "inodes, no unmarked bit was found in the inode bitmap at block " - "%llu (numInodes %lu).\n", blockGroup, bitmapBlock, numInodes); + ERROR("Even though the block group %" B_PRIu32 " indicates there are " + "free inodes, no unmarked bit was found in the inode bitmap at " + "block %" B_PRIu64 " (numInodes %" B_PRIu32 ").\n", blockGroup, + bitmapBlock, numInodes); return B_ERROR; } if (!inodeBitmap.Mark(pos, 1)) { - ERROR("Failed to mark bit %lu at bitmap block %llu\n", pos, - bitmapBlock); + ERROR("Failed to mark bit %" B_PRIu32 " at bitmap block %" B_PRIu64 + "\n", pos, bitmapBlock); return B_BAD_DATA; } @@ -209,14 +210,15 @@ InodeAllocator::_UnmarkInBitmap(Transaction& transaction, fsblock_t bitmapBlock, BitmapBlock inodeBitmap(fVolume, numInodes); if (!inodeBitmap.SetToWritable(transaction, bitmapBlock)) { - ERROR("Unable to open inode bitmap at block %llu\n", bitmapBlock); + ERROR("Unable to open inode bitmap at block %" B_PRIu64 "\n", + bitmapBlock); return B_IO_ERROR; } uint32 pos = (id - 1) % fVolume->InodesPerGroup(); if (!inodeBitmap.Unmark(pos, 1)) { - ERROR("Unable to unmark bit %lu in inode bitmap block %llu\n", pos, - bitmapBlock); + ERROR("Unable to unmark bit %" B_PRIu32 " in inode bitmap block %" + B_PRIu64 "\n", pos, bitmapBlock); return B_BAD_DATA; } diff --git a/src/add-ons/kernel/file_systems/ext2/Journal.cpp b/src/add-ons/kernel/file_systems/ext2/Journal.cpp index ab65174a46..7efea26d13 100644 --- a/src/add-ons/kernel/file_systems/ext2/Journal.cpp +++ b/src/add-ons/kernel/file_systems/ext2/Journal.cpp @@ -268,7 +268,7 @@ Journal::Lock(Transaction* owner, bool separateSubTransactions) /*virtual*/ status_t Journal::Unlock(Transaction* owner, bool success) { - TRACE("Journal::Unlock(): Lock recursion: %ld\n", + TRACE("Journal::Unlock(): Lock recursion: %" B_PRId32 "\n", recursive_lock_get_recursion(&fLock)); if (fSeparateSubTransactions || recursive_lock_get_recursion(&fLock) == 1) { @@ -317,8 +317,8 @@ Journal::MapBlock(off_t logical, fsblock_t& physical) inline uint32 Journal::FreeLogBlocks() const { - TRACE("Journal::FreeLogBlocks(): start: %lu, end: %lu, size: %lu\n", - fLogStart, fLogEnd, fLogSize); + TRACE("Journal::FreeLogBlocks(): start: %" B_PRIu32 ", end: %" B_PRIu32 + ", size: %" B_PRIu32 "\n", fLogStart, fLogEnd, fLogSize); return fLogStart <= fLogEnd ? fLogSize - fLogEnd + fLogStart - 1 : fLogStart - fLogEnd; @@ -381,7 +381,7 @@ Journal::_WritePartialTransactionToLog(JournalHeader* descriptorBlock, if (escapedData == NULL) { TRACE("Journal::_WritePartialTransactionToLog(): Allocating " - "space for escaped block (%lu)\n", fBlockSize); + "space for escaped block (%" B_PRIu32 ")\n", fBlockSize); escapedData = new(std::nothrow) uint8[fBlockSize]; if (escapedData == NULL) { TRACE("Journal::_WritePartialTransactionToLof(): Failed to " @@ -411,7 +411,7 @@ Journal::_WritePartialTransactionToLog(JournalHeader* descriptorBlock, off_t logOffset = physicalBlock * fBlockSize; TRACE("Journal::_WritePartialTransactionToLog(): Writing from memory: " - "%p, to disk: %llu\n", finalData, logOffset); + "%p, to disk: %" B_PRIdOFF "\n", finalData, logOffset); size_t written = write_pos(fJournalVolume->Device(), logOffset, finalData, fBlockSize); if (written != fBlockSize) { @@ -420,7 +420,7 @@ Journal::_WritePartialTransactionToLog(JournalHeader* descriptorBlock, } TRACE("Journal::_WritePartialTransactionToLog(): Wrote a journal block " - "at: %lu\n", logBlock); + "at: %" B_PRIu32 "\n", logBlock); blockCount++; tag++; @@ -442,8 +442,8 @@ Journal::_WritePartialTransactionToLog(JournalHeader* descriptorBlock, off_t descriptorBlockOffset = physicalBlock * fBlockSize; - TRACE("Journal::_WritePartialTransactionToLog(): Writing to: %lld\n", - descriptorBlockOffset); + TRACE("Journal::_WritePartialTransactionToLog(): Writing to: %" B_PRIdOFF + "\n", descriptorBlockOffset); size_t written = write_pos(fJournalVolume->Device(), descriptorBlockOffset, descriptorBlock, fBlockSize); if (written != fBlockSize) { @@ -467,14 +467,15 @@ Journal::_WriteTransactionToLog() TRACE("Journal::_WriteTransactionToLog(): Attempting to get transaction " "size\n"); size_t size = _FullTransactionSize(); - TRACE("Journal::_WriteTransactionToLog(): transaction size: %lu\n", size); + TRACE("Journal::_WriteTransactionToLog(): transaction size: %" B_PRIuSIZE + "\n", size); if (size > fMaxTransactionSize) { TRACE("Journal::_WriteTransactionToLog(): not enough free space " "for the transaction. Attempting to free some space.\n"); size = _MainTransactionSize(); - TRACE("Journal::_WriteTransactionToLog(): main transaction size: %lu\n", - size); + TRACE("Journal::_WriteTransactionToLog(): main transaction size: %" + B_PRIuSIZE "\n", size); if(fHasSubTransaction && size < fMaxTransactionSize) { TRACE("Journal::_WriteTransactionToLog(): transaction doesn't fit, " @@ -482,22 +483,23 @@ Journal::_WriteTransactionToLog() detached = true; } else { // Error: transaction can't fit in log - panic("transaction too large (size: %lu, max size: %lu, log size: " - "%lu)\n", size, fMaxTransactionSize, fLogSize); + panic("transaction too large (size: %" B_PRIuSIZE ", max size: %" + B_PRIu32 ", log size: %" B_PRIu32 ")\n", size, + fMaxTransactionSize, fLogSize); return B_BUFFER_OVERFLOW; } } - TRACE("Journal::_WriteTransactionToLog(): free log blocks: %lu\n", - FreeLogBlocks()); + TRACE("Journal::_WriteTransactionToLog(): free log blocks: %" B_PRIu32 + "\n", FreeLogBlocks()); if (size > FreeLogBlocks()) { TRACE("Journal::_WriteTransactionToLog(): Syncing block cache\n"); cache_sync_transaction(fFilesystemBlockCache, fTransactionID); if (size > FreeLogBlocks()) { panic("Transaction fits, but sync didn't result in enough" - "free space.\n\tGot %ld when at least %ld was expected.", - FreeLogBlocks(), size); + "free space.\n\tGot %" B_PRIu32 " when at least %" B_PRIuSIZE + " was expected.", FreeLogBlocks(), size); } } @@ -510,7 +512,7 @@ Journal::_WriteTransactionToLog() // Prepare Descriptor block TRACE("Journal::_WriteTransactionToLog(): attempting to allocate space for " - "the descriptor block, block size %lu\n", fBlockSize); + "the descriptor block, block size %" B_PRIu32 "\n", fBlockSize); JournalHeader* descriptorBlock = (JournalHeader*)new(std::nothrow) uint8[fBlockSize]; if (descriptorBlock == NULL) { @@ -524,7 +526,7 @@ Journal::_WriteTransactionToLog() // Prepare Commit block TRACE("Journal::_WriteTransactionToLog(): attempting to allocate space for " - "the commit block, block size %lu\n", fBlockSize); + "the commit block, block size %" B_PRIu32 "\n", fBlockSize); JournalHeader* commitBlock = (JournalHeader*)new(std::nothrow) uint8[fBlockSize]; if (descriptorBlock == NULL) { @@ -588,7 +590,7 @@ Journal::_WriteTransactionToLog() off_t logOffset = physicalBlock * fBlockSize; TRACE("Journal::_WriteTransactionToLog(): Writting commit block to " - "%lld\n", logOffset); + "%" B_PRIdOFF "\n", logOffset); off_t written = write_pos(fJournalVolume->Device(), logOffset, commitBlock, fBlockSize); if (written != fBlockSize) { @@ -610,7 +612,8 @@ Journal::_WriteTransactionToLog() off_t logOffset = physicalBlock * fBlockSize; - TRACE("Journal::_WriteTransactionToLog(): Writing to: %lld\n", logOffset); + TRACE("Journal::_WriteTransactionToLog(): Writing to: %" B_PRIdOFF "\n", + logOffset); off_t written = write_pos(fJournalVolume->Device(), logOffset, commitBlock, fBlockSize); if (written != fBlockSize) { @@ -644,8 +647,8 @@ Journal::_WriteTransactionToLog() if (status == B_OK && _FullTransactionSize() > fLogSize) { // If the transaction is too large after writing, there is no way to // recover, so let this transaction fail. - ERROR("transaction too large (%ld blocks, log size %ld)!\n", - _FullTransactionSize(), fLogSize); + ERROR("transaction too large (%" B_PRIuSIZE " blocks, log size %" + B_PRIu32 ")!\n", _FullTransactionSize(), fLogSize); return B_BUFFER_OVERFLOW; } } else { @@ -679,7 +682,8 @@ Journal::_SaveSuperBlock() superblock.SetFirstCommitID(fFirstCommitID); superblock.SetLogStart(fLogStart); - TRACE("Journal::SaveSuperBlock(): Write to %lld\n", superblockPos); + TRACE("Journal::SaveSuperBlock(): Write to %" B_PRIdOFF "\n", + superblockPos); size_t bytesWritten = write_pos(fJournalVolume->Device(), superblockPos, &superblock, sizeof(superblock)); @@ -702,8 +706,8 @@ Journal::_LoadSuperBlock() if (status != B_OK) return status; - TRACE("Journal::_LoadSuperBlock(): superblock physical block: %llu\n", - superblockPos); + TRACE("Journal::_LoadSuperBlock(): superblock physical block: %" B_PRIu64 + "\n", superblockPos); JournalSuperBlock superblock; size_t bytesRead = read_pos(fJournalVolume->Device(), superblockPos @@ -715,8 +719,8 @@ Journal::_LoadSuperBlock() } if (!superblock.header.CheckMagic()) { - ERROR("Journal::_LoadSuperBlock(): Invalid superblock magic %lX\n", - superblock.header.Magic()); + ERROR("Journal::_LoadSuperBlock(): Invalid superblock magic %" B_PRIx32 + "\n", superblock.header.Magic()); return B_BAD_VALUE; } @@ -757,9 +761,10 @@ Journal::_LoadSuperBlock() // TODO: Why is "superblock.MaxTransactionBlocks();" zero? //fFirstCacheCommitID = fFirstCommitID - fTransactionID /*+ 1*/; - TRACE("Journal::_LoadSuperBlock(): block size: %lu, first commit id: %lu, " - "first log block: %lu, log start: %lu, log size: %lu, max transaction " - "size: %lu\n", fBlockSize, fFirstCommitID, fFirstLogBlock, fLogStart, + TRACE("Journal::_LoadSuperBlock(): block size: %" B_PRIu32 ", first commit" + " id: %" B_PRIu32 ", first log block: %" B_PRIu32 ", log start: %" + B_PRIu32 ", log size: %" B_PRIu32 ", max transaction size: %" B_PRIu32 + "\n", fBlockSize, fFirstCommitID, fFirstLogBlock, fLogStart, fLogSize, fMaxTransactionSize); return B_OK; @@ -795,7 +800,8 @@ Journal::_CountTags(JournalHeader* descriptorBlock) tags += 2; // Skip new UUID } - TRACE("Journal::_CountTags(): Tag block: %lu\n", tags->BlockNumber()); + TRACE("Journal::_CountTags(): Tag block: %" B_PRIu32 "\n", + tags->BlockNumber()); tags++; // Go to next tag count++; @@ -804,7 +810,7 @@ Journal::_CountTags(JournalHeader* descriptorBlock) if ((tags->Flags() & JOURNAL_FLAG_LAST_TAG) != 0) count++; - TRACE("Journal::_CountTags(): counted tags: %lu\n", count); + TRACE("Journal::_CountTags(): counted tags: %" B_PRIu32 "\n", count); return count; } @@ -858,11 +864,11 @@ Journal::_RecoverPassScan(uint32& lastCommitID) uint32 tags = _CountTags(header); nextBlock += tags; TRACE("Journal recover pass scan: Found a descriptor block with " - "%lu tags\n", tags); + "%" B_PRIu32 " tags\n", tags); } else if (blockType == JOURNAL_COMMIT_BLOCK) { nextCommitID++; TRACE("Journal recover pass scan: Found a commit block. Next " - "commit ID: %lu\n", nextCommitID); + "commit ID: %" B_PRIu32 "\n", nextCommitID); } else if (blockType != JOURNAL_REVOKE_BLOCK) { TRACE("Journal recover pass scan: Reached an unrecognized block, " "assuming as log's end.\n"); @@ -881,8 +887,8 @@ Journal::_RecoverPassScan(uint32& lastCommitID) header = (JournalHeader*)cached.SetTo(nextBlockPos); } - TRACE("Journal Recovery pass scan: Last detected transaction ID: %lu\n", - nextCommitID); + TRACE("Journal Recovery pass scan: Last detected transaction ID: %" + B_PRIu32 "\n", nextCommitID); lastCommitID = nextCommitID; return B_OK; @@ -946,7 +952,7 @@ Journal::_RecoverPassRevoke(uint32 lastCommitID) return B_ERROR; } - TRACE("Journal recovery pass revoke: Revoked blocks: %lu\n", + TRACE("Journal recovery pass revoke: Revoked blocks: %" B_PRIu32 "\n", fRevokeManager->NumRevokes()); return B_OK; @@ -1016,8 +1022,8 @@ Journal::_RecoverPassReplay(uint32 lastCommitID) = B_HOST_TO_BENDIAN_INT32(JOURNAL_MAGIC); } - TRACE("Journal::_RevoverPassReplay(): Write to %lu\n", - tag->BlockNumber() * fBlockSize); + TRACE("Journal::_RevoverPassReplay(): Write to %" B_PRIu32 + "\n", tag->BlockNumber() * fBlockSize); size_t written = write_pos(fFilesystemVolume->Device(), tag->BlockNumber() * fBlockSize, data, fBlockSize); @@ -1070,7 +1076,7 @@ Journal::_FlushLog(bool canWait, bool flushBlocks) status_t status = canWait ? recursive_lock_lock(&fLock) : recursive_lock_trylock(&fLock); - TRACE("Journal::_FlushLog(): Acquired fLock, recursion: %ld\n", + TRACE("Journal::_FlushLog(): Acquired fLock, recursion: %" B_PRId32 "\n", recursive_lock_get_recursion(&fLock)); if (status != B_OK) return status; @@ -1131,7 +1137,7 @@ Journal::_WrapAroundLog(uint32 block) size_t Journal::_CurrentTransactionSize() const { - TRACE("Journal::_CurrentTransactionSize(): transaction %ld\n", + TRACE("Journal::_CurrentTransactionSize(): transaction %" B_PRIu32 "\n", fTransactionID); size_t count; @@ -1140,12 +1146,12 @@ Journal::_CurrentTransactionSize() const count = cache_blocks_in_sub_transaction(fFilesystemBlockCache, fTransactionID); - TRACE("\tSub transaction size: %ld\n", count); + TRACE("\tSub transaction size: %" B_PRIuSIZE "\n", count); } else { count = cache_blocks_in_transaction(fFilesystemBlockCache, fTransactionID); - TRACE("\tTransaction size: %ld\n", count); + TRACE("\tTransaction size: %" B_PRIuSIZE "\n", count); } return count; @@ -1155,13 +1161,14 @@ Journal::_CurrentTransactionSize() const size_t Journal::_FullTransactionSize() const { - TRACE("Journal::_FullTransactionSize(): transaction %ld\n", fTransactionID); + TRACE("Journal::_FullTransactionSize(): transaction %" B_PRIu32 "\n", + fTransactionID); TRACE("\tFile sytem block cache: %p\n", fFilesystemBlockCache); size_t count = cache_blocks_in_transaction(fFilesystemBlockCache, fTransactionID); - TRACE("\tFull transaction size: %ld\n", count); + TRACE("\tFull transaction size: %" B_PRIuSIZE "\n", count); return count; } @@ -1170,12 +1177,13 @@ Journal::_FullTransactionSize() const size_t Journal::_MainTransactionSize() const { - TRACE("Journal::_MainTransactionSize(): transaction %ld\n", fTransactionID); + TRACE("Journal::_MainTransactionSize(): transaction %" B_PRIu32 "\n", + fTransactionID); size_t count = cache_blocks_in_main_transaction(fFilesystemBlockCache, fTransactionID); - TRACE("\tMain transaction size: %ld\n", count); + TRACE("\tMain transaction size: %" B_PRIuSIZE "\n", count); return count; } @@ -1186,13 +1194,13 @@ Journal::_TransactionDone(bool success) { if (!success) { if (fHasSubTransaction) { - TRACE("Journal::_TransactionDone(): transaction %ld failed, " - "aborting subtransaction\n", fTransactionID); + TRACE("Journal::_TransactionDone(): transaction %" B_PRIu32 + " failed, aborting subtransaction\n", fTransactionID); cache_abort_sub_transaction(fFilesystemBlockCache, fTransactionID); // parent is unaffected } else { - TRACE("Journal::_TransactionDone(): transaction %ld failed," - " aborting\n", fTransactionID); + TRACE("Journal::_TransactionDone(): transaction %" B_PRIu32 + " failed, aborting\n", fTransactionID); cache_abort_transaction(fFilesystemBlockCache, fTransactionID); fUnwrittenTransactions = 0; } @@ -1203,12 +1211,12 @@ Journal::_TransactionDone(bool success) // If possible, delay flushing the transaction uint32 size = _FullTransactionSize(); - TRACE("Journal::_TransactionDone(): full transaction size: %lu, max " - "transaction size: %lu, free log blocks: %lu\n", size, - fMaxTransactionSize, FreeLogBlocks()); + TRACE("Journal::_TransactionDone(): full transaction size: %" B_PRIu32 + ", max transaction size: %" B_PRIu32 ", free log blocks: %" B_PRIu32 + "\n", size, fMaxTransactionSize, FreeLogBlocks()); if (fMaxTransactionSize > 0 && size < fMaxTransactionSize) { TRACE("Journal::_TransactionDone(): delaying flush of transaction " - "%ld\n", fTransactionID); + "%" B_PRIu32 "\n", fTransactionID); // Make sure the transaction fits in the log if (size < FreeLogBlocks()) @@ -1228,8 +1236,8 @@ Journal::_TransactionWritten(int32 transactionID, int32 event, void* _logEntry) { LogEntry* logEntry = (LogEntry*)_logEntry; - TRACE("Journal::_TransactionWritten(): Transaction %ld checkpointed\n", - transactionID); + TRACE("Journal::_TransactionWritten(): Transaction %" B_PRIu32 + " checkpointed\n", transactionID); Journal* journal = logEntry->GetJournal(); @@ -1243,12 +1251,12 @@ Journal::_TransactionWritten(int32 transactionID, int32 event, void* _logEntry) TRACE("Journal::_TransactionWritten(): first log entry: %p\n", journal->fLogEntries.First()); if (logEntry == journal->fLogEntries.First()) { - TRACE("Journal::_TransactionWritten(): Moving start of log to %lu\n", - logEntry->Start()); + TRACE("Journal::_TransactionWritten(): Moving start of log to %" + B_PRIu32 "\n", logEntry->Start()); journal->fLogStart = logEntry->Start(); journal->fFirstCommitID = logEntry->CommitID(); - TRACE("Journal::_TransactionWritten(): Setting commit ID to %lu\n", - logEntry->CommitID()); + TRACE("Journal::_TransactionWritten(): Setting commit ID to %" B_PRIu32 + "\n", logEntry->CommitID()); if (journal->_SaveSuperBlock() != B_OK) panic("ext2: Failed to write journal superblock\n"); diff --git a/src/add-ons/kernel/file_systems/ext2/NoJournal.cpp b/src/add-ons/kernel/file_systems/ext2/NoJournal.cpp index d6230376eb..3d01b1c1a7 100644 --- a/src/add-ons/kernel/file_systems/ext2/NoJournal.cpp +++ b/src/add-ons/kernel/file_systems/ext2/NoJournal.cpp @@ -84,8 +84,8 @@ NoJournal::Unlock(Transaction* owner, bool success) status_t NoJournal::_WriteTransactionToLog() { - TRACE("NoJournal::_WriteTransactionToLog(): Ending transaction %ld\n", - fTransactionID); + TRACE("NoJournal::_WriteTransactionToLog(): Ending transaction %" B_PRId32 + "\n", fTransactionID); fTransactionID = cache_end_transaction(fFilesystemBlockCache, fTransactionID, _TransactionWritten, NULL); @@ -97,5 +97,5 @@ NoJournal::_WriteTransactionToLog() /*static*/ void NoJournal::_TransactionWritten(int32 transactionID, int32 event, void* param) { - TRACE("Transaction %ld checkpointed\n", transactionID); + TRACE("Transaction %" B_PRId32" checkpointed\n", transactionID); } diff --git a/src/add-ons/kernel/file_systems/ext2/RevokeManager.cpp b/src/add-ons/kernel/file_systems/ext2/RevokeManager.cpp index 1e15f652bf..e8ed581dc7 100644 --- a/src/add-ons/kernel/file_systems/ext2/RevokeManager.cpp +++ b/src/add-ons/kernel/file_systems/ext2/RevokeManager.cpp @@ -31,14 +31,16 @@ RevokeManager::~RevokeManager() status_t -RevokeManager::ScanRevokeBlock(JournalRevokeHeader* revokeBlock, uint32 commitID) +RevokeManager::ScanRevokeBlock(JournalRevokeHeader* revokeBlock, + uint32 commitID) { - TRACE("RevokeManager::ScanRevokeBlock(): Commit ID: %lu\n", commitID); + TRACE("RevokeManager::ScanRevokeBlock(): Commit ID: %" B_PRIu32 "\n", + commitID); int count = revokeBlock->NumBytes() / 4; for (int i = 0; i < count; ++i) { - TRACE("RevokeManager::ScanRevokeBlock(): Found a revoked block: %lu\n", - revokeBlock->RevokeBlock(i)); + TRACE("RevokeManager::ScanRevokeBlock(): Found a revoked block: %" + B_PRIu32 "\n", revokeBlock->RevokeBlock(i)); status_t status = Insert(revokeBlock->RevokeBlock(i), commitID); if (status != B_OK) { diff --git a/src/add-ons/kernel/file_systems/ext2/Transaction.cpp b/src/add-ons/kernel/file_systems/ext2/Transaction.cpp index 834da245aa..e69a6aec9c 100644 --- a/src/add-ons/kernel/file_systems/ext2/Transaction.cpp +++ b/src/add-ons/kernel/file_systems/ext2/Transaction.cpp @@ -187,11 +187,11 @@ Transaction::NotifyListeners(bool success) TRACE("Transaction::NotifyListeners(): fListeners.First(): %p\n", fListeners.First()); if (success) { - TRACE("Transaction::NotifyListeners(true): Number of listeners: %ld\n", - fListeners.Count()); + TRACE("Transaction::NotifyListeners(true): Number of listeners: %" + B_PRId32 "\n", fListeners.Count()); } else { - TRACE("Transaction::NotifyListeners(false): Number of listeners: %ld\n", - fListeners.Count()); + TRACE("Transaction::NotifyListeners(false): Number of listeners: %" + B_PRId32 "\n", fListeners.Count()); } TRACE("Transaction::NotifyListeners(): Finished counting\n"); diff --git a/src/add-ons/kernel/file_systems/ext2/Volume.cpp b/src/add-ons/kernel/file_systems/ext2/Volume.cpp index b833eee746..629cec7dc6 100644 --- a/src/add-ons/kernel/file_systems/ext2/Volume.cpp +++ b/src/add-ons/kernel/file_systems/ext2/Volume.cpp @@ -296,7 +296,8 @@ Volume::Mount(const char* deviceName, uint32 flags) if (opener.IsReadOnly()) fFlags |= VOLUME_READ_ONLY; - TRACE("features %lx, incompatible features %lx, read-only features %lx\n", + TRACE("features %" B_PRIx32 ", incompatible features %" B_PRIx32 + ", read-only features %" B_PRIx32 "\n", fSuperBlock.CompatibleFeatures(), fSuperBlock.IncompatibleFeatures(), fSuperBlock.ReadOnlyFeatures()); @@ -336,8 +337,9 @@ Volume::Mount(const char* deviceName, uint32 flags) fGroupsPerBlock = fBlockSize / fGroupDescriptorSize; fNumInodes = fSuperBlock.NumInodes(); - TRACE("block size %ld, num groups %ld, groups per block %ld, first %lu\n", - fBlockSize, fNumGroups, fGroupsPerBlock, fFirstDataBlock); + TRACE("block size %" B_PRIu32 ", num groups %" B_PRIu32 ", groups per " + "block %" B_PRIu32 ", first %" B_PRIu32 "\n", fBlockSize, fNumGroups, + fGroupsPerBlock, fFirstDataBlock); uint32 blockCount = (fNumGroups + fGroupsPerBlock - 1) / fGroupsPerBlock; @@ -523,8 +525,8 @@ Volume::_UnsupportedIncompatibleFeatures(ext2_super_block& superBlock) & ~supportedIncompatible; if (unsupported != 0) { - FATAL("ext2: incompatible features not supported: %lx (extents %x)\n", - unsupported, EXT2_INCOMPATIBLE_FEATURE_EXTENTS); + FATAL("ext2: incompatible features not supported: %" B_PRIx32 + " (extents %x)\n", unsupported, EXT2_INCOMPATIBLE_FEATURE_EXTENTS); } return unsupported; @@ -545,8 +547,10 @@ Volume::_UnsupportedReadOnlyFeatures(ext2_super_block& superBlock) uint32 unsupported = superBlock.ReadOnlyFeatures() & ~supportedReadOnly; - if (unsupported != 0) - FATAL("ext2: readonly features not supported: %lx\n", unsupported); + if (unsupported != 0) { + FATAL("ext2: readonly features not supported: %" B_PRIx32 "\n", + unsupported); + } return unsupported; } @@ -611,8 +615,8 @@ Volume::GetBlockGroup(int32 index, ext2_block_group** _group) memcpy(fGroupBlocks[blockIndex], block, fBlockSize); - TRACE("group [%ld]: inode table %lld\n", index, ((ext2_block_group*) - (fGroupBlocks[blockIndex] + blockOffset + TRACE("group [%" B_PRId32 "]: inode table %" B_PRIu64 "\n", index, + ((ext2_block_group*)(fGroupBlocks[blockIndex] + blockOffset * fGroupDescriptorSize))->InodeTable(Has64bitFeature())); } @@ -646,9 +650,9 @@ Volume::WriteBlockGroup(Transaction& transaction, int32 index) + blockOffset * fGroupDescriptorSize); group->checksum = _GroupCheckSum(group, index); - TRACE("Volume::WriteBlockGroup() checksum 0x%x for group %ld " - "(free inodes %ld, unused %ld)\n", group->checksum, index, - group->FreeInodes(Has64bitFeature()), + TRACE("Volume::WriteBlockGroup() checksum 0x%x for group %" B_PRId32 " " + "(free inodes %" B_PRIu32 ", unused %" B_PRIu32 ")\n", group->checksum, + index, group->FreeInodes(Has64bitFeature()), group->UnusedInodes(Has64bitFeature())); CachedBlock cached(this); @@ -822,7 +826,8 @@ Volume::AllocateBlocks(Transaction& transaction, uint32 minimum, uint32 maximum, if (status != B_OK) return status; - TRACE("Volume::AllocateBlocks(): Allocated %lu blocks\n", length); + TRACE("Volume::AllocateBlocks(): Allocated %" B_PRIu32 " blocks\n", + length); fFreeBlocks -= length; @@ -833,7 +838,7 @@ Volume::AllocateBlocks(Transaction& transaction, uint32 minimum, uint32 maximum, status_t Volume::FreeBlocks(Transaction& transaction, fsblock_t start, uint32 length) { - TRACE("Volume::FreeBlocks(%llu, %lu)\n", start, length); + TRACE("Volume::FreeBlocks(%" B_PRIu64 ", %" B_PRIu32 ")\n", start, length); if (IsReadOnly()) return B_READ_ONLY_DEVICE; @@ -841,11 +846,11 @@ Volume::FreeBlocks(Transaction& transaction, fsblock_t start, uint32 length) if (status != B_OK) return status; - TRACE("Volume::FreeBlocks(): number of free blocks (before): %llu\n", - fFreeBlocks); + TRACE("Volume::FreeBlocks(): number of free blocks (before): %" B_PRIdOFF + "\n", fFreeBlocks); fFreeBlocks += length; - TRACE("Volume::FreeBlocks(): number of free blocks (after): %llu\n", - fFreeBlocks); + TRACE("Volume::FreeBlocks(): number of free blocks (after): %" B_PRIdOFF + "\n", fFreeBlocks); return WriteSuperBlock(transaction); } @@ -880,8 +885,9 @@ Volume::WriteSuperBlock(Transaction& transaction) fSuperBlock.SetFreeInodes(fFreeInodes); // TODO: Rest of fields that can be modified - TRACE("Volume::WriteSuperBlock(): free blocks: %llu, free inodes: %lu\n", - fSuperBlock.FreeBlocks(Has64bitFeature()), fSuperBlock.FreeInodes()); + TRACE("Volume::WriteSuperBlock(): free blocks: %" B_PRIu64 ", free inodes:" + " %" B_PRIu32 "\n", fSuperBlock.FreeBlocks(Has64bitFeature()), + fSuperBlock.FreeInodes()); CachedBlock cached(this); uint8* block = cached.SetToWritable(transaction, fFirstDataBlock); @@ -889,8 +895,8 @@ Volume::WriteSuperBlock(Transaction& transaction) if (block == NULL) return B_IO_ERROR; - TRACE("Volume::WriteSuperBlock(): first data block: %lu, block: %p, " - "superblock: %p\n", fFirstDataBlock, block, &fSuperBlock); + TRACE("Volume::WriteSuperBlock(): first data block: %" B_PRIu32 ", block:" + " %p, superblock: %p\n", fFirstDataBlock, block, &fSuperBlock); if (fFirstDataBlock == 0) memcpy(block + 1024, &fSuperBlock, sizeof(fSuperBlock)); diff --git a/src/add-ons/kernel/file_systems/ext2/ext2.h b/src/add-ons/kernel/file_systems/ext2/ext2.h index 25a8468e1a..b966e7c72d 100644 --- a/src/add-ons/kernel/file_systems/ext2/ext2.h +++ b/src/add-ons/kernel/file_systems/ext2/ext2.h @@ -13,9 +13,6 @@ #include -//#define TRACE_EXT2 - - typedef uint64 fileblock_t; // file block number typedef uint64 fsblock_t; // filesystem block number diff --git a/src/add-ons/kernel/file_systems/ext2/kernel_interface.cpp b/src/add-ons/kernel/file_systems/ext2/kernel_interface.cpp index b5fcdfce23..daea2ec47f 100644 --- a/src/add-ons/kernel/file_systems/ext2/kernel_interface.cpp +++ b/src/add-ons/kernel/file_systems/ext2/kernel_interface.cpp @@ -217,7 +217,7 @@ ext2_get_vnode(fs_volume* _volume, ino_t id, fs_vnode* _node, int* _type, Volume* volume = (Volume*)_volume->private_volume; if (id < 2 || id > volume->NumInodes()) { - ERROR("invalid inode id %lld requested!\n", id); + ERROR("invalid inode id %" B_PRIdINO " requested!\n", id); return B_BAD_VALUE; } @@ -319,7 +319,7 @@ ext2_read_pages(fs_volume* _volume, fs_vnode* _node, void* _cookie, while (true) { file_io_vec fileVecs[8]; - uint32 fileVecCount = 8; + size_t fileVecCount = 8; status = file_map_translate(inode->Map(), pos, bytesLeft, fileVecs, &fileVecCount, 0); @@ -436,8 +436,8 @@ ext2_get_file_map(fs_volume* _volume, fs_vnode* _node, off_t offset, return status; if (block > volume->NumBlocks()) { - panic("ext2_get_file_map() found block %lld for offset %lld\n", - block, offset); + panic("ext2_get_file_map() found block %" B_PRIu64 " for offset %" + B_PRIdOFF "\n", block, offset); } off_t blockOffset = block << volume->BlockShift(); @@ -467,10 +467,10 @@ ext2_get_file_map(fs_volume* _volume, fs_vnode* _node, off_t offset, offset += blockLength; size -= blockLength; - if (size <= vecs[index - 1].length || offset >= inode->Size()) { + if ((off_t)size <= vecs[index - 1].length || offset >= inode->Size()) { // We're done! *_count = index; - TRACE("ext2_get_file_map for inode %lld\n", inode->ID()); + TRACE("ext2_get_file_map for inode %" B_PRIdINO "\n", inode->ID()); return B_OK; } } @@ -518,7 +518,7 @@ static status_t ext2_ioctl(fs_volume* _volume, fs_vnode* _node, void* _cookie, uint32 cmd, void* buffer, size_t bufferLength) { - TRACE("ioctl: %lu\n", cmd); + TRACE("ioctl: %" B_PRIu32 "\n", cmd); Volume* volume = (Volume*)_volume->private_volume; switch (cmd) { @@ -537,14 +537,15 @@ ext2_ioctl(fs_volume* _volume, fs_vnode* _node, void* _cookie, uint32 cmd, uint32 group = 0; uint32 length; - TRACE("ioctl: blocks per group: %lu, block size: %lu, " - "first block: %lu, start: %llu, group: %lu\n", blocksPerGroup, + TRACE("ioctl: blocks per group: %" B_PRIu32 ", block size: %" + B_PRIu32 ", first block: %" B_PRIu32 ", start: %" B_PRIu64 + ", group: %" B_PRIu32 "\n", blocksPerGroup, blockSize, firstBlock, start, group); while (volume->AllocateBlocks(transaction, 1, 2048, group, start, length) == B_OK) { - TRACE("ioctl: Allocated blocks in group %lu: %llu-%llu\n", group, - start, start + length); + TRACE("ioctl: Allocated blocks in group %" B_PRIu32 ": %" + B_PRIu64 "-%" B_PRIu64 "\n", group, start, start + length); off_t blockNum = start + group * blocksPerGroup - firstBlock; for (uint32 i = 0; i < length; ++i) { @@ -1072,8 +1073,8 @@ ext2_rename(fs_volume* _volume, fs_vnode* _oldDir, const char* oldName, status = inodeIterator.FindEntry(".."); if (status == B_ENTRY_NOT_FOUND) { - TRACE("Corrupt file sytem. Missing \"..\" in directory %ld\n", - (int32)inode->ID()); + TRACE("Corrupt file system. Missing \"..\" in directory %" + B_PRIdINO "\n", inode->ID()); return B_BAD_DATA; } else if (status != B_OK) return status; @@ -1266,7 +1267,7 @@ ext2_read_link(fs_volume *_volume, fs_vnode *_node, char *buffer, if (!inode->IsSymLink()) return B_BAD_VALUE; - if (inode->Size() < *_bufferSize) + if (inode->Size() < (off_t)*_bufferSize) *_bufferSize = inode->Size(); if (inode->Size() > EXT2_SHORT_SYMLINK_LENGTH) diff --git a/src/add-ons/kernel/file_systems/fat/file.c b/src/add-ons/kernel/file_systems/fat/file.c index f06102115a..d9239a3b59 100644 --- a/src/add-ons/kernel/file_systems/fat/file.c +++ b/src/add-ons/kernel/file_systems/fat/file.c @@ -180,7 +180,10 @@ dosfs_rstat(fs_volume *_vol, fs_vnode *_node, struct stat *st) st->st_size = node->st_size; st->st_blocks = (node->st_size + 511) / 512; st->st_blksize = 0x10000; /* this value was chosen arbitrarily */ - st->st_atime = st->st_mtime = st->st_ctime = st->st_crtime = node->st_time; + st->st_atim.tv_sec = st->st_mtim.tv_sec = st->st_ctim.tv_sec + = st->st_crtim.tv_sec = node->st_time; + st->st_atim.tv_nsec = st->st_mtim.tv_nsec = st->st_ctim.tv_nsec + = st->st_crtim.tv_nsec = 0; UNLOCK_VOL(vol); diff --git a/src/add-ons/kernel/file_systems/fat/util.c b/src/add-ons/kernel/file_systems/fat/util.c index d5114f7731..7bab5e3a20 100644 --- a/src/add-ons/kernel/file_systems/fat/util.c +++ b/src/add-ons/kernel/file_systems/fat/util.c @@ -106,7 +106,7 @@ dos2time_t(uint32 t) days = daze[(t>>21)&15] + ((t>>25)+10)*365 + leaps((t>>25)+10,((t>>21)&15)-1)+((t>>16)&31)-1; - return (((days * 24) + ((t>>11)&31)) * 60 + ((t>>5)&63) + tzoffset) * 60 + 2*(t&31); + return (((days * 24) + ((t>>11)&31)) * 60 + ((t>>5)&63) - tzoffset) * 60 + 2*(t&31); } @@ -118,7 +118,7 @@ time_t2dos(time_t s) get_tzoffset(); - t = (s % 60) / 2; s /= 60; s -= tzoffset; + t = (s % 60) / 2; s /= 60; s += tzoffset; t += (s % 60) << 5; s /= 60; t += (s % 24) << 11;s /= 24; diff --git a/src/add-ons/kernel/file_systems/iso9660/iso9660.cpp b/src/add-ons/kernel/file_systems/iso9660/iso9660.cpp index c66ae29058..bbe2685e19 100644 --- a/src/add-ons/kernel/file_systems/iso9660/iso9660.cpp +++ b/src/add-ons/kernel/file_systems/iso9660/iso9660.cpp @@ -975,7 +975,7 @@ ConvertRecDate(ISORecDate* inDate, time_t* outDate) time_t time; int days, i, year, tz; - year = inDate->year -70; + year = inDate->year - 70; tz = inDate->offsetGMT; if (year < 0) { @@ -1002,7 +1002,7 @@ ConvertRecDate(ISORecDate* inDate, time_t* outDate) tz |= (-1 << 8); if (-48 <= tz && tz <= 52) - time += tz *15 * 60; + time -= tz * 15 * 60; } *outDate = time; return 0; diff --git a/src/add-ons/kernel/file_systems/iso9660/kernel_interface.cpp b/src/add-ons/kernel/file_systems/iso9660/kernel_interface.cpp index 4ed83b5f90..fc3405cb43 100644 --- a/src/add-ons/kernel/file_systems/iso9660/kernel_interface.cpp +++ b/src/add-ons/kernel/file_systems/iso9660/kernel_interface.cpp @@ -492,8 +492,10 @@ fs_read_stat(fs_volume* _volume, fs_vnode* _node, struct stat* st) // Same for file/dir in ISO9660 st->st_size = node->dataLen[FS_DATA_FORMAT]; st->st_blocks = (st->st_size + 511) / 512; - if (ConvertRecDate(&(node->recordDate), &time) == B_NO_ERROR) - st->st_ctime = st->st_mtime = st->st_atime = time; + if (ConvertRecDate(&(node->recordDate), &time) == B_NO_ERROR) { + st->st_ctim.tv_sec = st->st_mtim.tv_sec = st->st_atim.tv_sec = time; + st->st_ctim.tv_nsec = st->st_mtim.tv_nsec = st->st_atim.tv_nsec = 0; + } TRACE(("fs_read_stat - EXIT, result is %s\n", strerror(result))); diff --git a/src/add-ons/kernel/file_systems/nfs/nfs_add_on.c b/src/add-ons/kernel/file_systems/nfs/nfs_add_on.c index 1341e37381..eab631ca2d 100644 --- a/src/add-ons/kernel/file_systems/nfs/nfs_add_on.c +++ b/src/add-ons/kernel/file_systems/nfs/nfs_add_on.c @@ -229,7 +229,8 @@ postoffice_func(fs_nspace *ns) while (release_sem (call->sem) == B_INTERRUPTED); } else { - dprintf("nfs: postoffice: can't find pending call to remove for xid %ld\n", xid); + dprintf("nfs: postoffice: can't find pending call to remove " + "for xid %" B_PRId32 "\n", xid); } } } @@ -324,7 +325,7 @@ send_rpc_call(fs_nspace *ns, const struct sockaddr_in *addr, int32 prog, call = RPCPendingCallsFindAndRemovePendingCall(&ns->pendingCalls, xid, addr); - dprintf("nfs: xid %ld timed out, removing from queue", xid); + dprintf("nfs: xid %" B_PRId32 " timed out, removing from queue", xid); #if 0 if (call==NULL) @@ -375,14 +376,15 @@ is_successful_reply(struct XDRInPacket *reply) rpc_reject_stat rejectStat = (rpc_reject_stat)XDRInPacketGetInt32(reply); if (rejectStat == RPC_RPC_MISMATCH) { - int32 low=XDRInPacketGetInt32(reply); - int32 high=XDRInPacketGetInt32(reply); + int32 low = XDRInPacketGetInt32(reply); + int32 high = XDRInPacketGetInt32(reply); - dprintf ("nfs: RPC_MISMATCH (%ld,%ld)", low, high); + dprintf("nfs: RPC_MISMATCH (%" B_PRId32 ",%" B_PRId32 ")", low, + high); } else { rpc_auth_stat authStat = (rpc_auth_stat)XDRInPacketGetInt32(reply); - dprintf ("nfs: RPC_AUTH_ERROR (%d)", authStat); + dprintf("nfs: RPC_AUTH_ERROR (%d)", authStat); } } else { rpc_auth_flavor flavor = (rpc_auth_flavor)XDRInPacketGetInt32(reply); @@ -397,9 +399,10 @@ is_successful_reply(struct XDRInPacket *reply) int32 low = XDRInPacketGetInt32(reply); int32 high = XDRInPacketGetInt32(reply); - dprintf ("nfs: RPC_PROG_MISMATCH (%ld,%ld)", low, high); + dprintf("nfs: RPC_PROG_MISMATCH (%" B_PRId32 ",%" B_PRId32 ")", + low, high); } else if (acceptStat != RPC_SUCCESS) - dprintf ("nfs: Accepted but failed (%d)", acceptStat); + dprintf("nfs: Accepted but failed (%d)", acceptStat); else success = true; } @@ -1217,7 +1220,8 @@ fs_mount(fs_volume *_vol, const char *devname, uint32 flags, const char *_parms, if (_parms == NULL) return EINVAL; - dprintf("nfs: mount(%ld, %s, %08lx)\n", _vol->id, devname, flags); + dprintf("nfs: mount(%" B_PRId32 ", %s, %08" B_PRIx32 ")\n", _vol->id, + devname, flags); dprintf("nfs: nfs_params: %s\n", _parms); // HAIKU: this should go to std_ops @@ -1244,18 +1248,18 @@ fs_mount(fs_volume *_vol, const char *devname, uint32 flags, const char *_parms, memset(ns->mountAddr.sin_zero, 0, sizeof(ns->mountAddr.sin_zero)); if ((result = create_socket(ns)) < B_OK) { - dprintf( "nfs: could not create socket (%d)\n", (int)result ); + dprintf("nfs: could not create socket (%" B_PRId32 ")\n", result); goto err_socket; } if ((result = init_postoffice(ns)) < B_OK) { - dprintf( "nfs: could not init_postoffice() (%d)\n", (int)result ); + dprintf("nfs: could not init_postoffice() (%" B_PRId32 ")\n", result); goto err_postoffice; } if ((result = get_remote_address(ns, MOUNT_PROGRAM, MOUNT_VERSION, PMAP_IPPROTO_UDP, &ns->mountAddr)) < B_OK) { - dprintf( "could not get_remote_address() (%d)\n", (int)result ); + dprintf("could not get_remote_address() (%" B_PRId32 ")\n", result); goto err_sem; } diff --git a/src/add-ons/kernel/file_systems/udf/AllocationDescriptorList.h b/src/add-ons/kernel/file_systems/udf/AllocationDescriptorList.h index 3c3c8ff163..5a6b1d9d98 100644 --- a/src/add-ons/kernel/file_systems/udf/AllocationDescriptorList.h +++ b/src/add-ons/kernel/file_systems/udf/AllocationDescriptorList.h @@ -101,7 +101,7 @@ status_t AllocationDescriptorList::FindExtent(off_t start, long_address *extent, bool *isEmpty) { - TRACE(("AllocationDescriptorList<>::FindExtent: start: %Ld, " + TRACE(("AllocationDescriptorList<>::FindExtent: start: %" B_PRIdOFF ", " "extent: %p, isEmpty: %p\n", start, extent, isEmpty)); off_t startBlock = start >> fVolume->BlockShift(); @@ -132,7 +132,8 @@ AllocationDescriptorList::FindExtent(off_t start, } } else { TRACE_ERROR(("AllocationDescriptorList<>::FindExtent: " - "Descriptor #%ld found NULL\n", _DescriptorNumber())); + "Descriptor #%" B_PRId32 " found NULL\n", + _DescriptorNumber())); status = B_ERROR; break; } diff --git a/src/add-ons/kernel/file_systems/udf/Icb.cpp b/src/add-ons/kernel/file_systems/udf/Icb.cpp index 61a91357af..c924966e54 100644 --- a/src/add-ons/kernel/file_systems/udf/Icb.cpp +++ b/src/add-ons/kernel/file_systems/udf/Icb.cpp @@ -22,9 +22,9 @@ DirectoryIterator::GetNextEntry(char *name, uint32 *length, ino_t *id) if (!id || !name || !length) return B_BAD_VALUE; - TRACE(("DirectoryIterator::GetNextEntry: name = %p, length = %ld, " - "id = %p, position = %Ld, parent length = %Ld\n", name, *length, id, - fPosition, Parent()->Length())); + TRACE(("DirectoryIterator::GetNextEntry: name = %p, length = %" B_PRIu32 + ", id = %p, position = %" B_PRIdOFF ", parent length = %" B_PRIu64 + "\n", name, *length, id, fPosition, Parent()->Length())); status_t status = B_OK; if (fAtBeginning) { @@ -62,7 +62,8 @@ DirectoryIterator::GetNextEntry(char *name, uint32 *length, ino_t *id) } else { UdfString string(entry->id(), entry->id_length()); TRACE(("DirectoryIterator::GetNextEntry: UfdString id == `%s', " - "length = %lu\n", string.Utf8(), string.Utf8Length())); + "length = %" B_PRIu32 "\n", string.Utf8(), + string.Utf8Length())); DUMP(entry->icb()); sprintf(name, "%s", string.Utf8()); *length = string.Utf8Length(); @@ -111,9 +112,9 @@ Icb::Icb(Volume *volume, long_address address) fFileCache(NULL), fFileMap(NULL) { - TRACE(("Icb::Icb: volume = %p, address(block = %ld, partition = %d, " - "length = %ld)\n", volume, address.block(), address.partition(), - address.length())); + TRACE(("Icb::Icb: volume = %p, address(block = %" B_PRIu32 ", partition = " + "%d, length = %" B_PRIu32 ")\n", volume, address.block(), + address.partition(), address.length())); if (volume == NULL) fInitStatus = B_BAD_VALUE; @@ -142,7 +143,8 @@ Icb::Icb(Volume *volume, long_address address) } fInitStatus = status; - TRACE(("Icb::Icb: status = 0x%lx, `%s'\n", status, strerror(status))); + TRACE(("Icb::Icb: status = 0x%" B_PRIx32 ", `%s'\n", status, + strerror(status))); } @@ -222,7 +224,7 @@ Icb::FindBlock(uint32 logicalBlock, off_t &block, bool &recorded) return B_ERROR; } - DEBUG_INIT_ETC("Icb", ("pos: %lld", pos)); + DEBUG_INIT_ETC("Icb", ("pos: %" B_PRIdOFF, pos)); status_t status = B_OK; long_address extent; @@ -237,8 +239,9 @@ Icb::FindBlock(uint32 logicalBlock, off_t &block, bool &recorded) ShortDescriptorAccessor(fPartition)); status = list.FindExtent(pos, &extent, &isEmpty); if (status != B_OK) { - TRACE_ERROR(("Icb::FindBlock: error finding extent for offset %Ld. " - "status = 0x%lx `%s'\n", pos, status, strerror(status))); + TRACE_ERROR(("Icb::FindBlock: error finding extent for offset " + "%" B_PRIdOFF ". status = 0x%" B_PRIx32 " `%s'\n", pos, status, + strerror(status))); } break; } @@ -249,8 +252,9 @@ Icb::FindBlock(uint32 logicalBlock, off_t &block, bool &recorded) AllocationDescriptorList list(this); status = list.FindExtent(pos, &extent, &isEmpty); if (status != B_OK) { - TRACE_ERROR(("Icb::FindBlock: error finding extent for offset %Ld. " - "status = 0x%lx `%s'\n", pos, status, strerror(status))); + TRACE_ERROR(("Icb::FindBlock: error finding extent for offset " + "%" B_PRIdOFF ". status = 0x%" B_PRIx32 " `%s'\n", pos, + status, strerror(status))); } break; } @@ -281,7 +285,7 @@ Icb::FindBlock(uint32 logicalBlock, off_t &block, bool &recorded) if (status == B_OK) { block = extent.block(); recorded = extent.type() == EXTENT_TYPE_RECORDED; - TRACE(("Icb::FindBlock: block %lld\n", block)); + TRACE(("Icb::FindBlock: block %" B_PRIdOFF "\n", block)); } return status; } @@ -290,7 +294,7 @@ Icb::FindBlock(uint32 logicalBlock, off_t &block, bool &recorded) status_t Icb::Read(off_t pos, void *buffer, size_t *length, uint32 *block) { - TRACE(("Icb::Read: pos = %Ld, buffer = %p, length = (%p)->%ld\n", + TRACE(("Icb::Read: pos = %" B_PRIdOFF ", buffer = %p, length = (%p)->%ld\n", pos, buffer, length, (length ? *length : 0))); if (!buffer || !length || pos < 0) @@ -356,8 +360,8 @@ template status_t Icb::_Read(DescriptorList &list, off_t pos, void *_buffer, size_t *length, uint32 *block) { - TRACE(("Icb::_Read(): list = %p, pos = %Ld, buffer = %p, length = %ld\n", - &list, pos, _buffer, (length ? *length : 0))); + TRACE(("Icb::_Read(): list = %p, pos = %" B_PRIdOFF ", buffer = %p, " + "length = %ld\n", &list, pos, _buffer, (length ? *length : 0))); uint64 bytesLeftInFile = uint64(pos) > Length() ? 0 : Length() - pos; size_t bytesLeft = (*length >= bytesLeftInFile) ? bytesLeftInFile : *length; @@ -370,19 +374,22 @@ Icb::_Read(DescriptorList &list, off_t pos, void *_buffer, size_t *length, uint3 while (bytesLeft > 0) { - TRACE(("Icb::_Read(): pos: %Ld, bytesLeft: %ld\n", pos, bytesLeft)); + TRACE(("Icb::_Read(): pos: %" B_PRIdOFF ", bytesLeft: %ld\n", pos, + bytesLeft)); long_address extent; bool isEmpty = false; status = list.FindExtent(pos, &extent, &isEmpty); if (status != B_OK) { - TRACE_ERROR(("Icb::_Read: error finding extent for offset %Ld. " - "status = 0x%lx `%s'\n", pos, status, strerror(status))); + TRACE_ERROR(("Icb::_Read: error finding extent for offset %" + B_PRIdOFF ". status = 0x%" B_PRIx32 " `%s'\n", pos, status, + strerror(status))); break; } - TRACE(("Icb::_Read(): found extent for offset %Ld: (block: %ld, " - "partition: %d, length: %ld, type: %d)\n", pos, extent.block(), - extent.partition(), extent.length(), extent.type())); + TRACE(("Icb::_Read(): found extent for offset %" B_PRIdOFF ": (block: " + "%" B_PRIu32 ", partition: %d, length: %" B_PRIu32 ", type: %d)\n", + pos, extent.block(), extent.partition(), extent.length(), + extent.type())); switch (extent.type()) { case EXTENT_TYPE_RECORDED: @@ -421,8 +428,8 @@ Icb::_Read(DescriptorList &list, off_t pos, void *_buffer, size_t *length, uint3 if (extent.length() < readLength) readLength = extent.length(); - TRACE(("Icb::_Read: reading block. offset = %Ld, length: %ld\n", - blockOffset, readLength)); + TRACE(("Icb::_Read: reading block. offset = %" B_PRIdOFF + ", length: %ld\n", blockOffset, readLength)); if (isEmpty) { TRACE(("Icb::_Read: reading %ld empty bytes as zeros\n", @@ -436,8 +443,8 @@ Icb::_Read(DescriptorList &list, off_t pos, void *_buffer, size_t *length, uint3 break; } - TRACE(("Icb::_Read: %ld bytes from disk block %Ld using " - "block_cache_get_etc()\n", readLength, diskBlock)); + TRACE(("Icb::_Read: %ld bytes from disk block %" B_PRIdOFF " using" + " block_cache_get_etc()\n", readLength, diskBlock)); uint8 *data = (uint8*)block_cache_get_etc(volume->BlockCache(), diskBlock, 0, readLength); if (data == NULL) @@ -530,7 +537,7 @@ Icb::_GetFileMap(DescriptorList &list, off_t offset, size_t size, size -= length; index++; - if (index >= max || size <= vecs[index - 1].length + if (index >= max || (off_t)size <= vecs[index - 1].length || offset >= (off_t)Length()) { *count = index; return index >= max ? B_BUFFER_OVERFLOW : B_OK; diff --git a/src/add-ons/kernel/file_systems/udf/PhysicalPartition.cpp b/src/add-ons/kernel/file_systems/udf/PhysicalPartition.cpp index 50a336237c..d118d3bf53 100644 --- a/src/add-ons/kernel/file_systems/udf/PhysicalPartition.cpp +++ b/src/add-ons/kernel/file_systems/udf/PhysicalPartition.cpp @@ -11,8 +11,8 @@ PhysicalPartition::PhysicalPartition(uint16 number, uint32 start, uint32 length) fStart(start), fLength(length) { - TRACE(("PhysicalPartition::PhysicalPartition: number = %d, start = %lu," - "length = %lu\n", number, start, length)); + TRACE(("PhysicalPartition::PhysicalPartition: number = %d, start = %" + B_PRIu32 ",length = %" B_PRIu32 "\n", number, start, length)); } @@ -31,15 +31,15 @@ PhysicalPartition::~PhysicalPartition() status_t PhysicalPartition::MapBlock(uint32 logicalBlock, off_t &physicalBlock) { - TRACE(("PhysicalPartition::MapBlock: %ld\n", logicalBlock)); + TRACE(("PhysicalPartition::MapBlock: %" B_PRIu32 "\n", logicalBlock)); if (logicalBlock >= fLength) { - TRACE_ERROR(("PhysicalPartition::MapBlock: block %ld invalid," - "length = %ld\n", logicalBlock, fLength)); + TRACE_ERROR(("PhysicalPartition::MapBlock: block %" B_PRIu32 " invalid" + ",length = %" B_PRIu32 "\n", logicalBlock, fLength)); return B_BAD_ADDRESS; } else { physicalBlock = fStart + logicalBlock; - TRACE(("PhysicalPartition::MapBlock: block %ld mapped to %Ld\n", - logicalBlock, physicalBlock)); + TRACE(("PhysicalPartition::MapBlock: block %" B_PRIu32 " mapped to %" + B_PRIdOFF "\n", logicalBlock, physicalBlock)); return B_OK; } } diff --git a/src/add-ons/kernel/file_systems/udf/Recognition.cpp b/src/add-ons/kernel/file_systems/udf/Recognition.cpp index fbc8a27ced..0cab1e07e8 100644 --- a/src/add-ons/kernel/file_systems/udf/Recognition.cpp +++ b/src/add-ons/kernel/file_systems/udf/Recognition.cpp @@ -54,23 +54,24 @@ udf_recognize(int device, off_t offset, off_t length, uint32 blockSize, partition_descriptor partitionDescriptors[], uint8 &partitionDescriptorCount) { - TRACE(("udf_recognize: device: = %d, offset = %Ld, length = %Ld, " - "blockSize = %ld, ", device, offset, length, blockSize)); - + TRACE(("udf_recognize: device: = %d, offset = %" B_PRIdOFF ", length = %" + B_PRIdOFF ", blockSize = %" B_PRIu32 "\n", device, offset, length, + blockSize)); // Check the block size status_t status = get_block_shift(blockSize, blockShift); if (status != B_OK) { TRACE_ERROR(("\nudf_recognize: Block size must be a positive power of " - "two! (blockSize = %ld)\n", blockSize)); + "two! (blockSize = %" B_PRIu32 ")\n", blockSize)); return status; } - TRACE(("blockShift: %ld\n", blockShift)); + TRACE(("blockShift: %" B_PRIu32 "\n", blockShift)); // Check for a valid volume recognition sequence status = walk_volume_recognition_sequence(device, offset, blockSize, blockShift); if (status != B_OK) { - TRACE_ERROR(("udf_recognize: Invalid sequence. status = %ld\n", status)); + TRACE_ERROR(("udf_recognize: Invalid sequence. status = %" B_PRId32 + "\n", status)); return status; } // Now hunt down a volume descriptor sequence from one of @@ -80,8 +81,8 @@ udf_recognize(int device, off_t offset, off_t length, uint32 blockSize, logicalVolumeDescriptor, partitionDescriptors, partitionDescriptorCount); if (status != B_OK) { - TRACE_ERROR(("udf_recognize: cannot find volume descriptor. status = %ld\n", - status)); + TRACE_ERROR(("udf_recognize: cannot find volume descriptor. status = %" + B_PRId32 "\n", status)); return status; } // Now walk the integrity sequence and make sure the last integrity @@ -90,7 +91,7 @@ udf_recognize(int device, off_t offset, off_t length, uint32 blockSize, logicalVolumeDescriptor.integrity_sequence_extent()); if (status != B_OK) { TRACE_ERROR(("udf_recognize: last integrity descriptor not closed. " - "status = %ld\n", status)); + "status = %" B_PRId32 "\n", status)); return status; } @@ -106,9 +107,9 @@ status_t walk_volume_recognition_sequence(int device, off_t offset, uint32 blockSize, uint32 blockShift) { - TRACE(("walk_volume_recognition_sequence: device = %d, offset = %Ld, " - "blockSize = %ld, blockShift = %lu\n", device, offset, blockSize, - blockShift)); + TRACE(("walk_volume_recognition_sequence: device = %d, offset = %" + B_PRIdOFF ", blockSize = %" B_PRIu32 ", blockShift = %" B_PRIu32 "\n", + device, offset, blockSize, blockShift)); // vrs starts at block 16. Each volume structure descriptor (vsd) // should be one block long. We're expecting to find 0 or more iso9660 @@ -125,8 +126,8 @@ walk_volume_recognition_sequence(int device, off_t offset, uint32 blockSize, bool foundECMA168 = false; for (uint32 block = 16; true; block++) { off_t address = (offset + block) << blockShift; - TRACE(("walk_volume_recognition_sequence: block = %ld, " - "address = %Ld, ", block, address)); + TRACE(("walk_volume_recognition_sequence: block = %" B_PRIu32 ", " + "address = %" B_PRIdOFF ", ", block, address)); ssize_t bytesRead = read_pos(device, address, chunk.Data(), blockSize); if (bytesRead == (ssize_t)blockSize) { volume_structure_descriptor_header* descriptor @@ -155,8 +156,8 @@ walk_volume_recognition_sequence(int device, off_t offset, uint32 blockSize, break; } } else { - TRACE_ERROR(("read_pos(pos:%Ld, len:%ld) failed with: 0x%lx\n", address, - blockSize, bytesRead)); + TRACE_ERROR(("read_pos(pos:%" B_PRIdOFF ", len:%" B_PRIu32 ") " + "failed with: 0x%lx\n", address, blockSize, bytesRead)); break; } } diff --git a/src/add-ons/kernel/file_systems/udf/SparablePartition.cpp b/src/add-ons/kernel/file_systems/udf/SparablePartition.cpp index 124e191d6e..480bbb498c 100644 --- a/src/add-ons/kernel/file_systems/udf/SparablePartition.cpp +++ b/src/add-ons/kernel/file_systems/udf/SparablePartition.cpp @@ -19,8 +19,9 @@ SparablePartition::SparablePartition(uint16 number, uint32 start, uint32 length, fTableCount(tableCount), fInitStatus(B_NO_INIT) { - TRACE(("SparablePartition::SparablePartition: number = %d, start = %lu," - "length = %lu, packetLength = %d\n", number, start, length, packetLength)); + TRACE(("SparablePartition::SparablePartition: number = %d, start = %" + B_PRIu32 ",length = %" B_PRIu32 ", packetLength = %d\n", number, start, + length, packetLength)); status_t status = (0 < TableCount() && TableCount() <= kMaxSparingTableCount) ? B_OK : B_BAD_VALUE; diff --git a/src/add-ons/kernel/file_systems/udf/UdfString.cpp b/src/add-ons/kernel/file_systems/udf/UdfString.cpp index 2e0eb472d9..b7eaa95c58 100644 --- a/src/add-ons/kernel/file_systems/udf/UdfString.cpp +++ b/src/add-ons/kernel/file_systems/udf/UdfString.cpp @@ -147,8 +147,8 @@ UdfString::SetTo(const char *utf8) // First copy the utf8 string fUtf8String = new(nothrow) char[length + 1]; if (fUtf8String == NULL) { - TRACE_ERROR(("UdfString::SetTo: fUtf8String[%ld] allocation failed\n", - length + 1)); + TRACE_ERROR(("UdfString::SetTo: fUtf8String[%" B_PRIu32 + "] allocation failed\n", length + 1)); return; } @@ -159,8 +159,8 @@ UdfString::SetTo(const char *utf8) // or have to use burly 16-bit unicode. uint32 *raw = new(nothrow) uint32[length]; if (raw == NULL) { - TRACE_ERROR(("UdfString::SetTo: uint32 raw[%ld] temporary string " - "allocation failed\n", length)); + TRACE_ERROR(("UdfString::SetTo: uint32 raw[%" B_PRIu32 "] temporary" + " string allocation failed\n", length)); _Clear(); return; } @@ -201,8 +201,8 @@ UdfString::SetTo(const char *utf8) for (uint32 i = 0; i < rawLength; i++) fCs0String[i + 1] = raw[i] % 256; } else { - TRACE_ERROR(("UdfString::SetTo: fCs0String[%ld] allocation failed\n", - fCs0Length)); + TRACE_ERROR(("UdfString::SetTo: fCs0String[%" B_PRIu32 + "] allocation failed\n", fCs0Length)); _Clear(); return; } @@ -221,8 +221,8 @@ UdfString::SetTo(const char *utf8) fCs0String[pos++] = low; } } else { - TRACE_ERROR(("UdfString::SetTo: fCs0String[%ld] allocation failed\n", - fCs0Length)); + TRACE_ERROR(("UdfString::SetTo: fCs0String[%" B_PRIu32 + "] allocation failed\n", fCs0Length)); _Clear(); return; } diff --git a/src/add-ons/kernel/file_systems/udf/UdfString.h b/src/add-ons/kernel/file_systems/udf/UdfString.h index 8db6127ddf..4d64fb36d1 100644 --- a/src/add-ons/kernel/file_systems/udf/UdfString.h +++ b/src/add-ons/kernel/file_systems/udf/UdfString.h @@ -61,7 +61,8 @@ UdfString::UdfString(const array &dString) : fCs0String(NULL) , fUtf8String(NULL) { - TRACE(("UdfString::UdfString: dString.length(): %ld", dString.length())); + TRACE(("UdfString::UdfString: dString.length(): %" B_PRIu32, + dString.length())); SetTo(dString); } diff --git a/src/add-ons/kernel/file_systems/udf/Utils.cpp b/src/add-ons/kernel/file_systems/udf/Utils.cpp index 111e41036d..f93aabe471 100644 --- a/src/add-ons/kernel/file_systems/udf/Utils.cpp +++ b/src/add-ons/kernel/file_systems/udf/Utils.cpp @@ -153,8 +153,8 @@ decode_time(timestamp ×tamp, struct timespec ×pec) long_address to_long_address(ino_t id, uint32 length) { - TRACE(("udf_to_long_address: ino_t = %Ld (0x%Lx), length = %ld", - id, id, length)); + TRACE(("udf_to_long_address: ino_t = %" B_PRIdINO ", length = %" B_PRIu32, + id, length)); long_address result; result.set_block((id >> 16) & 0xffffffff); result.set_partition(id & 0xffff); @@ -171,9 +171,11 @@ to_vnode_id(long_address address) ino_t result = address.block(); result <<= 16; result |= address.partition(); - TRACE(("block: %ld, 0x%lx\n", address.block(), address.block())); + TRACE(("block: %" B_PRIu32 ", 0x%" B_PRIx32 "\n", address.block(), + address.block())); TRACE(("partition: %d, 0x%x\n", address.partition(), address.partition())); - TRACE(("length: %ld, 0x%lx\n", address.length(), address.length())); - TRACE(("ino_t: %Ld, 0x%Lx\n", result, result)); + TRACE(("length: %" B_PRIu32 ", 0x%" B_PRIx32 "\n", address.length(), + address.length())); + TRACE(("ino_t: %" B_PRIdINO "\n", result)); return result; } diff --git a/src/add-ons/kernel/file_systems/udf/Volume.cpp b/src/add-ons/kernel/file_systems/udf/Volume.cpp index 87360165a2..7222003de2 100644 --- a/src/add-ons/kernel/file_systems/udf/Volume.cpp +++ b/src/add-ons/kernel/file_systems/udf/Volume.cpp @@ -48,9 +48,9 @@ status_t Volume::Mount(const char *deviceName, off_t offset, off_t length, uint32 blockSize, uint32 flags) { - TRACE(("Volume::Mount: deviceName = `%s', offset = %Ld, length = %Ld, " - "blockSize: %ld, flags: %ld\n", deviceName, offset, length, blockSize, - flags)); + TRACE(("Volume::Mount: deviceName = `%s', offset = %" B_PRIdOFF ", length " + "= %" B_PRIdOFF ", blockSize: %" B_PRIu32 ", flags: %" B_PRIu32 "\n", + deviceName, offset, length, blockSize, flags)); if (!deviceName) return B_BAD_VALUE; if (Mounted()) @@ -134,8 +134,9 @@ Volume::Mount(const char *deviceName, off_t offset, off_t length, status = partition ? B_OK : B_NO_MEMORY; if (!status) { TRACE(("Volume::Mount: adding PhysicalPartition(number: %d, " - "start: %ld, length: %ld)\n", map->partition_number(), - descriptor->start(), descriptor->length())); + "start: %" B_PRIu32 ", length: %" B_PRIu32 ")\n", + map->partition_number(), descriptor->start(), + descriptor->length())); status = _SetPartition(i, partition); if (!status) physicalCount++; @@ -197,7 +198,7 @@ Volume::Mount(const char *deviceName, off_t offset, off_t length, metadataCount++; } else { TRACE_ERROR(("Volume::Mount: metadata partition " - "creation failed! 0x%lx\n", status)); + "creation failed! 0x%" B_PRIx32 "\n", status)); } } else { TRACE_ERROR(("Volume::Mount: no matching partition descriptor found!\n")); @@ -241,9 +242,9 @@ Volume::Mount(const char *deviceName, off_t offset, off_t length, fBlockSize = blockSize; fBlockShift = blockShift; } - TRACE(("Volume::Mount: device = %d, offset = %Ld, length = %Ld, " - "blockSize = %ld, blockShift = %ld\n", device, offset, length, - blockSize, blockShift)); + TRACE(("Volume::Mount: device = %d, offset = %" B_PRIdOFF ", length = %" + B_PRIdOFF ", blockSize = %" B_PRIu32 ", blockShift = %" B_PRIu32 "\n", + device, offset, length, blockSize, blockShift)); // At this point we've found a valid set of volume descriptors and // our partitions are all set up. We now need to investigate the file // set descriptor pointed to by the logical volume descriptor. @@ -265,8 +266,9 @@ Volume::Mount(const char *deviceName, off_t offset, off_t length, = read_pos(device, address, chunk.Data(), blockSize); if (bytesRead != ssize_t(blockSize)) { status = B_IO_ERROR; - TRACE_ERROR(("read_pos(pos:%Ld, len:%ld) failed with: 0x%lx\n", - address, blockSize, bytesRead)); + TRACE_ERROR(("read_pos(pos:%" B_PRIdOFF ", len:%" B_PRIu32 + ") failed with: 0x%lx\n", address, blockSize, + bytesRead)); } } // See if it's valid, and if so, create the root icb @@ -286,21 +288,22 @@ Volume::Mount(const char *deviceName, off_t offset, off_t length, return B_NO_MEMORY; } - TRACE(("Volume::Mount: Root Node id = %Ld\n", fRootIcb->Id())); + TRACE(("Volume::Mount: Root Node id = %" B_PRIdINO "\n", + fRootIcb->Id())); if (!status) { status = publish_vnode(fFSVolume, fRootIcb->Id(), fRootIcb, &gUDFVnodeOps, fRootIcb->Mode(), 0); if (status != B_OK) { TRACE_ERROR(("Error creating vnode for root icb! " - "status = 0x%lx, `%s'\n", status, + "status = 0x%" B_PRIx32 ", `%s'\n", status, strerror(status))); // Clean up the icb we created, since _Unset() // won't do this for us. delete fRootIcb; fRootIcb = NULL; } - TRACE(("Volume::Mount: Root vnode published. Id = %Ld\n", - fRootIcb->Id())); + TRACE(("Volume::Mount: Root vnode published. Id = %" + B_PRIdINO "\n", fRootIcb->Id())); } } } @@ -330,10 +333,12 @@ Volume::Name() const { status_t Volume::MapBlock(long_address address, off_t *mappedBlock) { - TRACE(("Volume::MapBlock: partition = %d, block = %ld, mappedBlock = %p\n", - address.partition(), address.block(), mappedBlock)); - DEBUG_INIT_ETC("Volume", ("partition = %d, block = %ld, mappedBlock = %p", - address.partition(), address.block(), mappedBlock)); + TRACE(("Volume::MapBlock: partition = %d, block = %" B_PRIu32 + ", mappedBlock = %p\n", address.partition(), address.block(), + mappedBlock)); + DEBUG_INIT_ETC("Volume", ("partition = %d, block = %" B_PRIu32 + ", mappedBlock = %p", address.partition(), address.block(), + mappedBlock)); status_t error = mappedBlock ? B_OK : B_BAD_VALUE; if (!error) { Partition *partition = _GetPartition(address.partition()); diff --git a/src/add-ons/kernel/file_systems/udf/kernel_interface.cpp b/src/add-ons/kernel/file_systems/udf/kernel_interface.cpp index 06a3a292b9..7c0b6d40de 100644 --- a/src/add-ons/kernel/file_systems/udf/kernel_interface.cpp +++ b/src/add-ons/kernel/file_systems/udf/kernel_interface.cpp @@ -410,8 +410,8 @@ udf_open_dir(fs_volume *volume, fs_vnode *vnode, void **cookie) DirectoryIterator *iterator = NULL; status_t status = dir->GetDirectoryIterator(&iterator); if (status != B_OK) { - TRACE_ERROR(("udf_open_dir: error getting directory iterator: 0x%lx, " - "`%s'\n", status, strerror(status))); + TRACE_ERROR(("udf_open_dir: error getting directory iterator: 0x%" + B_PRIx32 ", `%s'\n", status, strerror(status))); return status; } *cookie = (void *)iterator; diff --git a/src/add-ons/kernel/generic/mpu401/mpu401.c b/src/add-ons/kernel/generic/mpu401/mpu401.c index e68c99e2ec..cb61dc3f28 100644 --- a/src/add-ons/kernel/generic/mpu401/mpu401.c +++ b/src/add-ons/kernel/generic/mpu401/mpu401.c @@ -237,7 +237,7 @@ midi_close(void * cookie) delete_sem(mpu_device->writesemaphore); atomic_add(&mpu_device->count, -1); - PRINT(("midi_close() done (count = %lu)\n", mpu_device->count)); + PRINT(("midi_close() done (count = %" B_PRId32 ")\n", mpu_device->count)); return B_OK; } diff --git a/src/add-ons/kernel/partitioning_systems/gpt/Header.cpp b/src/add-ons/kernel/partitioning_systems/gpt/Header.cpp index 289f926ada..4fbc15965c 100644 --- a/src/add-ons/kernel/partitioning_systems/gpt/Header.cpp +++ b/src/add-ons/kernel/partitioning_systems/gpt/Header.cpp @@ -336,7 +336,7 @@ Header::_PrintGUID(const guid_t &id) { static char guid[48]; snprintf(guid, sizeof(guid), - "%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", + "%08" B_PRIx32 "-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", B_LENDIAN_TO_HOST_INT32(id.data1), B_LENDIAN_TO_HOST_INT16(id.data2), B_LENDIAN_TO_HOST_INT16(id.data3), id.data4[0], id.data4[1], id.data4[2], id.data4[3], id.data4[4], id.data4[5], id.data4[6], @@ -350,17 +350,17 @@ Header::_Dump(const efi_table_header& header) { dprintf("EFI header: %.8s\n", header.header); dprintf("EFI revision: %" B_PRIx32 "\n", header.Revision()); - dprintf("header size: %ld\n", header.HeaderSize()); - dprintf("header CRC: %ld\n", header.HeaderCRC()); - dprintf("absolute block: %Ld\n", header.AbsoluteBlock()); - dprintf("alternate block: %Ld\n", header.AlternateBlock()); - dprintf("first usable block: %Ld\n", header.FirstUsableBlock()); - dprintf("last usable block: %Ld\n", header.LastUsableBlock()); + dprintf("header size: %" B_PRId32 "\n", header.HeaderSize()); + dprintf("header CRC: %" B_PRId32 "\n", header.HeaderCRC()); + dprintf("absolute block: %" B_PRIu64 "\n", header.AbsoluteBlock()); + dprintf("alternate block: %" B_PRIu64 "\n", header.AlternateBlock()); + dprintf("first usable block: %" B_PRIu64 "\n", header.FirstUsableBlock()); + dprintf("last usable block: %" B_PRIu64 "\n", header.LastUsableBlock()); dprintf("disk GUID: %s\n", _PrintGUID(header.disk_guid)); - dprintf("entries block: %Ld\n", header.EntriesBlock()); - dprintf("entry size: %ld\n", header.EntrySize()); - dprintf("entry count: %ld\n", header.EntryCount()); - dprintf("entries CRC: %ld\n", header.EntriesCRC()); + dprintf("entries block: %" B_PRIu64 "\n", header.EntriesBlock()); + dprintf("entry size: %" B_PRIu32 "\n", header.EntrySize()); + dprintf("entry count: %" B_PRIu32 "\n", header.EntryCount()); + dprintf("entries CRC: %" B_PRIu32 "\n", header.EntriesCRC()); } @@ -373,14 +373,14 @@ Header::_DumpPartitions() if (entry.partition_type == kEmptyGUID) continue; - dprintf("[%3ld] partition type: %s\n", i, + dprintf("[%3" B_PRIu32 "] partition type: %s\n", i, _PrintGUID(entry.partition_type)); dprintf(" unique id: %s\n", _PrintGUID(entry.unique_guid)); - dprintf(" start block: %Ld\n", entry.StartBlock()); - dprintf(" end block: %Ld\n", entry.EndBlock()); + dprintf(" start block: %" B_PRIu64 "\n", entry.StartBlock()); + dprintf(" end block: %" B_PRIu64 "\n", entry.EndBlock()); dprintf(" size: %g MB\n", (entry.EndBlock() - entry.StartBlock()) * 512 / 1024.0 / 1024.0); - dprintf(" attributes: %Lx\n", entry.Attributes()); + dprintf(" attributes: %" B_PRIx64 "\n", entry.Attributes()); char name[64]; to_utf8(entry.name, EFI_PARTITION_NAME_LENGTH, name, sizeof(name)); diff --git a/src/add-ons/kernel/partitioning_systems/gpt/efi_gpt.cpp b/src/add-ons/kernel/partitioning_systems/gpt/efi_gpt.cpp index 8dbf7ad741..ad8f784bca 100644 --- a/src/add-ons/kernel/partitioning_systems/gpt/efi_gpt.cpp +++ b/src/add-ons/kernel/partitioning_systems/gpt/efi_gpt.cpp @@ -119,7 +119,8 @@ efi_gpt_scan_partition(int fd, partition_data* partition, void* _cookie) partition->offset + entry.StartBlock() * partition->block_size, entry.BlockCount() * partition->block_size, -1); if (child == NULL) { - TRACE(("efi_gpt: Creating child at index %ld failed\n", index - 1)); + TRACE(("efi_gpt: Creating child at index %" B_PRIu32 " failed\n", + index - 1)); return B_ERROR; } @@ -128,7 +129,7 @@ efi_gpt_scan_partition(int fd, partition_data* partition, void* _cookie) child->name = strdup(name); child->type = strdup(get_partition_type(entry.partition_type)); child->block_size = partition->block_size; - child->cookie = (void*)i; + child->cookie = (void*)(addr_t)i; } return B_OK; @@ -492,7 +493,7 @@ efi_gpt_resize_child(int fd, partition_id partitionID, off_t size, if (header == NULL) return B_BAD_VALUE; - uint32 entryIndex = (uint32)child->cookie; + uint32 entryIndex = (uint32)(addr_t)child->cookie; if (entryIndex >= header->EntryCount()) return B_BAD_VALUE; @@ -553,7 +554,7 @@ efi_gpt_move_child(int fd, partition_id partitionID, partition_id childID, if (header == NULL) return B_BAD_VALUE; - uint32 entryIndex = (uint32)child->cookie; + uint32 entryIndex = (uint32)(addr_t)child->cookie; if (entryIndex >= header->EntryCount()) return B_BAD_VALUE; @@ -614,7 +615,7 @@ efi_gpt_set_content_name(int fd, partition_id partitionID, const char* name, if (header == NULL) return B_BAD_VALUE; - uint32 entryIndex = (uint32)child->cookie; + uint32 entryIndex = (uint32)(addr_t)child->cookie; if (entryIndex >= header->EntryCount()) return B_BAD_VALUE; @@ -660,7 +661,7 @@ efi_gpt_set_type(int fd, partition_id partitionID, const char* type, if (header == NULL) return B_BAD_VALUE; - uint32 entryIndex = (uint32)child->cookie; + uint32 entryIndex = (uint32)(addr_t)child->cookie; if (entryIndex >= header->EntryCount()) return B_BAD_VALUE; @@ -777,7 +778,7 @@ efi_gpt_create_child(int fd, partition_id partitionID, off_t offset, child->name = strdup(name); child->type = strdup(type); child->parameters = strdup(parameters); - child->cookie = (void*)entryIndex; + child->cookie = (void*)(addr_t)entryIndex; if (child->type == NULL || child->parameters == NULL) { delete_partition(child->id); @@ -813,7 +814,7 @@ efi_gpt_delete_child(int fd, partition_id partitionID, partition_id childID, if (header == NULL) return B_BAD_VALUE; - uint32 entryIndex = (uint32)child->cookie; + uint32 entryIndex = (uint32)(addr_t)child->cookie; if (entryIndex >= header->EntryCount()) return B_BAD_VALUE; diff --git a/src/add-ons/mail_daemon/inbound_filters/match_header/ConfigView.cpp b/src/add-ons/mail_daemon/inbound_filters/match_header/ConfigView.cpp index 03e8487ebf..38936ec26a 100644 --- a/src/add-ons/mail_daemon/inbound_filters/match_header/ConfigView.cpp +++ b/src/add-ons/mail_daemon/inbound_filters/match_header/ConfigView.cpp @@ -85,7 +85,7 @@ RuleFilterConfig::RuleFilterConfig(const BMessage *settings) chain = settings->FindInt32("argument"); else chain = -1; - printf("Chain: %ld\n",chain); + printf("Chain: %" B_PRId32 "\n",chain); BMailAccounts accounts; for (int32 i = 0; i < accounts.CountAccounts(); i++) { diff --git a/src/add-ons/mail_daemon/inbound_filters/match_header/RuleFilter.cpp b/src/add-ons/mail_daemon/inbound_filters/match_header/RuleFilter.cpp index 512a00247c..ed3bf8a74b 100644 --- a/src/add-ons/mail_daemon/inbound_filters/match_header/RuleFilter.cpp +++ b/src/add-ons/mail_daemon/inbound_filters/match_header/RuleFilter.cpp @@ -43,7 +43,7 @@ RuleFilter::RuleFilter(MailProtocol& protocol, AddonSettings* addonSettings) fMatcher.SetPattern(regex, false); settings->FindString("argument",&fArg); - settings->FindInt32("do_what",(long *)&fDoWhat); + settings->FindInt32("do_what", (int32*)&fDoWhat); if (fDoWhat == Z_SET_REPLY) settings->FindInt32("argument", &fReplyAccount); } diff --git a/src/add-ons/mail_daemon/inbound_filters/spam_filter/SpamFilterConfig.cpp b/src/add-ons/mail_daemon/inbound_filters/spam_filter/SpamFilterConfig.cpp index bc71405e1d..2d0820ba48 100644 --- a/src/add-ons/mail_daemon/inbound_filters/spam_filter/SpamFilterConfig.cpp +++ b/src/add-ons/mail_daemon/inbound_filters/spam_filter/SpamFilterConfig.cpp @@ -414,7 +414,7 @@ AGMSBayesianSpamFilterConfig::ShowSpamServerConfigurationWindow () { maximizeCommand.what = B_SET_PROPERTY; maximizeCommand.AddBool ("data", false); maximizeCommand.AddSpecifier ("Minimize"); - maximizeCommand.AddSpecifier ("Window", 0L); + maximizeCommand.AddSpecifier ("Window", (int32)0); errorCode = messengerToServer.SendMessage (&maximizeCommand, &replyMessage); if (errorCode != B_OK) goto ErrorExit; diff --git a/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPProtocol.cpp b/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPProtocol.cpp index 6f33929002..8297b9de54 100644 --- a/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPProtocol.cpp +++ b/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPProtocol.cpp @@ -297,7 +297,7 @@ IMAPProtocol::SendCommand(const char* command, int32 commandID) return B_NO_MEMORY; static char cmd[256]; - ::sprintf(cmd, "A%.7ld %s"CRLF, commandID, command); + ::sprintf(cmd, "A%.7" B_PRId32 " %s"CRLF, commandID, command); TRACE("_SendCommand: %s\n", cmd); int commandLength = strlen(cmd); @@ -347,7 +347,7 @@ IMAPProtocol::HandleResponse(int32 commandID, bigtime_t timeout, for (std::vector::iterator it = fOngoingCommands.begin(); it != fOngoingCommands.end(); it++) { static char idString[8]; - ::sprintf(idString, "A%.7ld", *it); + ::sprintf(idString, "A%.7" B_PRId32, *it); if (line.FindFirst(idString) >= 0) { if (*it == commandID) { BString result = IMAPParser::ExtractElementAfter(line, diff --git a/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPStorage.cpp b/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPStorage.cpp index 17c6f043de..762fad56f3 100644 --- a/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPStorage.cpp +++ b/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPStorage.cpp @@ -240,7 +240,7 @@ IMAPStorage::DeleteMessage(int32 uid) BPath filePath = fMailboxPath; filePath.Append(storageEntry.fileName); BEntry entry(filePath.Path()); - TRACE("IMAPStorage::DeleteMessage %s, %ld\n", filePath.Path(), uid); + TRACE("IMAPStorage::DeleteMessage %s, %" B_PRId32 "\n", filePath.Path(), uid); status_t status = entry.Remove(); if (status != B_OK) diff --git a/src/add-ons/mail_daemon/inbound_protocols/pop3/MessageIO.cpp b/src/add-ons/mail_daemon/inbound_protocols/pop3/MessageIO.cpp index 58913947ab..a49a77108b 100644 --- a/src/add-ons/mail_daemon/inbound_protocols/pop3/MessageIO.cpp +++ b/src/add-ons/mail_daemon/inbound_protocols/pop3/MessageIO.cpp @@ -102,7 +102,7 @@ BMailMessageIO::ReadAt(off_t pos, void* buffer, size_t amountToRead) // Put the file position back at where it was, if possible. That's because // ReadAt isn't supposed to affect the file position. - if (oldPosition < fSize) + if (oldPosition < (off_t)fSize) fSlave->Seek (oldPosition, SEEK_SET); else fSlave->Seek (0, SEEK_END); diff --git a/src/add-ons/mail_daemon/inbound_protocols/pop3/pop3.cpp b/src/add-ons/mail_daemon/inbound_protocols/pop3/pop3.cpp index 25a391d6ed..078b45ebe9 100644 --- a/src/add-ons/mail_daemon/inbound_protocols/pop3/pop3.cpp +++ b/src/add-ons/mail_daemon/inbound_protocols/pop3/pop3.cpp @@ -494,8 +494,9 @@ POP3Protocol::Stat() if (SendCommand("STAT" CRLF) < B_OK) return B_ERROR; - int32 messages,dropSize; - if (sscanf(fLog.String(), "+OK %ld %ld", &messages, &dropSize) < 2) + int32 messages, dropSize; + if (sscanf(fLog.String(), "+OK %" B_SCNd32" %" B_SCNd32, &messages, + &dropSize) < 2) return B_ERROR; fNumMessages = messages; @@ -591,11 +592,11 @@ POP3Protocol::Retrieve(int32 message, BPositionIO *write_to) int32 message_len = MessageSize(message); write_to->Seek (0, SEEK_END); if (write_to->Position() != message_len) { - printf ("POP3Protocol::Retrieve Note: message size is %d, was " - "expecting %ld, for message #%ld. Could be a transmission error " - "or a bad POP server implementation (does it remove escape codes " - "when it counts size?).\n", - (int) write_to->Position(), message_len, message); + printf ("POP3Protocol::Retrieve Note: message size is %" B_PRIdOFF + ", was expecting %" B_PRId32 ", for message #%" B_PRId32 ". " + "Could be a transmission error or a bad POP server " + "implementation (does it remove escape codes when it counts " + "size?).\n", write_to->Position(), message_len, message); } } @@ -916,7 +917,7 @@ POP3Protocol::_UniqueIDs() b = atol(&(result.String()[b])); else b = 0; - fSizes.AddItem((void *)(b)); + fSizes.AddItem((void *)(addr_t)b); } return ret; diff --git a/src/add-ons/media/media-add-ons/mixer/AudioMixer.cpp b/src/add-ons/media/media-add-ons/mixer/AudioMixer.cpp index b138573f55..5bcc8208aa 100644 --- a/src/add-ons/media/media-add-ons/mixer/AudioMixer.cpp +++ b/src/add-ons/media/media-add-ons/mixer/AudioMixer.cpp @@ -321,7 +321,8 @@ void AudioMixer::HandleInputBuffer(BBuffer* buffer, bigtime_t lateness) { if (lateness > kMaxJitter && lateness > fLastLateness) { - debug_printf("AudioMixer: Dequeued input buffer %Ld usec late\n", lateness); + debug_printf("AudioMixer: Dequeued input buffer %" B_PRIdBIGTIME + " usec late\n", lateness); if (RunMode() == B_DROP_DATA || RunMode() == B_DECREASE_PRECISION || RunMode() == B_INCREASE_LATENCY) { debug_printf("AudioMixer: sending notify\n"); @@ -380,8 +381,8 @@ AudioMixer::GetLatencyFor(const media_destination &for_whom, *out_latency = EventLatency(); *out_timesource = TimeSource()->ID(); - printf("AudioMixer::GetLatencyFor %Ld, timesource is %ld\n", - *out_latency, *out_timesource); + printf("AudioMixer::GetLatencyFor %" B_PRIdBIGTIME ", timesource is %" + B_PRId32 "\n", *out_latency, *out_timesource); return B_OK; } @@ -398,8 +399,8 @@ AudioMixer::Connected(const media_source &producer, // BBufferProducer::PrepareToConnect() should have removed all wildcards. if (out_input->format.u.raw_audio.frame_rate == 0) { fprintf(stderr, "Audio Mixer Warning: " - "Producer (port %ld, id %ld) connected with frame_rate=0\n", - producer.port, producer.id); + "Producer (port %" B_PRId32 ", id %" B_PRId32 ") connected with " + "frame_rate=0\n", producer.port, producer.id); MixerOutput *output = fCore->Output(); float frame_rate = output ? output->MediaOutput().format.u.raw_audio.frame_rate : 44100.0f; @@ -422,8 +423,10 @@ AudioMixer::Connected(const media_source &producer, // name, the name given the connection by the producer may still be an // empty string. // if the input has no name, assign one - if (strlen(out_input->name) == 0) - sprintf(out_input->name, "Input %ld", out_input->destination.id); + if (strlen(out_input->name) == 0) { + sprintf(out_input->name, "Input %" B_PRId32, + out_input->destination.id); + } // add a new input to the mixer engine MixerInput *input; @@ -607,16 +610,19 @@ AudioMixer::FormatChangeRequested(const media_source &source, media_node_id id; FindLatencyFor(destination, &fDownstreamLatency, &id); - TRACE("AudioMixer: Downstream Latency is %Ld usecs\n", fDownstreamLatency); + TRACE("AudioMixer: Downstream Latency is %" B_PRIdBIGTIME " usecs\n", + fDownstreamLatency); // SetDuration of one buffer SetBufferDuration(buffer_duration(io_format->u.raw_audio)); - TRACE("AudioMixer: buffer duration is %Ld usecs\n", BufferDuration()); + TRACE("AudioMixer: buffer duration is %" B_PRIdBIGTIME " usecs\n", + BufferDuration()); // Our internal latency is at least the length of a full output buffer fInternalLatency = BufferDuration() - + max(4500LL, bigtime_t(0.5 * BufferDuration())); - TRACE("AudioMixer: Internal latency is %Ld usecs\n", fInternalLatency); + + max((bigtime_t)4500, bigtime_t(0.5 * BufferDuration())); + TRACE("AudioMixer: Internal latency is %" B_PRIdBIGTIME " usecs\n", + fInternalLatency); SetEventLatency(fDownstreamLatency + fInternalLatency); @@ -1020,7 +1026,8 @@ AudioMixer::LateNoticeReceived(const media_source& what, bigtime_t howMuch, fLastLateNotification = TimeSource()->Now() + howMuch; - debug_printf("AudioMixer: increasing internal latency to %Ld usec\n", fInternalLatency); + debug_printf("AudioMixer: increasing internal latency to %" + B_PRIdBIGTIME " usec\n", fInternalLatency); SetEventLatency(fDownstreamLatency + fInternalLatency); PublishEventLatencyChange(); diff --git a/src/add-ons/media/media-add-ons/mixer/MixerCore.cpp b/src/add-ons/media/media-add-ons/mixer/MixerCore.cpp index 3ff2a8fecc..4931f4560d 100644 --- a/src/add-ons/media/media-add-ons/mixer/MixerCore.cpp +++ b/src/add-ons/media/media-add-ons/mixer/MixerCore.cpp @@ -492,7 +492,7 @@ MixerCore::_MixThread() if (!LockFromMixThread()) return; - bigtime_t latency = max(3600LL, bigtime_t(0.4 * buffer_duration( + bigtime_t latency = max((bigtime_t)3600, bigtime_t(0.4 * buffer_duration( fOutput->MediaOutput().format.u.raw_audio))); // TODO: when the format changes while running, everything is wrong! diff --git a/src/add-ons/media/media-add-ons/mixer/MixerInput.cpp b/src/add-ons/media/media-add-ons/mixer/MixerInput.cpp index 5bb5085f61..420a2d728b 100644 --- a/src/add-ons/media/media-add-ons/mixer/MixerInput.cpp +++ b/src/add-ons/media/media-add-ons/mixer/MixerInput.cpp @@ -183,22 +183,24 @@ MixerInput::BufferReceived(BBuffer* buffer) offset = expected_frame; } else { printf("MixerInput::BufferReceived: GLITCH! last frame was " - "%4ld, expected frame was %4d, new frame is %4d\n", - fLastDataFrameWritten, expected_frame, offset); + "%4" B_PRId32 ", expected frame was %4d, new frame is %4d" + "\n", fLastDataFrameWritten, expected_frame, offset); if (start > fLastDataAvailableTime) { if ((start - fLastDataAvailableTime) < (buffer_duration / 10)) { // buffer is less than 10% of buffer duration too late printf("short glitch, buffer too late, time delta " - "%Ld\n", start - fLastDataAvailableTime); + "%" B_PRIdBIGTIME "\n", start + - fLastDataAvailableTime); offset = expected_frame; out_frames++; } else { // buffer more than 10% of buffer duration too late // TODO: zerofill buffer printf("MAJOR glitch, buffer too late, time delta " - "%Ld\n", start - fLastDataAvailableTime); + "%" B_PRIdBIGTIME "\n", start + - fLastDataAvailableTime); } } else { // start <= fLastDataAvailableTime // the new buffer is too early @@ -206,7 +208,8 @@ MixerInput::BufferReceived(BBuffer* buffer) < (buffer_duration / 10)) { // buffer is less than 10% of buffer duration too early printf("short glitch, buffer too early, time delta " - "%Ld\n", fLastDataAvailableTime - start); + "%" B_PRIdBIGTIME "\n", fLastDataAvailableTime + - start); offset = expected_frame; out_frames--; if (out_frames < 1) @@ -215,7 +218,8 @@ MixerInput::BufferReceived(BBuffer* buffer) // buffer more than 10% of buffer duration too early // TODO: zerofill buffer printf("MAJOR glitch, buffer too early, time delta " - "%Ld\n", fLastDataAvailableTime - start); + "%" B_PRIdBIGTIME "\n", fLastDataAvailableTime + - start); } } } diff --git a/src/add-ons/media/media-add-ons/mixer/MixerUtils.cpp b/src/add-ons/media/media-add-ons/mixer/MixerUtils.cpp index ce28d01de6..a050bea7eb 100644 --- a/src/add-ons/media/media-add-ons/mixer/MixerUtils.cpp +++ b/src/add-ons/media/media-add-ons/mixer/MixerUtils.cpp @@ -53,7 +53,7 @@ StringForChannelMask(char *str, uint32 mask) DECODE(B_CHANNEL_MONO, "Mono"); #undef DECODE if (mask) - sprintf(str + strlen(str), "0x%08lX", mask); + sprintf(str + strlen(str), "0x%08" B_PRIx32, mask); return str; } diff --git a/src/add-ons/media/media-add-ons/multi_audio/MultiAudioNode.cpp b/src/add-ons/media/media-add-ons/multi_audio/MultiAudioNode.cpp index ffac270c82..ddac66162e 100644 --- a/src/add-ons/media/media-add-ons/multi_audio/MultiAudioNode.cpp +++ b/src/add-ons/media/media-add-ons/multi_audio/MultiAudioNode.cpp @@ -364,7 +364,7 @@ MultiAudioNode::NodeRegistered() input->destination.port = ControlPort(); input->destination.id = fInputs.CountItems(); input->node = Node(); - sprintf(input->name, "output %ld", input->destination.id); + sprintf(input->name, "output %" B_PRId32, input->destination.id); currentInput = new node_input(*input, fOutputPreferredFormat); currentInput->fPreferredFormat.u.raw_audio.channel_count = 1; @@ -414,7 +414,7 @@ MultiAudioNode::NodeRegistered() output->source.port = ControlPort(); output->source.id = fOutputs.CountItems(); output->node = Node(); - sprintf(output->name, "input %ld", output->source.id); + sprintf(output->name, "input %" B_PRId32, output->source.id); currentOutput = new node_output(*output, fInputPreferredFormat); currentOutput->fPreferredFormat.u.raw_audio.channel_count = 1; @@ -1014,8 +1014,10 @@ MultiAudioNode::Disconnect(const media_source& what, delete channel->fBufferGroup; channel->fBufferGroup = NULL; } else { - fprintf(stderr, "\tDisconnect() called with wrong source/destination (%ld/%ld), ours is (%ld/%ld)\n", - what.id, where.id, channel->fOutput.source.id, channel->fOutput.destination.id); + fprintf(stderr, "\tDisconnect() called with wrong source/destination (" + "%" B_PRId32 "/%" B_PRId32 "), ours is (%" B_PRId32 "/%" B_PRId32 + ")\n", what.id, where.id, channel->fOutput.source.id, + channel->fOutput.destination.id); } } @@ -1047,7 +1049,7 @@ MultiAudioNode::LateNoticeReceived(const media_source& what, bigtime_t howMuch, fInternalLatency += howMuch; SetEventLatency(fLatency + fInternalLatency); - fprintf(stderr, "\tincreasing latency to %Ld\n", + fprintf(stderr, "\tincreasing latency to %" B_PRIdBIGTIME"\n", fLatency + fInternalLatency); } else { // The other run modes dictate various strategies for sacrificing data @@ -1122,7 +1124,7 @@ MultiAudioNode::HandleEvent(const media_timed_event* event, bigtime_t lateness, _HandleParameter(event, lateness, realTimeEvent); break; default: - fprintf(stderr," unknown event type: %li\n", event->type); + fprintf(stderr," unknown event type: %" B_PRId32 "\n", event->type); break; } } @@ -1158,7 +1160,7 @@ MultiAudioNode::_HandleBuffer(const media_timed_event* event, // lateness doesn't matter in offline mode or in recording mode //mLateBuffers++; NotifyLateProducer(channel->fInput.source, -howEarly, performanceTime); - fprintf(stderr," <- LATE BUFFER : %lli\n", howEarly); + fprintf(stderr," <- LATE BUFFER : %" B_PRIdBIGTIME "\n", howEarly); buffer->Recycle(); } else { //WriteBuffer(buffer, *channel); diff --git a/src/add-ons/media/media-add-ons/opensound/OpenSoundDevice.cpp b/src/add-ons/media/media-add-ons/opensound/OpenSoundDevice.cpp index df9fd14f2d..427d3020fc 100644 --- a/src/add-ons/media/media-add-ons/opensound/OpenSoundDevice.cpp +++ b/src/add-ons/media/media-add-ons/opensound/OpenSoundDevice.cpp @@ -364,8 +364,8 @@ status_t OpenSoundDevice::InitDriver() { CALLED(); - PRINT(("OpenSoundDevice::InitDriver: %ld engines, %ld mixers\n", - CountEngines(), CountMixers())); + PRINT(("OpenSoundDevice::InitDriver: %" B_PRId32 " engines, %" B_PRId32 + " mixers\n", CountEngines(), CountMixers())); if (CountMixers()) { ;//... diff --git a/src/add-ons/media/media-add-ons/opensound/OpenSoundDeviceEngine.cpp b/src/add-ons/media/media-add-ons/opensound/OpenSoundDeviceEngine.cpp index 4e26d27f8d..cf74f4629d 100644 --- a/src/add-ons/media/media-add-ons/opensound/OpenSoundDeviceEngine.cpp +++ b/src/add-ons/media/media-add-ons/opensound/OpenSoundDeviceEngine.cpp @@ -540,7 +540,8 @@ status_t OpenSoundDeviceEngine::AcceptFormatFor(int fmt, media_format &format, b return err; } - PRINT(("%s:step1 fmt=0x%08x, raw.format=0x%08lx\n", __FUNCTION__, fmt, raw.format)); + PRINT(("%s:step1 fmt=0x%08x, raw.format=0x%08" B_PRIx32 "\n", + __FUNCTION__, fmt, raw.format)); // if specified, try it if (raw.format) afmt = OpenSoundDevice::convert_media_format_to_oss_format(raw.format); @@ -556,7 +557,8 @@ status_t OpenSoundDeviceEngine::AcceptFormatFor(int fmt, media_format &format, b PRINT(("%s:step3 afmt=0x%08x\n", __FUNCTION__, afmt)); // convert back raw.format = OpenSoundDevice::convert_oss_format_to_media_format(afmt); - PRINT(("%s:step4 afmt=0x%08x, raw.format=0x%08lx\n", __FUNCTION__, afmt, raw.format)); + PRINT(("%s:step4 afmt=0x%08x, raw.format=0x%08" B_PRIx32 "\n", + __FUNCTION__, afmt, raw.format)); raw.valid_bits = OpenSoundDevice::convert_oss_format_to_valid_bits(afmt); err = SetFormat(afmt); @@ -634,7 +636,8 @@ status_t OpenSoundDeviceEngine::SpecializeFormatFor(int fmt, media_format &forma if (format.type == B_MEDIA_RAW_AUDIO) { media_multi_audio_format &raw = format.u.raw_audio; - PRINT(("%s:step1 fmt=0x%08x, raw.format=0x%08lx\n", __FUNCTION__, fmt, raw.format)); + PRINT(("%s:step1 fmt=0x%08x, raw.format=0x%08" B_PRIx32 "\n", + __FUNCTION__, fmt, raw.format)); // select the best as default if (!raw.format) { afmt = OpenSoundDevice::select_oss_format(fmt); @@ -651,7 +654,8 @@ status_t OpenSoundDeviceEngine::SpecializeFormatFor(int fmt, media_format &forma } // convert back raw.format = OpenSoundDevice::convert_oss_format_to_media_format(afmt); - PRINT(("%s:step4 afmt=0x%08x, raw.format=0x%08lx\n", __FUNCTION__, afmt, raw.format)); + PRINT(("%s:step4 afmt=0x%08x, raw.format=0x%08" B_PRIx32 "\n", + __FUNCTION__, afmt, raw.format)); if (!raw.valid_bits) raw.valid_bits = OpenSoundDevice::convert_oss_format_to_valid_bits(afmt); if (raw.valid_bits != OpenSoundDevice::convert_oss_format_to_valid_bits(afmt)) { diff --git a/src/add-ons/media/media-add-ons/opensound/OpenSoundNode.cpp b/src/add-ons/media/media-add-ons/opensound/OpenSoundNode.cpp index 39d747df76..8658b8b652 100644 --- a/src/add-ons/media/media-add-ons/opensound/OpenSoundNode.cpp +++ b/src/add-ons/media/media-add-ons/opensound/OpenSoundNode.cpp @@ -158,7 +158,7 @@ public: // make sure all buffers are recycled, or we might hang // when told to quit - while (BBuffer* buffer = (BBuffer*)fBuffers.RemoveItem(0L)) + while (BBuffer* buffer = (BBuffer*)fBuffers.RemoveItem((int32)0)) buffer->Recycle(); } @@ -325,7 +325,7 @@ OpenSoundNode::OpenSoundNode(BMediaAddOn* addon, const char* name, fTimeSourceStartTime(0), fWeb(NULL), - fConfig(0UL) + fConfig((uint32)0) { CALLED(); @@ -488,7 +488,7 @@ OpenSoundNode::NodeRegistered() const char *prefix = ""; if (strstr(engine->Info()->name, "SPDIF")) prefix = "S/PDIF "; - sprintf(mediaInput.name, "%sOutput %ld (%s)", prefix, + sprintf(mediaInput.name, "%sOutput %" B_PRId32 " (%s)", prefix, mediaInput.destination.id, gSupportedFormatsNames[f]); NodeInput* input = new (nothrow) NodeInput(mediaInput, i, fmt, @@ -536,7 +536,7 @@ OpenSoundNode::NodeRegistered() const char *prefix = ""; if (strstr(engine->Info()->name, "SPDIF")) prefix = "S/PDIF "; - sprintf(mediaOutput.name, "%sInput %ld (%s)", prefix, + sprintf(mediaOutput.name, "%sInput %" B_PRId32 " (%s)", prefix, mediaOutput.source.id, gSupportedFormatsNames[f]); NodeOutput* output = new (nothrow) NodeOutput(mediaOutput, @@ -1282,8 +1282,9 @@ OpenSoundNode::Disconnect(const media_source& what, channel->FreeBuffers(); } else { fprintf(stderr, "\tDisconnect() called with wrong source/destination " - "(%ld/%ld), ours is (%ld/%ld)\n", what.id, where.id, - channel->fOutput.source.id, channel->fOutput.destination.id); + "(%" B_PRId32 "/%" B_PRId32 "), ours is (%" B_PRId32 "/%" B_PRId32 + ")\n", what.id, where.id, channel->fOutput.source.id, + channel->fOutput.destination.id); } } @@ -1315,7 +1316,7 @@ OpenSoundNode::LateNoticeReceived(const media_source& what, bigtime_t how_much, fInternalLatency += how_much; SetEventLatency(fLatency + fInternalLatency); - fprintf(stderr, "\tincreasing latency to %Ld\n", + fprintf(stderr, "\tincreasing latency to %" B_PRIdBIGTIME "\n", fLatency + fInternalLatency); } else { // The other run modes dictate various strategies for sacrificing data @@ -1396,7 +1397,8 @@ OpenSoundNode::HandleEvent(const media_timed_event* event, bigtime_t lateness, HandleParameter(event,lateness,realTimeEvent); break; default: - fprintf(stderr," unknown event type: %li\n",event->type); + fprintf(stderr," unknown event type: %" B_PRId32 "\n", + event->type); break; } } @@ -1448,7 +1450,7 @@ OpenSoundNode::HandleBuffer(const media_timed_event* event, // TODO: Debug //mLateBuffers++; NotifyLateProducer(channel->fInput.source, -how_early, perf_time); - fprintf(stderr," <- LATE BUFFER : %lli\n", how_early); + fprintf(stderr," <- LATE BUFFER : %" B_PRIdBIGTIME "\n", how_early); buffer->Recycle(); } else { fDevice->Locker()->Lock(); @@ -1610,8 +1612,8 @@ OpenSoundNode::TimeSourceOp(const time_source_op_info& op, void* _reserved) break; case B_TIMESOURCE_SEEK: // TRACE("TimeSourceOp op B_TIMESOURCE_SEEK\n"); -printf("TimeSourceOp op B_TIMESOURCE_SEEK, real %lld, " - "perf %lld\n", op.real_time, op.performance_time); +printf("TimeSourceOp op B_TIMESOURCE_SEEK, real %" B_PRIdBIGTIME ", " + "perf %" B_PRIdBIGTIME "\n", op.real_time, op.performance_time); BroadcastTimeWarp(op.real_time, op.performance_time); break; default: @@ -2257,7 +2259,7 @@ OpenSoundNode::_PlayThread(NodeInput* input) TRACE("OpenSoundNode::_PlayThread: buffers: %ld\n", input->fBuffers.CountItems()); - BBuffer* buffer = (BBuffer*)input->fBuffers.RemoveItem(0L); + BBuffer* buffer = (BBuffer*)input->fBuffers.RemoveItem((int32)0); fDevice->Locker()->Unlock(); diff --git a/src/add-ons/media/media-add-ons/tone_producer_demo/ToneProducer.cpp b/src/add-ons/media/media-add-ons/tone_producer_demo/ToneProducer.cpp index 7967feced9..e10172ee35 100644 --- a/src/add-ons/media/media-add-ons/tone_producer_demo/ToneProducer.cpp +++ b/src/add-ons/media/media-add-ons/tone_producer_demo/ToneProducer.cpp @@ -662,7 +662,8 @@ ToneProducer::Stop(bigtime_t performance_time, bool immediate) { // send 'data not available' message if(mOutput.destination != media_destination::null) { - printf("ToneProducer: B_PRODUCER_STOPPED at %Ld\n", performance_time); + printf("ToneProducer: B_PRODUCER_STOPPED at %" B_PRIdBIGTIME "\n", + performance_time); SendDataStatus(B_PRODUCER_STOPPED, mOutput.destination, performance_time); } diff --git a/src/add-ons/print/drivers/preview/JobSetupWindow.cpp b/src/add-ons/print/drivers/preview/JobSetupWindow.cpp index 9ba38eb419..5d142469cf 100644 --- a/src/add-ons/print/drivers/preview/JobSetupWindow.cpp +++ b/src/add-ons/print/drivers/preview/JobSetupWindow.cpp @@ -121,7 +121,7 @@ void JobSetupWindow::UpdateJobMessage() { int32 from = 1; - int32 to = LONG_MAX; + int32 to = INT32_MAX; if (fAll->Value() == B_CONTROL_OFF) { from = atoi(fFrom->Text()); to = atoi(fTo->Text()); diff --git a/src/add-ons/print/drivers/preview/PrinterDriver.cpp b/src/add-ons/print/drivers/preview/PrinterDriver.cpp index 117e3ecdbc..ef2048f477 100644 --- a/src/add-ons/print/drivers/preview/PrinterDriver.cpp +++ b/src/add-ons/print/drivers/preview/PrinterDriver.cpp @@ -78,8 +78,8 @@ PrinterDriver::PrintJob(BFile *spoolFile, BMessage *jobMsg) printf("\n"); for (int32 page = 1; page <= pfh.page_count; ++page) { - printf("PrinterDriver::PrintPage(): Faking print of page %ld/ %ld\n", - page, pfh.page_count); + printf("PrinterDriver::PrintPage(): Faking print of page %" B_PRId32 + "/ %" B_PRId32 "\n", page, pfh.page_count); } fJobFile->Seek(0, SEEK_SET); @@ -87,9 +87,10 @@ PrinterDriver::PrintJob(BFile *spoolFile, BMessage *jobMsg) status_t status = reader.InitCheck(); printf("\nPrintJobReader::InitCheck(): %s\n", status == B_OK ? "B_OK" : "B_ERROR"); - printf("PrintJobReader::NumberOfPages(): %ld\n", reader.NumberOfPages()); - printf("PrintJobReader::FirstPage(): %ld\n", reader.FirstPage()); - printf("PrintJobReader::LastPage(): %ld\n", reader.LastPage()); + printf("PrintJobReader::NumberOfPages(): %" B_PRId32 "\n", + reader.NumberOfPages()); + printf("PrintJobReader::FirstPage(): %" B_PRId32 "\n", reader.FirstPage()); + printf("PrintJobReader::LastPage(): %" B_PRId32 "\n", reader.LastPage()); BRect rect = reader.PaperRect(); printf("PrintJobReader::PaperRect(): BRect(l:%.1f, t:%.1f, r:%.1f, b:%.1f)\n", @@ -101,7 +102,8 @@ PrinterDriver::PrintJob(BFile *spoolFile, BMessage *jobMsg) int32 xdpi, ydpi; reader.GetResolution(&xdpi, &ydpi); - printf("PrintJobReader::GetResolution(): xdpi:%ld, ydpi:%ld\n", xdpi, ydpi); + printf("PrintJobReader::GetResolution(): xdpi:%" B_PRId32 ", ydpi:%" + B_PRId32 "\n", xdpi, ydpi); printf("PrintJobReader::GetScale(): %.1f\n", reader.GetScale()); fPrinting = false; @@ -172,7 +174,7 @@ PrinterDriver::JobSetup(BMessage *jobMsg, const char *printerName) jobMsg->AddInt32("first_page", 1); if (!jobMsg->HasInt32("last_page")) - jobMsg->AddInt32("last_page", LONG_MAX); + jobMsg->AddInt32("last_page", INT32_MAX); BlockingWindow* w = NewJobSetupWindow(jobMsg, printerName); return w->Go(); diff --git a/src/add-ons/print/transports/ipp/Ipp.cpp b/src/add-ons/print/transports/ipp/Ipp.cpp index b4a69983a3..2906be87de 100644 --- a/src/add-ons/print/transports/ipp/Ipp.cpp +++ b/src/add-ons/print/transports/ipp/Ipp.cpp @@ -93,7 +93,8 @@ IPPPrinterRoster::Listen() packet[len] = '\0'; // Verify packet format - if (sscanf(packet, "%lx%lx%1023s", &type, &state, uri) == 3) { + if (sscanf(packet, "%" B_SCNx32 "%" B_SCNx32 "%1023s", &type, &state, + uri) == 3) { IPPPrinter *printer = fPrinters.Get(uri); if (!printer) { printer = new IPPPrinter(uri, type); diff --git a/src/add-ons/print/transports/ipp/IppTransport.cpp b/src/add-ons/print/transports/ipp/IppTransport.cpp index 64814f1502..65b7c767bf 100644 --- a/src/add-ons/print/transports/ipp/IppTransport.cpp +++ b/src/add-ons/print/transports/ipp/IppTransport.cpp @@ -64,7 +64,7 @@ IppTransport::IppTransport(BMessage *msg) else strcpy(__user, "baron"); - sprintf(__file, "%s/%s@ipp.%ld", spool_path, __user, __jobid); + sprintf(__file, "%s/%s@ipp.%" B_PRId32, spool_path, __user, __jobid); __fs.open(__file, ios::in | ios::out | ios::binary | ios::trunc); if (__fs.good()) { diff --git a/src/add-ons/print/transports/lpr/LprTransport.cpp b/src/add-ons/print/transports/lpr/LprTransport.cpp index 8ac8daf536..6de02a45c5 100644 --- a/src/add-ons/print/transports/lpr/LprTransport.cpp +++ b/src/add-ons/print/transports/lpr/LprTransport.cpp @@ -66,7 +66,7 @@ LprTransport::LprTransport(BMessage *msg) } dir.WriteAttr(LPR_JOB_ID, B_INT32_TYPE, 0, &fJobId, sizeof(fJobId)); - sprintf(fFile, "%s/%s@ipp.%ld", spool_path, fUser, fJobId); + sprintf(fFile, "%s/%s@ipp.%" B_PRId32, spool_path, fUser, fJobId); fStream.open(fFile, ios::in | ios::out | ios::binary | ios::trunc); if (fStream.good()) { diff --git a/src/add-ons/screen_savers/spider/Polygon.cpp b/src/add-ons/screen_savers/spider/Polygon.cpp index 71c401e12a..cec30cb3ee 100644 --- a/src/add-ons/screen_savers/spider/Polygon.cpp +++ b/src/add-ons/screen_savers/spider/Polygon.cpp @@ -39,7 +39,7 @@ Polygon::Polygon(BRect bounds, BList points) // destructor Polygon::~Polygon() { - while (point_vector* pv = (point_vector*)fPoints.RemoveItem(0L)) + while (point_vector* pv = (point_vector*)fPoints.RemoveItem((int32)0)) delete pv; } diff --git a/src/apps/clock/cl_view.cpp b/src/apps/clock/cl_view.cpp index d0605d95e4..d6cfb8e6a8 100644 --- a/src/apps/clock/cl_view.cpp +++ b/src/apps/clock/cl_view.cpp @@ -333,7 +333,7 @@ void TOnscreenView::MouseDown( BPoint point ) { BPoint cursor; - ulong buttons; + uint32 buttons; BRect bounds = Bounds(); GetMouse(&cursor,&buttons); diff --git a/src/apps/codycam/CodyCam.cpp b/src/apps/codycam/CodyCam.cpp index 36f17d4bac..f68df37330 100644 --- a/src/apps/codycam/CodyCam.cpp +++ b/src/apps/codycam/CodyCam.cpp @@ -65,7 +65,7 @@ ErrorAlert(const char* message, status_t err, BWindow *window = NULL) alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(); - printf("%s\n%s [%lx]", message, strerror(err), err); + printf("%s\n%s [%" B_PRIx32 "]", message, strerror(err), err); } @@ -541,7 +541,7 @@ VideoWindow::MessageReceived(BMessage* message) case msg_upl_client: message->FindInt32("client", &(fFtpInfo.uploadClient)); - FTPINFO("upl client = %ld\n", fFtpInfo.uploadClient); + FTPINFO("upl client = %" B_PRId32 "\n", fFtpInfo.uploadClient); _UploadClientChanged(); break; diff --git a/src/apps/codycam/Settings.cpp b/src/apps/codycam/Settings.cpp index af06871438..537d0bf1f9 100644 --- a/src/apps/codycam/Settings.cpp +++ b/src/apps/codycam/Settings.cpp @@ -177,7 +177,7 @@ ScalarValueSetting::Value() const void ScalarValueSetting::GetValueAsString(char* buffer) const { - sprintf(buffer, "%ld", fValue); + sprintf(buffer, "%" B_PRId32, fValue); } diff --git a/src/apps/codycam/Settings.h b/src/apps/codycam/Settings.h index 7bce95515a..cde0f821ba 100644 --- a/src/apps/codycam/Settings.h +++ b/src/apps/codycam/Settings.h @@ -61,7 +61,7 @@ public: int32 defaultValue, const char* valueExpectedErrorString, const char* wrongValueErrorString, - int32 min = LONG_MIN, int32 max = LONG_MAX); + int32 min = INT32_MIN, int32 max = INT32_MAX); virtual ~ScalarValueSetting(); void ValueChanged(int32 newValue); diff --git a/src/apps/codycam/VideoConsumer.cpp b/src/apps/codycam/VideoConsumer.cpp index c764d19c7c..55618e0972 100644 --- a/src/apps/codycam/VideoConsumer.cpp +++ b/src/apps/codycam/VideoConsumer.cpp @@ -124,7 +124,7 @@ VideoConsumer::~VideoConsumer() BMediaAddOn* -VideoConsumer::AddOn(long* cookie) const +VideoConsumer::AddOn(int32* cookie) const { FUNCTION("VideoConsumer::AddOn\n"); // do the right thing if we're ever used with an add-on @@ -243,7 +243,8 @@ VideoConsumer::HandleMessage(int32 message, const void* data, size_t size) void VideoConsumer::BufferReceived(BBuffer* buffer) { - LOOP("VideoConsumer::Buffer #%ld received, start_time %Ld\n", buffer->ID(), buffer->Header()->start_time); + LOOP("VideoConsumer::Buffer #%" B_PRId32 " received, start_time %" B_PRIdBIGTIME + "\n", buffer->ID(), buffer->Header()->start_time); if (RunState() == B_STOPPED) { buffer->Recycle(); @@ -309,8 +310,8 @@ VideoConsumer::CreateBuffers(const media_format& withFormat) else PROGRESS("VideoConsumer::CreateBuffers - SUCCESSFUL ADD BUFFER TO GROUP\n"); } else { - ERROR("VideoConsumer::CreateBuffers - ERROR CREATING VIDEO RING BUFFER: %08lx\n", - status); + ERROR("VideoConsumer::CreateBuffers - ERROR CREATING VIDEO RING " + "BUFFER: %08" B_PRIx32 "\n", status); return B_ERROR; } } @@ -322,8 +323,8 @@ VideoConsumer::CreateBuffers(const media_format& withFormat) if ((status = fBuffers->GetBufferList(3, buffList)) == B_OK) for (int j = 0; j < 3; j++) if (buffList[j] != NULL) { - fBufferMap[j] = (uint32)buffList[j]; - PROGRESS(" j = %d buffer = %08lx\n", j, fBufferMap[j]); + fBufferMap[j] = buffList[j]; + PROGRESS(" j = %d buffer = %p\n", j, fBufferMap[j]); } else { ERROR("VideoConsumer::CreateBuffers ERROR MAPPING RING BUFFER\n"); return B_ERROR; @@ -542,7 +543,7 @@ VideoConsumer::HandleEvent(const media_timed_event* event, bigtime_t lateness, uint32 index = 0; fOurBuffers = true; while (index < 3) - if ((uint32)buffer == fBufferMap[index]) + if (buffer == fBufferMap[index]) break; else index++; @@ -735,7 +736,7 @@ VideoConsumer::FtpSave(char* filename) uint32 time = real_time_clock(); char s[80]; strcpy(s, B_TRANSLATE("Last Capture: ")); - strcat(s, ctime((const long*)&time)); + strcat(s, ctime((const time_t*)&time)); s[strlen(s) - 1] = 0; UpdateFtpStatus(s); delete ftp; diff --git a/src/apps/codycam/VideoConsumer.h b/src/apps/codycam/VideoConsumer.h index 473bd4f069..af3e640a47 100644 --- a/src/apps/codycam/VideoConsumer.h +++ b/src/apps/codycam/VideoConsumer.h @@ -43,7 +43,7 @@ class VideoConsumer : public BMediaEventLooper, public BBufferConsumer { /* BMediaNode */ public: - virtual BMediaAddOn* AddOn(long* cookie) const; + virtual BMediaAddOn* AddOn(int32* cookie) const; protected: virtual void Start(bigtime_t performanceTime); @@ -114,7 +114,7 @@ class VideoConsumer : public BMediaEventLooper, public BBufferConsumer { private: BStringView* fStatusLine; - uint32 fInternalID; + int32 fInternalID; BMediaAddOn* fAddOn; thread_id fFtpThread; @@ -129,7 +129,7 @@ class VideoConsumer : public BMediaEventLooper, public BBufferConsumer { BBitmap* fBitmap[3]; bool fOurBuffers; BBufferGroup* fBuffers; - uint32 fBufferMap[3]; + BBuffer* fBufferMap[3]; BBitmap* fFtpBitmap; volatile bool fTimeToFtp; diff --git a/src/apps/cortex/addons/common/AudioBuffer.cpp b/src/apps/cortex/addons/common/AudioBuffer.cpp index f09212714b..92ceffb4f9 100644 --- a/src/apps/cortex/addons/common/AudioBuffer.cpp +++ b/src/apps/cortex/addons/common/AudioBuffer.cpp @@ -295,7 +295,7 @@ uint32 AudioBuffer::findMin(uint32 fromFrame, uint32 frameCount, if(pAt) { // reset pAt for(n = 0; n < channels; n++) - pAt[n] = ULONG_MAX; + pAt[n] = UINT32_MAX; } // find minimum for each channel @@ -348,7 +348,7 @@ uint32 AudioBuffer::findMax(uint32 fromFrame, uint32 frameCount, if(pAt) { // reset pAt for(n = 0; n < channels; n++) - pAt[n] = ULONG_MAX; + pAt[n] = UINT32_MAX; } // find minimum for each channel @@ -400,7 +400,7 @@ uint32 AudioBuffer::findPeaks(uint32 fromFrame, uint32 frameCount, if(pAt) { // reset pAt for(n = 0; n < channels; n++) - pAt[n] = ULONG_MAX; + pAt[n] = UINT32_MAX; } // find peaks in both directions diff --git a/src/apps/cortex/addons/common/MediaNodeControlApp.cpp b/src/apps/cortex/addons/common/MediaNodeControlApp.cpp index d0326ebbfb..4e6bd81323 100644 --- a/src/apps/cortex/addons/common/MediaNodeControlApp.cpp +++ b/src/apps/cortex/addons/common/MediaNodeControlApp.cpp @@ -82,7 +82,7 @@ MediaNodeControlApp::MediaNodeControlApp( if(err < B_OK) { char buffer[512]; sprintf(buffer, - "MediaNodeControlApp: couldn't find node (%ld):\n%s\n", + "MediaNodeControlApp: couldn't find node (%" B_PRId32 "):\n%s\n", nodeID, strerror(err)); BAlert* alert = new BAlert("error", buffer, "OK"); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); @@ -96,8 +96,8 @@ MediaNodeControlApp::MediaNodeControlApp( if(err < B_OK) { char buffer[512]; sprintf(buffer, - "MediaNodeControlApp: couldn't get node info (%ld):\n%s\n", - nodeID, strerror(err)); + "MediaNodeControlApp: couldn't get node info (%" B_PRId32 + "):\n%s\n", nodeID, strerror(err)); BAlert* alert = new BAlert("error", buffer, "OK"); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(); @@ -113,8 +113,8 @@ MediaNodeControlApp::MediaNodeControlApp( if(err < B_OK) { char buffer[512]; sprintf(buffer, - "MediaNodeControlApp: no parameters for node (%ld):\n%s\n", - nodeID, strerror(err)); + "MediaNodeControlApp: no parameters for node (%" B_PRId32 + "):\n%s\n", nodeID, strerror(err)); BAlert* alert = new BAlert("error", buffer, "OK"); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(); diff --git a/src/apps/debugger/user_interface/gui/inspector_window/InspectorWindow.cpp b/src/apps/debugger/user_interface/gui/inspector_window/InspectorWindow.cpp index 5dbb1083aa..1293e2f6ad 100644 --- a/src/apps/debugger/user_interface/gui/inspector_window/InspectorWindow.cpp +++ b/src/apps/debugger/user_interface/gui/inspector_window/InspectorWindow.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2011, Rene Gollent, rene@gollent.com. All rights reserved. + * Copyright 2011-2013, Rene Gollent, rene@gollent.com. All rights reserved. * Distributed under the terms of the MIT License. */ @@ -125,8 +125,8 @@ InspectorWindow::_Init() textMenu->AddItem(item); BLayoutBuilder::Group<>(this, B_VERTICAL) - .SetInsets(4.0f, 4.0f, 4.0f, 4.0f) - .AddGroup(B_HORIZONTAL, 4.0f) + .SetInsets(B_USE_DEFAULT_SPACING) + .AddGroup(B_HORIZONTAL) .Add(fAddressInput = new BTextControl("addrInput", "Target Address:", "", new BMessage(MSG_INSPECT_ADDRESS))) @@ -135,7 +135,7 @@ InspectorWindow::_Init() .Add(fNextBlockButton = new BButton("navNext", ">", new BMessage(MSG_NAVIGATE_NEXT_BLOCK))) .End() - .AddGroup(B_HORIZONTAL, 4.0f) + .AddGroup(B_HORIZONTAL) .Add(fHexMode = new BMenuField("hexMode", "Hex Mode:", hexMenu)) .AddGlue() @@ -156,7 +156,7 @@ InspectorWindow::_Init() int32 targetEndian = fTeam->GetArchitecture()->IsBigEndian() ? EndianModeBigEndian : EndianModeLittleEndian; - scrollView->SetTarget(fMemoryView = MemoryView::Create(fTeam)); + scrollView->SetTarget(fMemoryView = MemoryView::Create(fTeam, this)); fAddressInput->SetTarget(this); fPreviousBlockButton->SetTarget(this); @@ -221,6 +221,7 @@ InspectorWindow::MessageReceived(BMessage* msg) } if (addressValid) { + fCurrentAddress = address; if (fCurrentBlock != NULL && !fCurrentBlock->Contains(address)) { fCurrentBlock->ReleaseReference(); @@ -231,11 +232,6 @@ InspectorWindow::MessageReceived(BMessage* msg) fListener->InspectRequested(address, this); else fMemoryView->SetTargetAddress(fCurrentBlock, address); - - fCurrentAddress = address; - BString computedAddress; - computedAddress.SetToFormat("0x%" B_PRIx64, address); - fAddressInput->SetText(computedAddress.String()); } break; } @@ -289,6 +285,19 @@ InspectorWindow::MemoryBlockRetrieved(TeamMemoryBlock* block) } +void +InspectorWindow::TargetAddressChanged(target_addr_t address) +{ + AutoLocker lock(this); + if (lock.IsLocked()) { + fCurrentAddress = address; + BString computedAddress; + computedAddress.SetToFormat("0x%" B_PRIx64, address); + fAddressInput->SetText(computedAddress.String()); + } +} + + status_t InspectorWindow::LoadSettings(const GuiTeamUiSettings& settings) { diff --git a/src/apps/debugger/user_interface/gui/inspector_window/InspectorWindow.h b/src/apps/debugger/user_interface/gui/inspector_window/InspectorWindow.h index a145e1899c..320e344d9f 100644 --- a/src/apps/debugger/user_interface/gui/inspector_window/InspectorWindow.h +++ b/src/apps/debugger/user_interface/gui/inspector_window/InspectorWindow.h @@ -1,5 +1,5 @@ /* - * Copyright 2011, Rene Gollent, rene@gollent.com. All rights reserved. + * Copyright 2011-2013, Rene Gollent, rene@gollent.com. All rights reserved. * Distributed under the terms of the MIT License. */ #ifndef INSPECTOR_WINDOW_H @@ -8,6 +8,7 @@ #include +#include "MemoryView.h" #include "TeamMemoryBlock.h" #include "Types.h" @@ -17,13 +18,13 @@ class BMenuField; class BMessenger; class BTextControl; class GuiTeamUiSettings; -class MemoryView; class Team; class UserInterfaceListener; class InspectorWindow : public BWindow, - public TeamMemoryBlock::Listener { + public TeamMemoryBlock::Listener, + public MemoryView::Listener { public: InspectorWindow(::Team* team, UserInterfaceListener* listener, @@ -38,8 +39,12 @@ public: virtual void MessageReceived(BMessage* message); virtual bool QuitRequested(); + // TeamMemoryBlock::Listener virtual void MemoryBlockRetrieved(TeamMemoryBlock* block); + // MemoryView::Listener + virtual void TargetAddressChanged(target_addr_t address); + status_t LoadSettings( const GuiTeamUiSettings& settings); status_t SaveSettings( diff --git a/src/apps/debugger/user_interface/gui/inspector_window/MemoryView.cpp b/src/apps/debugger/user_interface/gui/inspector_window/MemoryView.cpp index fe30580295..a59e96760e 100644 --- a/src/apps/debugger/user_interface/gui/inspector_window/MemoryView.cpp +++ b/src/apps/debugger/user_interface/gui/inspector_window/MemoryView.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2011, Rene Gollent, rene@gollent.com. All rights reserved. + * Copyright 2011-2013, Rene Gollent, rene@gollent.com. All rights reserved. * Distributed under the terms of the MIT License. */ @@ -26,7 +26,7 @@ enum { }; -MemoryView::MemoryView(::Team* team) +MemoryView::MemoryView(::Team* team, Listener* listener) : BView("memoryView", B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE | B_SUBPIXEL_PRECISE), @@ -38,7 +38,8 @@ MemoryView::MemoryView(::Team* team) fTextCharsPerLine(0), fHexBlocksPerLine(0), fHexMode(HexMode8BitInt), - fTextMode(TextModeASCII) + fTextMode(TextModeASCII), + fListener(listener) { Architecture* architecture = team->GetArchitecture(); fTargetAddressSize = architecture->AddressSize() * 2; @@ -56,9 +57,9 @@ MemoryView::~MemoryView() /*static */ MemoryView* -MemoryView::Create(::Team* team) +MemoryView::Create(::Team* team, Listener* listener) { - MemoryView* self = new MemoryView(team); + MemoryView* self = new MemoryView(team, listener); try { self->_Init(); @@ -85,6 +86,13 @@ MemoryView::SetTargetAddress(TeamMemoryBlock* block, target_addr_t address) } +void +MemoryView::UnsetListener() +{ + fListener = NULL; +} + + void MemoryView::AttachedToWindow() { @@ -329,6 +337,8 @@ MemoryView::MessageReceived(BMessage* message) _RecalcScrollBars(); ScrollToSelection(); Invalidate(); + if (fListener != NULL) + fListener->TargetAddressChanged(fTargetAddress); break; } case MSG_SET_HEX_MODE: @@ -546,3 +556,11 @@ MemoryView::_GetNextHexBlock(char* buffer, int32 bufferSize, } } } + + +//#pragma mark - Listener + + +MemoryView::Listener::~Listener() +{ +} diff --git a/src/apps/debugger/user_interface/gui/inspector_window/MemoryView.h b/src/apps/debugger/user_interface/gui/inspector_window/MemoryView.h index 9f0dba6e4e..ca10a25c48 100644 --- a/src/apps/debugger/user_interface/gui/inspector_window/MemoryView.h +++ b/src/apps/debugger/user_interface/gui/inspector_window/MemoryView.h @@ -1,5 +1,5 @@ /* - * Copyright 2011, Rene Gollent, rene@gollent.com. All rights reserved. + * Copyright 2011-2013, Rene Gollent, rene@gollent.com. All rights reserved. * Distributed under the terms of the MIT License. */ @@ -46,15 +46,19 @@ class TeamMemoryBlock; class MemoryView : public BView { public: - MemoryView(::Team* team); + class Listener; + + MemoryView(::Team* team, Listener* listener); virtual ~MemoryView(); - static MemoryView* Create(::Team* team); + static MemoryView* Create(::Team* team, Listener* listener); // throws void SetTargetAddress(TeamMemoryBlock* block, target_addr_t address); + void UnsetListener(); + virtual void AttachedToWindow(); virtual void Draw(BRect rect); virtual void FrameResized(float width, float height); @@ -83,6 +87,17 @@ private: int32 fCurrentEndianMode; int32 fHexMode; int32 fTextMode; + Listener* fListener; }; + +class MemoryView::Listener { +public: + virtual ~Listener(); + + virtual void TargetAddressChanged(target_addr_t address) + = 0; +}; + + #endif // MEMORY_VIEW_H diff --git a/src/apps/debugger/user_interface/gui/team_window/BreakpointsView.cpp b/src/apps/debugger/user_interface/gui/team_window/BreakpointsView.cpp index 599113b99e..7095cdd183 100644 --- a/src/apps/debugger/user_interface/gui/team_window/BreakpointsView.cpp +++ b/src/apps/debugger/user_interface/gui/team_window/BreakpointsView.cpp @@ -205,9 +205,10 @@ BreakpointsView::WatchpointSelectionChanged(Watchpoint* watchpoint) void BreakpointsView::_Init() { - BLayoutBuilder::Group<>(this) + BLayoutBuilder::Group<>(this, B_HORIZONTAL, 0.0f) .Add(fListView = BreakpointListView::Create(fTeam, this)) - .AddGroup(B_VERTICAL, 4.0f) + .AddGroup(B_VERTICAL, B_USE_SMALL_SPACING) + .SetInsets(B_USE_SMALL_SPACING) .Add(fToggleBreakpointButton = new BButton("Toggle")) .Add(fRemoveBreakpointButton = new BButton("Remove")) .AddGlue() diff --git a/src/apps/debugger/user_interface/gui/team_window/ImageFunctionsView.cpp b/src/apps/debugger/user_interface/gui/team_window/ImageFunctionsView.cpp index 9d21acb028..017c9e436b 100644 --- a/src/apps/debugger/user_interface/gui/team_window/ImageFunctionsView.cpp +++ b/src/apps/debugger/user_interface/gui/team_window/ImageFunctionsView.cpp @@ -1,6 +1,6 @@ /* * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. - * Copyright 2011, Rene Gollent, rene@gollent.com. + * Copyright 2011-2013, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ @@ -23,6 +23,132 @@ #include "Tracing.h" +// #pragma mark - SourcePathComponentNode + + +class ImageFunctionsView::SourcePathComponentNode : public BReferenceable { +public: + SourcePathComponentNode(SourcePathComponentNode* parent, + const BString& componentName, LocatableFile* sourceFile, + FunctionInstance* function) + : + fParent(parent), + fComponentName(componentName), + fSourceFile(sourceFile), + fFunction(function) + { + if (fSourceFile != NULL) + fSourceFile->AcquireReference(); + if (fFunction != NULL) + fFunction->AcquireReference(); + } + + virtual ~SourcePathComponentNode() + { + for (int32 i = 0; i < fChildPathComponents.CountItems(); i++) + fChildPathComponents.ItemAt(i)->ReleaseReference(); + + if (fSourceFile != NULL) + fSourceFile->ReleaseReference(); + + if (fFunction != NULL) + fFunction->ReleaseReference(); + } + + const BString& ComponentName() const + { + return fComponentName; + } + + LocatableFile* SourceFile() const + { + return fSourceFile; + } + + FunctionInstance* Function() const + { + return fFunction; + } + + int32 CountChildren() const + { + return fChildPathComponents.CountItems(); + } + + SourcePathComponentNode* ChildAt(int32 index) + { + return fChildPathComponents.ItemAt(index); + } + + SourcePathComponentNode* FindChildByName(const BString& name) const + { + return fChildPathComponents.BinarySearchByKey(name, + &CompareByComponentName); + } + + int32 FindChildIndexByName(const BString& name) const + { + return fChildPathComponents.BinarySearchIndexByKey(name, + &CompareByComponentName); + } + + bool AddChild(SourcePathComponentNode* child) + { + if (!fChildPathComponents.BinaryInsert(child, + &CompareComponents)) { + return false; + } + + child->AcquireReference(); + + return true; + } + + bool RemoveChild(SourcePathComponentNode* child) + { + if (!fChildPathComponents.RemoveItem(child)) + return false; + + child->ReleaseReference(); + + return true; + } + + bool RemoveAllChildren() + { + for (int32 i = 0; i < fChildPathComponents.CountItems(); i++) + RemoveChild(fChildPathComponents.ItemAt(i)); + + return true; + } + +private: + friend class ImageFunctionsView::FunctionsTableModel; + + static int CompareByComponentName(const BString* name, const + SourcePathComponentNode* node) + { + return name->Compare(node->ComponentName()); + } + + static int CompareComponents(const SourcePathComponentNode* a, + const SourcePathComponentNode* b) + { + return a->ComponentName().Compare(b->ComponentName()); + } + +private: + typedef BObjectList ChildPathComponentList; + +private: + SourcePathComponentNode* fParent; + BString fComponentName; + LocatableFile* fSourceFile; + FunctionInstance* fFunction; + ChildPathComponentList fChildPathComponents; +}; + + // #pragma mark - FunctionsTableModel @@ -31,10 +157,7 @@ public: FunctionsTableModel() : fImageDebugInfo(NULL), - fFunctions(NULL), - fFunctionCount(0), - fSourceFileIndices(NULL), - fSourceFileCount(0) + fSourcelessNode(NULL) { } @@ -46,16 +169,14 @@ public: void SetImageDebugInfo(ImageDebugInfo* imageDebugInfo) { // unset old functions - if (fSourceFileIndices != NULL) { - NotifyNodesRemoved(TreeTablePath(), 0, fSourceFileCount); + if (fImageDebugInfo != NULL) { + NotifyNodesRemoved(TreeTablePath(), 0, + fChildPathComponents.CountItems()); + for (int32 i = 0; i < fChildPathComponents.CountItems(); i++) + fChildPathComponents.ItemAt(i)->ReleaseReference(); - delete[] fFunctions; - fFunctions = NULL; - fFunctionCount = 0; - - delete[] fSourceFileIndices; - fSourceFileIndices = NULL; - fSourceFileCount = 0; + fChildPathComponents.MakeEmpty(); + fSourcelessNode = NULL; } fImageDebugInfo = imageDebugInfo; @@ -95,35 +216,27 @@ public: // The array might now be too large, but we can live with that. } - // count the different source files - int32 sourceFileCount = 1; - for (int32 i = 1; i < functionCount; i++) { - if (_CompareSourceFileNames(functions[i - 1]->SourceFile(), - functions[i]->SourceFile()) != 0) { - sourceFileCount++; + SourcePathComponentNode* sourcelessNode = new(std::nothrow) + SourcePathComponentNode(NULL, "", NULL, NULL); + BReference sourceNodeRef( + sourcelessNode, true); + + + for (int32 i = 0; i < functionCount; i++) { + if (!_BuildFunctionSourcePath(functions[i], sourcelessNode)) + return; + } + + if (sourcelessNode->CountChildren() != 0) { + if (fChildPathComponents.BinaryInsert(sourcelessNode, + &SourcePathComponentNode::CompareComponents)) { + fSourcelessNode = sourcelessNode; + sourceNodeRef.Detach(); } } - // allocate and init the indices for the source files - fSourceFileIndices = new(std::nothrow) int32[sourceFileCount]; - if (fSourceFileIndices == NULL) - return; - fSourceFileCount = sourceFileCount; - - fSourceFileIndices[0] = 0; - - int32 sourceFileIndex = 1; - for (int32 i = 1; i < functionCount; i++) { - if (_CompareSourceFileNames(functions[i - 1]->SourceFile(), - functions[i]->SourceFile()) != 0) { - fSourceFileIndices[sourceFileIndex++] = i; - } - } - - fFunctions = functionsDeleter.Detach(); - fFunctionCount = functionCount; - - NotifyNodesAdded(TreeTablePath(), 0, fSourceFileCount); + NotifyNodesAdded(TreeTablePath(), 0, + fChildPathComponents.CountItems()); } virtual int32 CountColumns() const @@ -139,34 +252,17 @@ public: virtual int32 CountChildren(void* parent) const { if (parent == this) - return fSourceFileCount; + return fChildPathComponents.CountItems(); - if (parent >= fSourceFileIndices - && parent < fSourceFileIndices + fSourceFileCount) { - int32 sourceIndex = (int32*)parent - fSourceFileIndices; - return _CountSourceFileFunctions(sourceIndex); - } - - return 0; + return ((SourcePathComponentNode*)parent)->CountChildren(); } virtual void* ChildAt(void* parent, int32 index) const { - if (parent == this) { - return index >= 0 && index < fSourceFileCount - ? fSourceFileIndices + index : NULL; - } + if (parent == this) + return fChildPathComponents.ItemAt(index); - if (parent >= fSourceFileIndices - && parent < fSourceFileIndices + fSourceFileCount) { - int32 sourceIndex = (int32*)parent - fSourceFileIndices; - int32 count = _CountSourceFileFunctions(sourceIndex); - int32 firstFunctionIndex = fSourceFileIndices[sourceIndex]; - return index >= 0 && index < count - ? fFunctions[firstFunctionIndex + index] : NULL; - } - - return NULL; + return ((SourcePathComponentNode*)parent)->ChildAt(index); } virtual bool GetValueAt(void* object, int32 columnIndex, BVariant& value) @@ -177,84 +273,168 @@ public: if (object == this) return false; - if (object >= fSourceFileIndices - && object < fSourceFileIndices + fSourceFileCount) { - int32 index = *(int32*)object; - if (LocatableFile* file = fFunctions[index]->SourceFile()) { - BString path; - file->GetPath(path); - value.SetTo(path); - } else - value.SetTo("", B_VARIANT_DONT_COPY_DATA); + SourcePathComponentNode* node = (SourcePathComponentNode*)object; - return true; - } + value.SetTo(node->ComponentName(), B_VARIANT_DONT_COPY_DATA); - FunctionInstance* function = (FunctionInstance*)object; - value.SetTo(function->PrettyName(), B_VARIANT_DONT_COPY_DATA); return true; } bool GetFunctionPath(FunctionInstance* function, TreeTablePath& _path) { - int32 index = -1; - for (int32 i = 0; i < fFunctionCount; i++) { - if (fFunctions[i] == function) { - index = i; - break; + if (function == NULL) + return false; + + LocatableFile* sourceFile = function->SourceFile(); + SourcePathComponentNode* node = NULL; + int32 childIndex = -1; + if (sourceFile == NULL) { + node = fSourcelessNode; + _path.AddComponent(fChildPathComponents.IndexOf(node)); + } else { + BString sourcePath; + sourceFile->GetPath(sourcePath); + + if (sourcePath.IsEmpty()) + return false; + + BString searchPath; + while (!sourcePath.IsEmpty()) { + if (sourcePath[0] == '/') + sourcePath.Remove(0, 1); + int32 separatorIndex = sourcePath.FindFirst('/'); + if (separatorIndex == -1) { + searchPath = sourcePath; + sourcePath.Truncate(0); + } else + sourcePath.MoveInto(searchPath, 0, separatorIndex); + + if (node == NULL) { + childIndex = fChildPathComponents.BinarySearchIndexByKey( + searchPath, + &SourcePathComponentNode::CompareByComponentName); + node = fChildPathComponents.ItemAt(childIndex); + } else { + childIndex = node->FindChildIndexByName(searchPath); + node = node->ChildAt(childIndex); + } + + if (childIndex < 0) + return false; + + _path.AddComponent(childIndex); } } - if (index < 0) + if (node == NULL) return false; - int32 sourceIndex = fSourceFileCount - 1; - while (fSourceFileIndices[sourceIndex] > index) - sourceIndex--; + childIndex = node->FindChildIndexByName(function->PrettyName()); + if (childIndex < 0) + return false; - _path.Clear(); - return _path.AddComponent(sourceIndex) - && _path.AddComponent(index - fSourceFileIndices[sourceIndex]); + _path.AddComponent(childIndex); + return true; } bool GetObjectForPath(const TreeTablePath& path, LocatableFile*& _sourceFile, FunctionInstance*& _function) { - int32 componentCount = path.CountComponents(); - if (componentCount == 0 || componentCount > 2) + SourcePathComponentNode* node = fChildPathComponents.ItemAt( + path.ComponentAt(0)); + + if (node == NULL) return false; - int32 sourceIndex = path.ComponentAt(0); - if (sourceIndex < 0 || sourceIndex >= fSourceFileCount) - return false; + for (int32 i = 1; i < path.CountComponents(); i++) + node = node->ChildAt(path.ComponentAt(i)); - _sourceFile = fFunctions[fSourceFileIndices[sourceIndex]]->SourceFile(); - - _function = NULL; - - if (componentCount == 2) { - int32 index = path.ComponentAt(1); - if (index >= 0 && index < _CountSourceFileFunctions(sourceIndex)) - _function = fFunctions[fSourceFileIndices[sourceIndex] + index]; + if (node != NULL) { + _sourceFile = node->SourceFile(); + _function = node->Function(); + return true; } - return true; - } - - int32 CountSourceFiles() const - { - return fSourceFileCount; + return false; } private: - int32 _CountSourceFileFunctions(int32 sourceIndex) const + bool _BuildFunctionSourcePath(FunctionInstance* function, + SourcePathComponentNode* sourcelessNode) { - if (sourceIndex < 0 || sourceIndex >= fSourceFileCount) - return 0; + LocatableFile* sourceFile = function->SourceFile(); + if (sourceFile == NULL) + return _AddFunctionNode(sourcelessNode, function, NULL); - int32 nextFunctionIndex = sourceIndex + 1 < fSourceFileCount - ? fSourceFileIndices[sourceIndex + 1] : fFunctionCount; - return nextFunctionIndex - fSourceFileIndices[sourceIndex]; + BString sourcePath; + sourceFile->GetPath(sourcePath); + if (sourcePath.IsEmpty()) + return false; + + return _AddNextPathComponent(NULL, sourcePath, function, sourceFile); + } + + bool _AddNextPathComponent(SourcePathComponentNode* parent, + BString& childPath, FunctionInstance* function, LocatableFile* file) + { + if (childPath[0] == '/') + childPath.Remove(0, 1); + + BString pathComponent; + int32 pathSeparatorIndex = childPath.FindFirst('/'); + if (pathSeparatorIndex == -1) + pathComponent = childPath; + else + childPath.MoveInto(pathComponent, 0, pathSeparatorIndex); + + SourcePathComponentNode* currentNode = NULL; + if (parent == NULL) { + currentNode = fChildPathComponents.BinarySearchByKey(pathComponent, + SourcePathComponentNode::CompareByComponentName); + } else + currentNode = parent->FindChildByName(pathComponent); + + if (currentNode == NULL) { + currentNode = new(std::nothrow) SourcePathComponentNode(parent, + pathComponent, NULL, NULL); + if (currentNode == NULL) + return false; + BReference nodeReference(currentNode, + true); + if (parent != NULL) { + if (!parent->AddChild(currentNode)) + return false; + } else { + if (!fChildPathComponents.BinaryInsert(currentNode, + &SourcePathComponentNode::CompareComponents)) { + return false; + } + + nodeReference.Detach(); + } + } + + if (pathSeparatorIndex == -1) + return _AddFunctionNode(currentNode, function, file); + + return _AddNextPathComponent(currentNode, childPath, function, file); + } + + bool _AddFunctionNode(SourcePathComponentNode* parent, + FunctionInstance* function, LocatableFile* file) + { + SourcePathComponentNode* functionNode = new(std::nothrow) + SourcePathComponentNode(parent, function->PrettyName(), file, + function); + + if (functionNode == NULL) + return B_NO_MEMORY; + + BReference nodeReference(functionNode, true); + if (!parent->AddChild(functionNode)) + return false; + + return true; } static int _CompareSourceFileNames(LocatableFile* a, LocatableFile* b) @@ -290,11 +470,12 @@ private: } private: - ImageDebugInfo* fImageDebugInfo; - FunctionInstance** fFunctions; - int32 fFunctionCount; - int32* fSourceFileIndices; - int32 fSourceFileCount; + typedef BObjectList ChildPathComponentList; + +private: + ImageDebugInfo* fImageDebugInfo; + ChildPathComponentList fChildPathComponents; + SourcePathComponentNode* fSourcelessNode; }; @@ -364,7 +545,7 @@ ImageFunctionsView::SetImageDebugInfo(ImageDebugInfo* imageDebugInfo) // If there's only one source file (i.e. "no source file"), expand the item. if (fImageDebugInfo != NULL - && fFunctionsTableModel->CountSourceFiles() == 1) { + && fFunctionsTableModel->CountChildren(fFunctionsTableModel) == 1) { TreeTablePath path; path.AddComponent(0); fFunctionsTable->SetNodeExpanded(path, true, false); @@ -388,6 +569,7 @@ ImageFunctionsView::SetFunction(FunctionInstance* function) fFunctionsTable->SetNodeExpanded(path, true, true); fFunctionsTable->SelectNode(path, false); fFunctionsTable->ScrollToNode(path); + fFunctionsTable->ResizeAllColumnsToPreferred(); } else fFunctionsTable->DeselectAllNodes(); } @@ -444,7 +626,7 @@ ImageFunctionsView::_Init() // columns fFunctionsTable->AddColumn(new StringTableColumn(0, "File/Function", 300, - 100, 1000, B_TRUNCATE_END, B_ALIGN_LEFT)); + 100, 1000, B_TRUNCATE_BEGINNING, B_ALIGN_LEFT)); fFunctionsTableModel = new FunctionsTableModel(); fFunctionsTable->SetTreeTableModel(fFunctionsTableModel); diff --git a/src/apps/debugger/user_interface/gui/team_window/ImageFunctionsView.h b/src/apps/debugger/user_interface/gui/team_window/ImageFunctionsView.h index eb4ed2674e..55fb9594ac 100644 --- a/src/apps/debugger/user_interface/gui/team_window/ImageFunctionsView.h +++ b/src/apps/debugger/user_interface/gui/team_window/ImageFunctionsView.h @@ -1,5 +1,6 @@ /* * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2013, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ #ifndef IMAGE_FUNCTIONS_VIEW_H @@ -36,6 +37,7 @@ public: private: class FunctionsTableModel; + class SourcePathComponentNode; private: // TreeTableListener diff --git a/src/apps/debugger/user_interface/gui/team_window/ImageListView.cpp b/src/apps/debugger/user_interface/gui/team_window/ImageListView.cpp index 1588aefb04..4494fc06e6 100644 --- a/src/apps/debugger/user_interface/gui/team_window/ImageListView.cpp +++ b/src/apps/debugger/user_interface/gui/team_window/ImageListView.cpp @@ -292,7 +292,7 @@ ImageListView::_Init() fImagesTable->AddColumn(new Int32TableColumn(0, "ID", 40, 20, 1000, B_TRUNCATE_MIDDLE, B_ALIGN_RIGHT)); fImagesTable->AddColumn(new StringTableColumn(1, "Name", 80, 40, 1000, - B_TRUNCATE_END, B_ALIGN_LEFT)); + B_TRUNCATE_BEGINNING, B_ALIGN_LEFT)); fImagesTable->AddTableListener(this); diff --git a/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp b/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp index 2c8ddf6c25..0f2e594e12 100644 --- a/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp +++ b/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp @@ -760,29 +760,31 @@ TeamWindow::_Init() { BScrollView* sourceScrollView; - BLayoutBuilder::Group<>(this, B_VERTICAL) + const float splitSpacing = 3.0f; + + BLayoutBuilder::Group<>(this, B_VERTICAL, 0.0f) .Add(fMenuBar = new BMenuBar("Menu")) - .AddSplit(B_VERTICAL, 3.0f) + .AddSplit(B_VERTICAL, splitSpacing) .GetSplitView(&fFunctionSplitView) - .SetInsets(4.0f, 4.0f, 4.0f, 4.0f) + .SetInsets(B_USE_SMALL_INSETS) .Add(fTabView = new BTabView("tab view"), 0.4f) - .AddGroup(B_VERTICAL, 4.0f) - .AddGroup(B_HORIZONTAL, 4.0f) - .Add(fRunButton = new BButton("Run")) - .Add(fStepOverButton = new BButton("Step Over")) - .Add(fStepIntoButton = new BButton("Step Into")) - .Add(fStepOutButton = new BButton("Step Out")) - .AddGlue() - .End() - .Add(fSourcePathView = new BStringView( - "source path", - "Source path unavailable."), 4.0f) - .AddSplit(B_HORIZONTAL, 3.0f) - .GetSplitView(&fSourceSplitView) + .AddSplit(B_HORIZONTAL, splitSpacing) + .GetSplitView(&fSourceSplitView) + .AddGroup(B_VERTICAL, B_USE_SMALL_SPACING) + .AddGroup(B_HORIZONTAL, B_USE_SMALL_SPACING) + .Add(fRunButton = new BButton("Run")) + .Add(fStepOverButton = new BButton("Step Over")) + .Add(fStepIntoButton = new BButton("Step Into")) + .Add(fStepOutButton = new BButton("Step Out")) + .AddGlue() + .End() + .Add(fSourcePathView = new BStringView( + "source path", + "Source path unavailable."), 4.0f) .Add(sourceScrollView = new BScrollView("source scroll", - NULL, 0, true, true), 3.0f) - .Add(fLocalsTabView = new BTabView("locals view")) + NULL, 0, true, true), splitSpacing) .End() + .Add(fLocalsTabView = new BTabView("locals view")) .End() .End(); @@ -790,7 +792,7 @@ TeamWindow::_Init() sourceScrollView->SetTarget(fSourceView = SourceView::Create(fTeam, this)); // add threads tab - BSplitView* threadGroup = new BSplitView(B_HORIZONTAL); + BSplitView* threadGroup = new BSplitView(B_HORIZONTAL, splitSpacing); threadGroup->SetName("Threads"); fTabView->AddTab(threadGroup); BLayoutBuilder::Split<>(threadGroup) @@ -799,7 +801,7 @@ TeamWindow::_Init() .Add(fStackTraceView = StackTraceView::Create(this)); // add images tab - BSplitView* imagesGroup = new BSplitView(B_HORIZONTAL); + BSplitView* imagesGroup = new BSplitView(B_HORIZONTAL, splitSpacing); imagesGroup->SetName("Images"); fTabView->AddTab(imagesGroup); BLayoutBuilder::Split<>(imagesGroup) @@ -808,11 +810,12 @@ TeamWindow::_Init() .Add(fImageFunctionsView = ImageFunctionsView::Create(this)); // add breakpoints tab - BGroupView* breakpointsGroup = new BGroupView(B_HORIZONTAL, 4.0f); + BGroupView* breakpointsGroup = new BGroupView(B_HORIZONTAL, + B_USE_SMALL_SPACING); breakpointsGroup->SetName("Breakpoints"); fTabView->AddTab(breakpointsGroup); BLayoutBuilder::Group<>(breakpointsGroup) - .SetInsets(4.0f, 4.0f, 4.0f, 4.0f) +// .SetInsets(0.0f) .Add(fBreakpointsView = BreakpointsView::Create(fTeam, this)); // add local variables tab @@ -840,10 +843,10 @@ TeamWindow::_Init() fSourcePathView->AddFilter(filter); // add menus and menu items - BMenu* menu = new BMenu("File"); + BMenu* menu = new BMenu("Team"); fMenuBar->AddItem(menu); - BMenuItem* item = new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), - 'Q'); + BMenuItem* item = new BMenuItem("Close", new BMessage(B_QUIT_REQUESTED), + 'W'); menu->AddItem(item); item->SetTarget(this); menu = new BMenu("Edit"); diff --git a/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp b/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp index d86684706c..1e1483d08a 100644 --- a/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp +++ b/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp @@ -1953,19 +1953,19 @@ VariablesView::_GetContextActionsForNode(ModelNode* node, ContextActionList* actions) { ValueLocation* location = node->NodeChild()->Location(); - - // if the location's stored somewhere other than in memory, - // then we won't be able to inspect it this way. - if (location->PieceAt(0).type != VALUE_PIECE_LOCATION_MEMORY) - return B_OK; - + status_t result = B_OK; BMessage* message = NULL; - status_t result = _AddContextAction("Inspect", MSG_SHOW_INSPECTOR_WINDOW, - actions, message); - if (result != B_OK) - return result; - message->AddUInt64("address", location->PieceAt(0).address); + // only show the Inspect option if the value is in fact located + // in memory. + if (location->PieceAt(0).type == VALUE_PIECE_LOCATION_MEMORY) { + result = _AddContextAction("Inspect", MSG_SHOW_INSPECTOR_WINDOW, + actions, message); + if (result != B_OK) + return result; + message->AddUInt64("address", location->PieceAt(0).address); + } + result = _AddContextAction("Cast as" B_UTF8_ELLIPSIS, MSG_SHOW_TYPECAST_NODE_PROMPT, actions, message); diff --git a/src/apps/debugger/user_interface/gui/team_window/WatchPromptWindow.cpp b/src/apps/debugger/user_interface/gui/team_window/WatchPromptWindow.cpp index 8464582e1f..34ae3beb88 100644 --- a/src/apps/debugger/user_interface/gui/team_window/WatchPromptWindow.cpp +++ b/src/apps/debugger/user_interface/gui/team_window/WatchPromptWindow.cpp @@ -101,7 +101,7 @@ WatchPromptWindow::_Init() BLayoutItem* labelItem = fTypeField->CreateLabelLayoutItem(); labelItem->View()->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); BLayoutBuilder::Group<>(this, B_VERTICAL) - .SetInsets(4.0f, 4.0f, 4.0f, 4.0f) + .SetInsets(B_USE_DEFAULT_SPACING) .AddGroup(B_HORIZONTAL, 4.0f) .Add(fAddressInput) .End() diff --git a/src/apps/debugger/user_interface/gui/teams_window/StartTeamWindow.cpp b/src/apps/debugger/user_interface/gui/teams_window/StartTeamWindow.cpp index bc5216e630..149bacd028 100644 --- a/src/apps/debugger/user_interface/gui/teams_window/StartTeamWindow.cpp +++ b/src/apps/debugger/user_interface/gui/teams_window/StartTeamWindow.cpp @@ -73,7 +73,7 @@ StartTeamWindow::_Init() fCancelButton = new BButton("Cancel", new BMessage(B_QUIT_REQUESTED)); BLayoutBuilder::Group<>(this, B_VERTICAL) - .SetInsets(4.0f, 4.0f, 4.0f, 4.0f) + .SetInsets(B_USE_DEFAULT_SPACING) .Add(fGuideText) .AddGroup(B_HORIZONTAL, 4.0f) .Add(fTeamTextControl) diff --git a/src/apps/debugger/user_interface/gui/teams_window/TeamsWindow.cpp b/src/apps/debugger/user_interface/gui/teams_window/TeamsWindow.cpp index b26bcd3255..617a3ef3df 100644 --- a/src/apps/debugger/user_interface/gui/teams_window/TeamsWindow.cpp +++ b/src/apps/debugger/user_interface/gui/teams_window/TeamsWindow.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include "MessageCodes.h" @@ -70,6 +71,23 @@ TeamsWindow::Create(SettingsManager* settingsManager) } +void +TeamsWindow::Zoom(BPoint, float, float) +{ + BSize preferredSize = fTeamsListView->PreferredSize(); + ResizeBy(preferredSize.Width() - Bounds().Width(), + 0.0); + + // if the new size would extend us past the screen border, + // move sufficiently to the left to bring us back within the bounds + // + a bit of extra margin so we're not flush against the edge. + BScreen screen; + float offset = screen.Frame().right - Frame().right; + if (offset < 0) + MoveBy(offset - 5.0, 0.0); +} + + void TeamsWindow::MessageReceived(BMessage* message) { @@ -149,7 +167,8 @@ TeamsWindow::_Init() BLayoutBuilder::Group<>(this, B_VERTICAL) .Add(fTeamsListView = new TeamsListView("TeamsList", fCurrentTeam)) .SetInsets(1.0f, 1.0f, 1.0f, 1.0f) - .AddGroup(B_HORIZONTAL, 4.0f) + .AddGroup(B_HORIZONTAL) + .SetInsets(B_USE_DEFAULT_SPACING) .Add(fAttachTeamButton = new BButton("Attach", new BMessage( MSG_DEBUG_THIS_TEAM))) .Add(fCreateTeamButton = new BButton("Start new team" diff --git a/src/apps/debugger/user_interface/gui/teams_window/TeamsWindow.h b/src/apps/debugger/user_interface/gui/teams_window/TeamsWindow.h index d4f4ebbbcf..b83083e6bf 100644 --- a/src/apps/debugger/user_interface/gui/teams_window/TeamsWindow.h +++ b/src/apps/debugger/user_interface/gui/teams_window/TeamsWindow.h @@ -25,6 +25,7 @@ public: static TeamsWindow* Create(SettingsManager* settingsManager); // throws + virtual void Zoom(BPoint origin, float width, float height); virtual void MessageReceived(BMessage* message); virtual bool QuitRequested(); diff --git a/src/apps/diskprobe/DataEditor.cpp b/src/apps/diskprobe/DataEditor.cpp index 2fd85a28df..97539ad9a5 100644 --- a/src/apps/diskprobe/DataEditor.cpp +++ b/src/apps/diskprobe/DataEditor.cpp @@ -236,8 +236,10 @@ void ReplaceChange::Apply(off_t bufferOffset, uint8 *buffer, size_t bufferSize) { // is it in our range? - if (fOffset > bufferOffset + bufferSize || fOffset + fSize < bufferOffset) + if (fOffset > (bufferOffset + (off_t)bufferSize) + || (fOffset + (off_t)fSize) < bufferOffset) { return; + } // don't change anything outside the supplied buffer off_t offset = fOffset; @@ -263,8 +265,10 @@ void ReplaceChange::Revert(off_t bufferOffset, uint8 *buffer, size_t bufferSize) { // is it in our range? - if (fOffset - bufferOffset > bufferSize || fOffset + fSize < bufferOffset) + if (fOffset - bufferOffset > (off_t)bufferSize + || fOffset + (off_t)fSize < bufferOffset) { return; + } // don't change anything outside the supplied buffer off_t offset = fOffset; @@ -307,8 +311,8 @@ ReplaceChange::Merge(DataChange *_change) // are the changes adjacent? - if (change->fOffset + change->fSize != fOffset - && fOffset + fSize != change->fOffset) + if (change->fOffset + (off_t)change->fSize != fOffset + && fOffset + (off_t)fSize != change->fOffset) return false; // okay, we can try to merge the two changes @@ -560,7 +564,7 @@ DataEditor::Replace(off_t offset, const uint8 *data, size_t length) if (offset >= fSize) return B_BAD_VALUE; - if (offset + length > fSize) + if (offset + (off_t)length > fSize) length = fSize - offset; if (fNeedsUpdate) { @@ -705,7 +709,7 @@ DataEditor::Save() // don't try to change the file size size_t size = fRealViewSize; - if (fRealViewOffset + fRealViewSize > fSize) + if (fRealViewOffset + (off_t)fRealViewSize > (off_t)fSize) size = fSize - fRealViewOffset; ssize_t bytesWritten; @@ -1125,7 +1129,7 @@ DataEditor::Find(off_t startPosition, const uint8 *data, size_t dataSize, } for (size_t i = firstByte; i < fRealViewSize; i++) { - if (position + i + dataSize > fSize) + if (position + (off_t)(i + dataSize) > (off_t)fSize) break; if (!compareFunc(fView + i, data, 1)) { diff --git a/src/apps/diskprobe/DataView.cpp b/src/apps/diskprobe/DataView.cpp index bd01742cd8..59589437ad 100644 --- a/src/apps/diskprobe/DataView.cpp +++ b/src/apps/diskprobe/DataView.cpp @@ -163,19 +163,19 @@ DataView::UpdateFromEditor(BMessage *message) if (message != NULL && message->FindInt64("offset", &offset) == B_OK && message->FindInt64("size", &size) == B_OK) { - if (offset > fOffset + fDataSize - || offset + size < fOffset) { + if (offset > fOffset + (off_t)fDataSize + || offset + (off_t)size < fOffset) { // the changes are not within our scope, so we can ignore them return; } if (offset > fOffset) start = offset - fOffset; - if (offset + size < fOffset + fDataSize) + if (offset + (off_t)size < fOffset + (off_t)fDataSize) end = offset + size - fOffset; } - if (fOffset + fDataSize > fFileSize) + if (fOffset + (off_t)fDataSize > fFileSize) fSizeInView = fFileSize - fOffset; else fSizeInView = fDataSize; @@ -356,8 +356,8 @@ DataView::ConvertLine(char *line, off_t offset, const uint8 *buffer, size_t size return; } - line += sprintf(line, fBase == kHexBase ? "%0*Lx: " : "%0*Ld: ", - (int)fPositionLength, offset); + line += sprintf(line, fBase == kHexBase ? "%0*" B_PRIxOFF": " : "%0*" + B_PRIdOFF": ", (int)fPositionLength, offset); for (uint32 i = 0; i < kBlockSize; i++) { if (i >= size) { diff --git a/src/apps/diskprobe/ProbeView.cpp b/src/apps/diskprobe/ProbeView.cpp index 2aef09dcaa..943889fcd6 100644 --- a/src/apps/diskprobe/ProbeView.cpp +++ b/src/apps/diskprobe/ProbeView.cpp @@ -216,7 +216,7 @@ get_type_string(char *buffer, size_t bufferSize, type_code type) for (int32 i = 0; i < 4; i++) { buffer[i] = type >> (24 - 8 * i); if (buffer[i] < ' ' || buffer[i] == 0x7f) { - snprintf(buffer, bufferSize, "0x%04lx", type); + snprintf(buffer, bufferSize, "0x%04" B_PRIx32, type); break; } else if (i == 3) buffer[4] = '\0'; @@ -705,7 +705,8 @@ HeaderView::UpdateIcon() void HeaderView::FormatValue(char *buffer, size_t bufferSize, off_t value) { - snprintf(buffer, bufferSize, fBase == kHexBase ? "0x%Lx" : "%Ld", value); + snprintf(buffer, bufferSize, fBase == kHexBase ? "0x%" B_PRIxOFF : "%" + B_PRIdOFF, value); } @@ -1550,7 +1551,7 @@ ProbeView::AttachedToWindow() const uint32 blockSizes[] = {512, 1024, 2048}; for (uint32 i = 0; i < sizeof(blockSizes) / sizeof(blockSizes[0]); i++) { char buffer[32]; - snprintf(buffer, sizeof(buffer), "%ld%s", blockSizes[i], + snprintf(buffer, sizeof(buffer), "%" B_PRId32 "%s", blockSizes[i], fEditor.IsDevice() && fEditor.BlockSize() == blockSizes[i] ? B_TRANSLATE(" (native)") : ""); subMenu->AddItem(item = new BMenuItem(buffer, @@ -1582,7 +1583,7 @@ ProbeView::AttachedToWindow() fontSize = 0; for (uint32 i = 0; i < sizeof(fontSizes) / sizeof(fontSizes[0]); i++) { char buffer[16]; - snprintf(buffer, sizeof(buffer), "%ld", fontSizes[i]); + snprintf(buffer, sizeof(buffer), "%" B_PRId32, fontSizes[i]); subMenu->AddItem(item = new BMenuItem(buffer, message = new BMessage(kMsgFontSize))); message->AddFloat("font_size", fontSizes[i]); @@ -1653,23 +1654,30 @@ ProbeView::_UpdateSelectionMenuItems(int64 start, int64 end) // update menu items char buffer[128]; - if (fDataView->Base() == kHexBase) - snprintf(buffer, sizeof(buffer), B_TRANSLATE("Native: 0x%0*Lx"), size * 2, position); - else - snprintf(buffer, sizeof(buffer), B_TRANSLATE("Native: %Ld (0x%0*Lx)"), position, size * 2, position); + if (fDataView->Base() == kHexBase) { + snprintf(buffer, sizeof(buffer), B_TRANSLATE("Native: 0x%0*Lx"), + size * 2, position); + } else { + snprintf(buffer, sizeof(buffer), B_TRANSLATE("Native: %Ld (0x%0*Lx)"), + position, size * 2, position); + } fNativeMenuItem->SetLabel(buffer); - fNativeMenuItem->SetEnabled(position >= 0 && (position * fEditor.BlockSize()) < fEditor.FileSize()); + fNativeMenuItem->SetEnabled(position >= 0 + && (off_t)(position * fEditor.BlockSize()) < fEditor.FileSize()); fNativeMenuItem->Message()->ReplaceInt64("block", position); position = B_SWAP_INT64(position) >> (8 * (8 - size)); - if (fDataView->Base() == kHexBase) - snprintf(buffer, sizeof(buffer), B_TRANSLATE("Swapped: 0x%0*Lx"), size * 2, position); - else - snprintf(buffer, sizeof(buffer), B_TRANSLATE("Swapped: %Ld (0x%0*Lx)"), position, size * 2, position); + if (fDataView->Base() == kHexBase) { + snprintf(buffer, sizeof(buffer), B_TRANSLATE("Swapped: 0x%0*Lx"), + size * 2, position); + } else { + snprintf(buffer, sizeof(buffer), B_TRANSLATE("Swapped: %Ld (0x%0*Lx)"), + position, size * 2, position); + } fSwappedMenuItem->SetLabel(buffer); - fSwappedMenuItem->SetEnabled(position >= 0 && (position * fEditor.BlockSize()) < fEditor.FileSize()); + fSwappedMenuItem->SetEnabled(position >= 0 && (off_t)(position * fEditor.BlockSize()) < fEditor.FileSize()); fSwappedMenuItem->Message()->ReplaceInt64("block", position); } diff --git a/src/apps/diskprobe/TypeEditors.cpp b/src/apps/diskprobe/TypeEditors.cpp index 2183ff81c2..39bfbf8cb2 100644 --- a/src/apps/diskprobe/TypeEditors.cpp +++ b/src/apps/diskprobe/TypeEditors.cpp @@ -226,7 +226,7 @@ StringEditor::_UpdateText() size_t viewSize = fEditor.ViewSize(); // that may need some more memory... - if (viewSize < fEditor.FileSize()) + if ((off_t)viewSize < fEditor.FileSize()) fEditor.SetViewSize(fEditor.FileSize()); const char *buffer; @@ -486,7 +486,7 @@ NumberEditor::_UpdateText() bool NumberEditor::TypeMatches() { - return fEditor.FileSize() >= _Size(); + return fEditor.FileSize() >= (off_t)_Size(); // we only look at as many bytes we need to } @@ -949,7 +949,7 @@ ImageView::_UpdateImage() size_t viewSize = fEditor.ViewSize(); // that may need some more memory... - if (viewSize < fEditor.FileSize()) + if ((off_t)viewSize < fEditor.FileSize()) fEditor.SetViewSize(fEditor.FileSize()); const char *data; @@ -1169,7 +1169,7 @@ MessageView::_TypeToString(type_code type) for (int32 i = 0; i < 4; i++) { text[i] = type >> (24 - 8 * i); if (text[i] < ' ' || text[i] == 0x7f) { - snprintf(text, sizeof(text), "0x%04lx", type); + snprintf(text, sizeof(text), "0x%04" B_PRIx32, type); break; } else if (i == 3) text[4] = '\0'; @@ -1226,16 +1226,16 @@ MessageView::SetTo(BMessage& message) switch (type) { case B_INT64_TYPE: - snprintf(text, sizeof(text), "%Ld", *(int64*)data); + snprintf(text, sizeof(text), "%" B_PRId64, *(int64*)data); break; case B_UINT64_TYPE: - snprintf(text, sizeof(text), "%Lu", *(uint64*)data); + snprintf(text, sizeof(text), "%" B_PRIu64, *(uint64*)data); break; case B_INT32_TYPE: - snprintf(text, sizeof(text), "%ld", *(int32*)data); + snprintf(text, sizeof(text), "%" B_PRId32, *(int32*)data); break; case B_UINT32_TYPE: - snprintf(text, sizeof(text), "%lu", *(uint32*)data); + snprintf(text, sizeof(text), "%" B_PRIu32, *(uint32*)data); break; case B_BOOL_TYPE: if (*(uint8*)data) @@ -1255,7 +1255,7 @@ MessageView::SetTo(BMessage& message) fTextView->Insert("\t\t"); if (count > 1) { char index[16]; - snprintf(index, sizeof(index), "%ld.\t", j); + snprintf(index, sizeof(index), "%" B_PRId32 ".\t", j); fTextView->Insert(index); } fTextView->Insert(text); @@ -1273,7 +1273,7 @@ MessageView::_UpdateMessage() size_t viewSize = fEditor.ViewSize(); // that may need some more memory... - if (viewSize < fEditor.FileSize()) + if ((off_t)viewSize < fEditor.FileSize()) fEditor.SetViewSize(fEditor.FileSize()); const char *buffer; diff --git a/src/apps/icon-o-matic/MainWindow.cpp b/src/apps/icon-o-matic/MainWindow.cpp index d8ac569860..ee5a4ce07d 100644 --- a/src/apps/icon-o-matic/MainWindow.cpp +++ b/src/apps/icon-o-matic/MainWindow.cpp @@ -176,7 +176,7 @@ MainWindow::MessageReceived(BMessage* message) if (message->WasDropped()) { const rgb_color* color; - int32 length; + ssize_t length; // create styles from dropped colors for (int32 i = 0; message->FindData("RGBColor", B_RGB_COLOR_TYPE, i, (const void**)&color, &length) == B_OK; i++) { diff --git a/src/apps/icon-o-matic/generic/listener/Observable.cpp b/src/apps/icon-o-matic/generic/listener/Observable.cpp index 36d198c388..f1694685f3 100644 --- a/src/apps/icon-o-matic/generic/listener/Observable.cpp +++ b/src/apps/icon-o-matic/generic/listener/Observable.cpp @@ -29,8 +29,8 @@ Observable::~Observable() if (fObservers.CountItems() > 0) { char message[256]; Observer* o = (Observer*)fObservers.ItemAt(0); - sprintf(message, "Observable::~Observable() - %ld " - "observers still watching, first: %s\n", + sprintf(message, "Observable::~Observable() - %" B_PRId32 + " observers still watching, first: %s\n", fObservers.CountItems(), typeid(*o).name()); debugger(message); } diff --git a/src/apps/icon-o-matic/generic/property/view/PropertyListView.cpp b/src/apps/icon-o-matic/generic/property/view/PropertyListView.cpp index dfb220df21..8550dc9222 100644 --- a/src/apps/icon-o-matic/generic/property/view/PropertyListView.cpp +++ b/src/apps/icon-o-matic/generic/property/view/PropertyListView.cpp @@ -399,7 +399,7 @@ PropertyListView::SetTo(PropertyObject* object) // unkown to the PropertyEditorFactory and therefor // there is no editor view at this item fprintf(stderr, "PropertyListView::_SetTo() - " - "property mismatch at %ld\n", i); + "property mismatch at %" B_PRId32 "\n", i); error = true; break; } @@ -425,7 +425,7 @@ PropertyListView::SetTo(PropertyObject* object) int32 focused = -1; for (int32 i = 0; PropertyItemView* item = _ItemAt(i); i++) { if (item->IsSelected()) - selection.AddItem((void*)i); + selection.AddItem((void*)(long)i); if (item->IsFocused()) focused = i; } @@ -449,7 +449,7 @@ PropertyListView::SetTo(PropertyObject* object) // restore scroll pos, selection and focus SetScrollOffset(scrollOffset); for (int32 i = 0; PropertyItemView* item = _ItemAt(i); i++) { - if (selection.HasItem((void*)i)) + if (selection.HasItem((void*)(long)i)) item->SetSelected(true); if (i == focused) item->MakeFocus(true); diff --git a/src/apps/icon-o-matic/generic/support/support.cpp b/src/apps/icon-o-matic/generic/support/support.cpp index 77e1e3298e..f2f7fc9de8 100644 --- a/src/apps/icon-o-matic/generic/support/support.cpp +++ b/src/apps/icon-o-matic/generic/support/support.cpp @@ -111,7 +111,7 @@ append_float(BString& string, float n, int32 maxDigits) n = n - rounded; rounded = (int32)(n * pow(10, maxDigits)); char tmp[maxDigits + 1]; - sprintf(tmp, "%0*ld", (int)maxDigits, rounded); + sprintf(tmp, "%0*" B_PRId32, (int)maxDigits, rounded); tmp[maxDigits] = 0; int32 digits = strlen(tmp); for (int32 i = strlen(tmp) - 1; i >= 0; i--) { diff --git a/src/apps/icon-o-matic/import_export/flat_icon/FlatIconExporter.cpp b/src/apps/icon-o-matic/import_export/flat_icon/FlatIconExporter.cpp index 10ac43fbde..a0eb7b8c24 100644 --- a/src/apps/icon-o-matic/import_export/flat_icon/FlatIconExporter.cpp +++ b/src/apps/icon-o-matic/import_export/flat_icon/FlatIconExporter.cpp @@ -51,12 +51,12 @@ FlatIconExporter::~FlatIconExporter() { #if PRINT_STATISTICS printf("Statistics\n" - "--style section size: %ld\n" - " gradients: %ld\n" - " gradient transforms: %ld\n" - "---path section size: %ld\n" - "--shape section size: %ld\n" - "---total/different points: %ld/%lu\n", + "--style section size: %" B_PRId32 "\n" + " gradients: %" B_PRId32 "\n" + " gradient transforms: %" B_PRId32 "\n" + "---path section size: %" B_PRId32 "\n" + "--shape section size: %" B_PRId32 "\n" + "---total/different points: %" B_PRId32 "/%" B_PRIdSSIZE "\n", fStyleSectionSize, fGradientSize, fGradientTransformSize, diff --git a/src/apps/icon-o-matic/import_export/styled_text/StyledTextImporter.cpp b/src/apps/icon-o-matic/import_export/styled_text/StyledTextImporter.cpp index 0d6b10f5a1..eaa9902265 100644 --- a/src/apps/icon-o-matic/import_export/styled_text/StyledTextImporter.cpp +++ b/src/apps/icon-o-matic/import_export/styled_text/StyledTextImporter.cpp @@ -186,14 +186,14 @@ StyledTextImporter::Import(Icon* icon, BMessage* clipping) { CALLED(); const char *text; - int32 textLength; + ssize_t textLength; if (clipping == NULL) return ENOENT; if (clipping->FindData("text/plain", B_MIME_TYPE, (const void **)&text, &textLength) == B_OK) { text_run_array *runs = NULL; - int32 runsLength; + ssize_t runsLength; if (clipping->FindData("application/x-vnd.Be-text_run_array", B_MIME_TYPE, (const void **)&runs, &runsLength) < B_OK) runs = NULL; diff --git a/src/apps/icon-o-matic/import_export/svg/SVGExporter.cpp b/src/apps/icon-o-matic/import_export/svg/SVGExporter.cpp index 0b57dc7bc0..ee9fcec11c 100644 --- a/src/apps/icon-o-matic/import_export/svg/SVGExporter.cpp +++ b/src/apps/icon-o-matic/import_export/svg/SVGExporter.cpp @@ -490,7 +490,7 @@ SVGExporter::_GetFill(const Style* style, char* string, status_t ret = B_OK; if (Gradient* gradient = style->Gradient()) { ret = _ExportGradient(gradient, stream); - sprintf(string, "url(#gradient%ld)", fGradientCount++); + sprintf(string, "url(#gradient%" B_PRId32 ")", fGradientCount++); } else { sprintf(string, "#%.2x%.2x%.2x", style->Color().red, style->Color().green, diff --git a/src/apps/icon-o-matic/shape/PathManipulator.cpp b/src/apps/icon-o-matic/shape/PathManipulator.cpp index 4a06a510a5..fa30575a61 100644 --- a/src/apps/icon-o-matic/shape/PathManipulator.cpp +++ b/src/apps/icon-o-matic/shape/PathManipulator.cpp @@ -143,21 +143,21 @@ public: break; } } - BList::AddItem((void*)value, index); + BList::AddItem((void*)(long)value, index); } } inline bool Remove(int32 value) - { return BList::RemoveItem((void*)value); } + { return BList::RemoveItem((void*)(long)value); } inline bool Contains(int32 value) const - { return BList::HasItem((void*)value); } + { return BList::HasItem((void*)(long)value); } inline bool IsEmpty() const { return BList::IsEmpty(); } inline int32 IndexAt(int32 index) const - { return (int32)BList::ItemAt(index); } + { return (int32)(long)BList::ItemAt(index); } inline void MakeEmpty() { BList::MakeEmpty(); } diff --git a/src/apps/icon-o-matic/shape/commands/FreezeTransformationCommand.cpp b/src/apps/icon-o-matic/shape/commands/FreezeTransformationCommand.cpp index b7a43f4f3b..105479227a 100644 --- a/src/apps/icon-o-matic/shape/commands/FreezeTransformationCommand.cpp +++ b/src/apps/icon-o-matic/shape/commands/FreezeTransformationCommand.cpp @@ -147,7 +147,7 @@ FreezeTransformationCommand::_ApplyTransformation(Shape* shape, path->ApplyTransform(transform); } else { printf("Not transfering transformation of \"%s\" onto " - "path \"%s\", because %ld other shapes " + "path \"%s\", because %" B_PRId32 " other shapes " "have it assigned.\n", shape->Name(), path->Name(), shapes - 1); } diff --git a/src/apps/magnify/Magnify.cpp b/src/apps/magnify/Magnify.cpp index c757b637a9..85184c99bd 100644 --- a/src/apps/magnify/Magnify.cpp +++ b/src/apps/magnify/Magnify.cpp @@ -873,8 +873,8 @@ TInfoView::Draw(BRect updateRect) float h = Bounds().Height(); if (ch2Showing) { MovePenTo(10, h-12); - sprintf(str, "2) x: %li y: %li y: %i", (int32)pt2.x, (int32)pt2.y, - abs((int)(pt1.y - pt2.y))); + sprintf(str, "2) x: %" B_PRIi32 " y: %" B_PRIi32 " y: %d", + (int32)pt2.x, (int32)pt2.y, abs((int)(pt1.y - pt2.y))); invalRect.Set(10, h-12-fFontHeight, 10 + StringWidth(fCH2Str), h-10); SetHighColor(ViewColor()); FillRect(invalRect); @@ -886,8 +886,8 @@ TInfoView::Draw(BRect updateRect) if (ch1Showing && ch2Showing) { MovePenTo(10, h-10-fFontHeight-2); - sprintf(str, "1) x: %li y: %li x: %i", (int32)pt1.x, (int32)pt1.y, - abs((int)(pt1.x - pt2.x))); + sprintf(str, "1) x: %" B_PRIi32 " y: %" B_PRIi32 " x: %d", + (int32)pt1.x, (int32)pt1.y, abs((int)(pt1.x - pt2.x))); invalRect.Set(10, h-10-2*fFontHeight-2, 10 + StringWidth(fCH1Str), h-10-fFontHeight); SetHighColor(ViewColor()); FillRect(invalRect); @@ -897,7 +897,7 @@ TInfoView::Draw(BRect updateRect) DrawString(fCH1Str); } else if (ch1Showing) { MovePenTo(10, h-10); - sprintf(str, "x: %li y: %li", (int32)pt1.x, (int32)pt1.y); + sprintf(str, "x: %" B_PRIi32 " y: %" B_PRIi32, (int32)pt1.x, (int32)pt1.y); invalRect.Set(10, h-10-fFontHeight, 10 + StringWidth(fCH1Str), h-8); SetHighColor(ViewColor()); FillRect(invalRect); @@ -1410,7 +1410,7 @@ void TMagnify::NudgeMouse(float x, float y) { BPoint loc; - ulong button; + uint32 button; GetMouse(&loc, &button); ConvertToScreen(&loc); @@ -1429,7 +1429,7 @@ TMagnify::WindowActivated(bool active) } -long +status_t TMagnify::MagnifyTask(void *arg) { TMagnify* view = (TMagnify*)arg; @@ -1456,7 +1456,7 @@ void TMagnify::Update(bool force) { BPoint loc; - ulong button; + uint32 button; static long counter = 0; if (!fStickCoordinates) { @@ -1697,11 +1697,14 @@ TMagnify::SaveBits(BFile* file, const BBitmap *bitmap, const char* name) const char str[1024]; // stream out the width, height and ColorSpace - sprintf(str, "const int32 k%sWidth = %ld;\n", name, (int32)bitmap->Bounds().Width()+1); + sprintf(str, "const int32 k%sWidth = %" B_PRIi32 ";\n", name, + (int32)bitmap->Bounds().Width()+1); file->Write(str, strlen(str)); - sprintf(str, "const int32 k%sHeight = %ld;\n", name, (int32)bitmap->Bounds().Height()+1); + sprintf(str, "const int32 k%sHeight = %" B_PRIi32 ";\n", name, + (int32)bitmap->Bounds().Height()+1); file->Write(str, strlen(str)); - sprintf(str, "const color_space k%sColorSpace = %s;\n\n", name, kColorSpaceName); + sprintf(str, "const color_space k%sColorSpace = %s;\n\n", name, + kColorSpaceName); file->Write(str, strlen(str)); // stream out the constant name for this array diff --git a/src/apps/magnify/Magnify.h b/src/apps/magnify/Magnify.h index c4d468caee..ae19a719d9 100644 --- a/src/apps/magnify/Magnify.h +++ b/src/apps/magnify/Magnify.h @@ -119,7 +119,7 @@ class TMagnify : public BView { void EndSave(); private: - static long MagnifyTask(void *); + static status_t MagnifyTask(void *); bool fNeedToUpdate; long fThread; // magnify thread id diff --git a/src/apps/mail/Content.cpp b/src/apps/mail/Content.cpp index 54927c2441..21b5cd7570 100644 --- a/src/apps/mail/Content.cpp +++ b/src/apps/mail/Content.cpp @@ -148,7 +148,7 @@ FilterHTMLTag(int32 &first, char **t, char *end) // check for some common entities (in ISO-Latin-1) if (first == '&') { // filter out and convert decimal values - if (a[1] == '#' && sscanf(a + 2, "%ld;", &first) == 1) { + if (a[1] == '#' && sscanf(a + 2, "%" B_SCNd32 ";", &first) == 1) { t[0] += strchr(a, ';') - a; return false; } @@ -932,11 +932,11 @@ TTextView::UpdateFont(const BFont* newFont) fFont = *newFont; // update the text run array safely with new font - text_run_array *runArray = RunArray(0, LONG_MAX); + text_run_array *runArray = RunArray(0, INT32_MAX); for (int i = 0; i < runArray->count; i++) runArray->runs[i].font = *newFont; - SetRunArray(0, LONG_MAX, runArray); + SetRunArray(0, INT32_MAX, runArray); FreeRunArray(runArray); } @@ -1917,7 +1917,7 @@ TTextView::Open(hyper_text *enclosure) strcpy(baseName, enclosure->name ? enclosure->name : "enclosure"); strcpy(name, baseName); for (int32 index = 0; dir.Contains(name); index++) - sprintf(name, "%s_%ld", baseName, index); + sprintf(name, "%s_%" B_PRId32, baseName, index); BEntry entry(path.Path()); entry_ref ref; diff --git a/src/apps/mail/Header.cpp b/src/apps/mail/Header.cpp index 60530c83b7..2fc6165461 100644 --- a/src/apps/mail/Header.cpp +++ b/src/apps/mail/Header.cpp @@ -348,7 +348,7 @@ THeaderView::THeaderView(BRect rect, BRect windowRect, bool incoming, fAccountMenu->AddItem( item = new BMenuItem(B_TRANSLATE(""), NULL)); item->SetEnabled(false); - fAccountID = ~0UL; + fAccountID = ~(int32)0; } // default account is invalid, set to marked // TODO: do this differently, no casting and knowledge @@ -1093,7 +1093,7 @@ QPopupMenu::AddPersonItem(const entry_ref *ref, ino_t node, BString &name, if (!parentMenu->AddItem(newItem, index + 1)) { fprintf (stderr, "QPopupMenu::AddPersonItem: Unable to add menu " - "item \"%s\" at index %ld.\n", sortKey.String(), index + 1); + "item \"%s\" at index %" B_PRId32 ".\n", sortKey.String(), index + 1); delete newItem; } } diff --git a/src/apps/mail/MailWindow.cpp b/src/apps/mail/MailWindow.cpp index f9879d6825..28620739ac 100644 --- a/src/apps/mail/MailWindow.cpp +++ b/src/apps/mail/MailWindow.cpp @@ -2396,7 +2396,7 @@ TMailWindow::Send(bool now) char versionString[255]; sprintf(versionString, - "Mail/Haiku %ld.%ld.%ld", + "Mail/Haiku %" B_PRIu32 ".%" B_PRIu32 ".%" B_PRIu32, info.major, info.middle, info.minor); fMail->SetHeaderField("X-Mailer", versionString); } @@ -2578,7 +2578,7 @@ TMailWindow::SaveAsDraft() if (status == B_OK) break; char appendix[B_FILE_NAME_LENGTH]; - sprintf(appendix, " %ld", i++); + sprintf(appendix, " %" B_PRId32, i++); int32 pos = min_c(sizeof(fileName) - strlen(appendix), originalLength); sprintf(fileName + pos, "%s", appendix); @@ -2746,8 +2746,8 @@ TMailWindow::TrainMessageAs(const char *CommandWord) ErrorExit: beep(); sprintf(errorString, "Unable to train the message file \"%s\" as %s. " - "Possibly useful error code: %s (%ld).", - filePath.Path(), CommandWord, strerror (errorCode), errorCode); + "Possibly useful error code: %s (%" B_PRId32 ").", + filePath.Path(), CommandWord, strerror(errorCode), errorCode); BAlert* alert = new BAlert("", errorString, B_TRANSLATE("OK")); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(); @@ -2921,7 +2921,7 @@ TMailWindow::OpenMessage(const entry_ref *ref, uint32 characterSetForDecoding) // Put the addresses in the 'Save Address' Menu // BMenuItem *item; - while ((item = fSaveAddrMenu->RemoveItem(0L)) != NULL) + while ((item = fSaveAddrMenu->RemoveItem((int32)0)) != NULL) delete item; // create the list of addresses @@ -2935,7 +2935,7 @@ TMailWindow::OpenMessage(const entry_ref *ref, uint32 characterSetForDecoding) BMessage *msg; for (int32 i = addressList.CountItems(); i-- > 0;) { - char *address = (char *)addressList.RemoveItem(0L); + char *address = (char *)addressList.RemoveItem((int32)0); // insert the new address in alphabetical order int32 index = 0; diff --git a/src/apps/mail/Prefs.cpp b/src/apps/mail/Prefs.cpp index 8611f1f917..45b32cd151 100644 --- a/src/apps/mail/Prefs.cpp +++ b/src/apps/mail/Prefs.cpp @@ -338,7 +338,7 @@ TPrefsWindow::MessageReceived(BMessage* msg) fNewFont->SetSize(old_size); if (revert) { - sprintf(label, "%ld", old_size); + sprintf(label, "%" B_PRId32, old_size); item = fSizeMenu->FindItem(label); if (item != NULL) item->SetMarked(true); @@ -759,7 +759,7 @@ TPrefsWindow::_BuildSizeMenu(BFont* font) for (loop = 0; loop < sizeof(sizes) / sizeof(int32); loop++) { msg = new BMessage(P_SIZE); msg->AddInt32("size", sizes[loop]); - sprintf(label, "%ld", sizes[loop]); + sprintf(label, "%" B_PRId32, sizes[loop]); menu->AddItem(item = new BMenuItem(label, msg)); if (sizes[loop] == (int32)size) item->SetMarked(true); diff --git a/src/apps/mail/Signature.cpp b/src/apps/mail/Signature.cpp index 48a02034f1..dc8bcf949e 100644 --- a/src/apps/mail/Signature.cpp +++ b/src/apps/mail/Signature.cpp @@ -369,7 +369,7 @@ TSignatureWindow::Save() fFile = new BFile(); while(true) { - sprintf(name, "signature_%ld", index++); + sprintf(name, "signature_%" B_PRId32, index++); if ((result = dir.CreateFile(name, fFile, true)) == B_NO_ERROR) break; if (result != EEXIST) diff --git a/src/apps/mail/Status.cpp b/src/apps/mail/Status.cpp index 544646f9d1..7acee481a2 100644 --- a/src/apps/mail/Status.cpp +++ b/src/apps/mail/Status.cpp @@ -165,7 +165,7 @@ TStatusWindow::MessageReceived(BMessage* msg) break; if (result != EEXIST) goto err_exit; - sprintf(newName, "%s_%ld", name, index++); + sprintf(newName, "%s_%" B_PRId32, name, index++); } dir.FindEntry(newName, &entry); node = new BNodeInfo(&file); diff --git a/src/apps/mandelbrot/tsb.cpp b/src/apps/mandelbrot/tsb.cpp index c77b9a8f93..f62daf14e8 100644 --- a/src/apps/mandelbrot/tsb.cpp +++ b/src/apps/mandelbrot/tsb.cpp @@ -243,7 +243,7 @@ char t2_done; /*------------------------------------------------------------*/ -long __calc1(void *arg) +int32 __calc1(void *arg) { tsbb->manda(vvx, vvy, ssx, ssx); return B_NO_ERROR; @@ -251,7 +251,7 @@ long __calc1(void *arg) /*------------------------------------------------------------*/ -long __calc2(void *arg) +int32 __calc2(void *arg) { tsbb->mandb(vvx, vvy, ssx, ssx); return B_NO_ERROR; @@ -526,7 +526,7 @@ char TShowBit::has_selection() void TShowBit::change_selection(long h, long v) { - ulong buttons; + uint32 buttons; long h0; long v0; BRect new_select; diff --git a/src/apps/mediaplayer/playlist/ListViews.cpp b/src/apps/mediaplayer/playlist/ListViews.cpp index c5dbbb6e0f..032ffeaa07 100644 --- a/src/apps/mediaplayer/playlist/ListViews.cpp +++ b/src/apps/mediaplayer/playlist/ListViews.cpp @@ -328,7 +328,7 @@ DragSortableListView::MessageReceived(BMessage* message) BList indices; int32 index; for (int32 i = 0; message->FindInt32("index", i, &index) == B_OK; i++) - indices.AddItem((void*)index); + indices.AddItem((void*)(addr_t)index); if (indices.CountItems() > 0) { if (modifiers() & B_SHIFT_KEY) CopyItems(indices, fDropIndex); @@ -636,7 +636,7 @@ DragSortableListView::MoveItems(const BList& indices, int32 index) BList removedItems; int32 count = indices.CountItems(); for (int32 i = 0; i < count; i++) { - int32 removeIndex = (int32)indices.ItemAtFast(i) - i; + int32 removeIndex = (int32)(addr_t)indices.ItemAtFast(i) - i; BListItem* item = RemoveItem(removeIndex); if (item && removedItems.AddItem((void*)item)) { if (removeIndex < index) @@ -669,9 +669,9 @@ DragSortableListView::CopyItems(const BList& indices, int32 toIndex) BList clonedItems; int32 count = indices.CountItems(); for (int32 i = 0; i < count; i++) { - int32 index = (int32)indices.ItemAtFast(i); + int32 index = (int32)(addr_t)indices.ItemAtFast(i); BListItem* item = CloneItem(index); - if (item && !clonedItems.AddItem((void*)item)) + if (item && !clonedItems.AddItem((void*)(addr_t)item)) delete item; } count = clonedItems.CountItems(); @@ -693,7 +693,7 @@ DragSortableListView::RemoveItemList(const BList& indices) { int32 count = indices.CountItems(); for (int32 i = 0; i < count; i++) { - int32 index = (int32)indices.ItemAtFast(i) - i; + int32 index = (int32)(addr_t)indices.ItemAtFast(i) - i; delete RemoveItem(index); } } @@ -706,7 +706,7 @@ DragSortableListView::GetSelectedItems(BList& indices) int32 index = CurrentSelection(i); if (index < 0) break; - if (!indices.AddItem((void*)index)) + if (!indices.AddItem((void*)(addr_t)index)) break; } } @@ -731,7 +731,7 @@ DragSortableListView::RemoveAll() BList indices; int32 count = CountItems(); for (int32 i = 0; i < count; i++) { - if (!indices.AddItem((void*)i)) + if (!indices.AddItem((void*)(addr_t)i)) break; } diff --git a/src/apps/mediaplayer/playlist/PlaylistListView.cpp b/src/apps/mediaplayer/playlist/PlaylistListView.cpp index df2e04811b..940b5a2462 100644 --- a/src/apps/mediaplayer/playlist/PlaylistListView.cpp +++ b/src/apps/mediaplayer/playlist/PlaylistListView.cpp @@ -425,7 +425,7 @@ PlaylistListView::Randomize() int32 index = CurrentSelection(count); if (index < 0) break; - if (!indices.AddItem((void*)index)) + if (!indices.AddItem((void*)(addr_t)index)) return; count++; } @@ -435,7 +435,7 @@ PlaylistListView::Randomize() // no selection, simply add all items count = CountItems(); for (int32 i = 0; i < count; i++) { - if (!indices.AddItem((void*)i)) + if (!indices.AddItem((void*)(addr_t)i)) return; } } @@ -458,7 +458,7 @@ void PlaylistListView::RemoveToTrash(int32 index) { BList indices; - indices.AddItem((void*)index); + indices.AddItem((void*)(addr_t)index); RemoveItemList(indices, true); } diff --git a/src/apps/mediaplayer/playlist/RandomizePLItemsCommand.cpp b/src/apps/mediaplayer/playlist/RandomizePLItemsCommand.cpp index 3f9ad41129..da6eec2538 100644 --- a/src/apps/mediaplayer/playlist/RandomizePLItemsCommand.cpp +++ b/src/apps/mediaplayer/playlist/RandomizePLItemsCommand.cpp @@ -48,7 +48,7 @@ RandomizePLItemsCommand::RandomizePLItemsCommand(Playlist* playlist, BList indexSet; for (int32 i = 0; i < fCount; i++) { fItems[i] = fPlaylist->ItemAt(fListIndices[i]); - if (fItems[i] == NULL || !indexSet.AddItem((void*)i)) { + if (fItems[i] == NULL || !indexSet.AddItem((void*)(addr_t)i)) { // indicate a bad object state delete[] fItems; fItems = NULL; @@ -59,7 +59,7 @@ RandomizePLItemsCommand::RandomizePLItemsCommand(Playlist* playlist, // remove the indices from the set in random order for (int32 i = 0; i < fCount; i++) { int32 randomSetIndex = rand() % indexSet.CountItems(); - fRandomInternalIndices[i] = (int32)indexSet.RemoveItem(randomSetIndex); + fRandomInternalIndices[i] = (int32)(addr_t)indexSet.RemoveItem(randomSetIndex); } } diff --git a/src/apps/midiplayer/MidiPlayerWindow.cpp b/src/apps/midiplayer/MidiPlayerWindow.cpp index e098f584a0..95dbe958e9 100644 --- a/src/apps/midiplayer/MidiPlayerWindow.cpp +++ b/src/apps/midiplayer/MidiPlayerWindow.cpp @@ -394,7 +394,7 @@ void MidiPlayerWindow::StartSynth() { synth.Start(); - synth.SetFileHook(_StopHook, (int32) this); + synth.SetFileHook(_StopHook, (int32)(addr_t)this); playing = true; } @@ -412,7 +412,7 @@ MidiPlayerWindow::StopSynth() void MidiPlayerWindow::_StopHook(int32 arg) { - ((MidiPlayerWindow*)arg)->StopHook(); + ((MidiPlayerWindow*)(addr_t)arg)->StopHook(); } diff --git a/src/apps/packageinstaller/PackageInfo.cpp b/src/apps/packageinstaller/PackageInfo.cpp index 22cfe55e35..93549344ad 100644 --- a/src/apps/packageinstaller/PackageInfo.cpp +++ b/src/apps/packageinstaller/PackageInfo.cpp @@ -73,7 +73,7 @@ PackageInfo::~PackageInfo() { pkg_profile *iter = 0; while (1) { - iter = static_cast(fProfiles.RemoveItem((long int)0)); + iter = static_cast(fProfiles.RemoveItem((int32)0)); if (iter == NULL) break; @@ -82,7 +82,7 @@ PackageInfo::~PackageInfo() PackageItem *file = 0; while (true) { - file = static_cast(fFiles.RemoveItem((long int)0)); + file = static_cast(fFiles.RemoveItem((int32)0)); if (file == NULL) break; @@ -90,7 +90,7 @@ PackageInfo::~PackageInfo() } while (true) { - file = static_cast(fScripts.RemoveItem((long int)0)); + file = static_cast(fScripts.RemoveItem((int32)0)); if (file == NULL) break; diff --git a/src/apps/people/PersonView.cpp b/src/apps/people/PersonView.cpp index 9dc3165ef1..656bef1021 100644 --- a/src/apps/people/PersonView.cpp +++ b/src/apps/people/PersonView.cpp @@ -217,7 +217,7 @@ PersonView::BuildGroupMenu() if (file.InitCheck() == B_OK && file.GetAttrInfo(fCategoryAttribute, &info) == B_OK && info.size > 1) { - if (info.size > sizeof(buffer)) + if (info.size > (off_t)sizeof(buffer)) info.size = sizeof(buffer); if (file.ReadAttr(fCategoryAttribute.String(), B_STRING_TYPE, diff --git a/src/apps/powerstatus/PowerStatusView.cpp b/src/apps/powerstatus/PowerStatusView.cpp index 62ef64e4d7..c7a6968243 100644 --- a/src/apps/powerstatus/PowerStatusView.cpp +++ b/src/apps/powerstatus/PowerStatusView.cpp @@ -321,10 +321,11 @@ PowerStatusView::_SetLabel(char* buffer, size_t bufferLength) close = ")"; } - if (!fShowTime && fPercent >= 0) - snprintf(buffer, bufferLength, "%s%ld%%%s", open, fPercent, close); - else if (fShowTime && fTimeLeft >= 0) { - snprintf(buffer, bufferLength, "%s%ld:%02ld%s", + if (!fShowTime && fPercent >= 0) { + snprintf(buffer, bufferLength, "%s%" B_PRId32 "%%%s", open, fPercent, + close); + } else if (fShowTime && fTimeLeft >= 0) { + snprintf(buffer, bufferLength, "%s%" B_PRId32 ":%02" B_PRId32 "%s", open, fTimeLeft / 3600, (fTimeLeft / 60) % 60, close); } } @@ -372,11 +373,12 @@ PowerStatusView::Update(bool force) close = ")"; } if (fHasBattery) { - size_t length = snprintf(text, sizeof(text), "%s%ld%%%s", - open, fPercent, close); + size_t length = snprintf(text, sizeof(text), "%s%" B_PRId32 + "%%%s", open, fPercent, close); if (fTimeLeft) { length += snprintf(text + length, sizeof(text) - length, - "\n%ld:%02ld", fTimeLeft / 3600, (fTimeLeft / 60) % 60); + "\n%" B_PRId32 ":%02" B_PRId32, fTimeLeft / 3600, + (fTimeLeft / 60) % 60); } const char* state = NULL; diff --git a/src/apps/showimage/Filter.cpp b/src/apps/showimage/Filter.cpp index 6c5769abdd..c8e7fc7735 100644 --- a/src/apps/showimage/Filter.cpp +++ b/src/apps/showimage/Filter.cpp @@ -829,6 +829,7 @@ Scaler::Dither(int32 fromRow, int32 toRow) color.red = Limit(srcData[2] + error[0] / 16); color.green = Limit(srcData[1] + error[1] / 16); color.blue = Limit(srcData[0] + error[2] / 16); + color.alpha = UINT8_MAX; index = screen.IndexForColor(color); actualColor = screen.ColorForIndex(index); @@ -879,6 +880,7 @@ Scaler::Dither(int32 fromRow, int32 toRow) color.red = Limit(srcData[2] + error[0] / 16); color.green = Limit(srcData[1] + error[1] / 16); color.blue = Limit(srcData[0] + error[2] / 16); + color.alpha = UINT8_MAX; index = screen.IndexForColor(color); actualColor = screen.ColorForIndex(index); diff --git a/src/apps/terminal/BasicTerminalBuffer.cpp b/src/apps/terminal/BasicTerminalBuffer.cpp index f5bcd6199a..dfbb54e28d 100644 --- a/src/apps/terminal/BasicTerminalBuffer.cpp +++ b/src/apps/terminal/BasicTerminalBuffer.cpp @@ -431,48 +431,31 @@ BasicTerminalBuffer::FindWord(const TermPos& pos, TermPos start(x, y); TermPos end(x + (IS_WIDTH(line->cells[x].attributes) ? FULL_WIDTH : HALF_WIDTH), y); - while (true) { - if (--x < 0) { - // Hit the beginning of the line -- continue at the end of the - // previous line, if it soft-breaks. - y--; - if ((line = _HistoryLineAt(y, lineBuffer)) == NULL - || !line->softBreak || line->length == 0) { - break; - } - x = line->length - 1; - } - if (x > 0 && IS_WIDTH(line->cells[x - 1].attributes)) - x--; - - if (classifier->Classify(line->cells[x].character) != type) + for (;;) { + TermPos previousPos = start; + if (!_PreviousLinePos(lineBuffer, line, previousPos) + || classifier->Classify(line->cells[previousPos.x].character) + != type) { break; + } - start.SetTo(x, y); + start = previousPos; } // find the end - x = end.x; - y = end.y; - line = _HistoryLineAt(y, lineBuffer); + line = _HistoryLineAt(end.y, lineBuffer); - while (true) { - if (x >= line->length) { - // Hit the end of the line -- if it soft-breaks continue with the - // next line. - if (!line->softBreak) - break; - y++; - x = 0; - if ((line = _HistoryLineAt(y, lineBuffer)) == NULL) - break; - } - - if (classifier->Classify(line->cells[x].character) != type) + for (;;) { + TermPos nextPos = end; + if (!_NormalizeLinePos(lineBuffer, line, nextPos)) break; - x += IS_WIDTH(line->cells[x].attributes) ? FULL_WIDTH : HALF_WIDTH; - end.SetTo(x, y); + if (classifier->Classify(line->cells[nextPos.x].character) != type) + break; + + nextPos.x += IS_WIDTH(line->cells[nextPos.x].attributes) + ? FULL_WIDTH : HALF_WIDTH; + end = nextPos; } _start = start; @@ -481,6 +464,34 @@ BasicTerminalBuffer::FindWord(const TermPos& pos, } +bool +BasicTerminalBuffer::PreviousLinePos(TermPos& pos) const +{ + TerminalLine* lineBuffer = ALLOC_LINE_ON_STACK(fWidth); + TerminalLine* line = _HistoryLineAt(pos.y, lineBuffer); + if (line == NULL || pos.x < 0 || pos.x >= fWidth) + return false; + + return _PreviousLinePos(lineBuffer, line, pos); +} + + +bool +BasicTerminalBuffer::NextLinePos(TermPos& pos, bool normalize) const +{ + TerminalLine* lineBuffer = ALLOC_LINE_ON_STACK(fWidth); + TerminalLine* line = _HistoryLineAt(pos.y, lineBuffer); + if (line == NULL || pos.x < 0 || pos.x > fWidth) + return false; + + if (!_NormalizeLinePos(lineBuffer, line, pos)) + return false; + + pos.x += IS_WIDTH(line->cells[pos.x].attributes) ? FULL_WIDTH : HALF_WIDTH; + return !normalize || _NormalizeLinePos(lineBuffer, line, pos); +} + + int32 BasicTerminalBuffer::LineLength(int32 index) const { @@ -1692,6 +1703,46 @@ BasicTerminalBuffer::_NextChar(TermPos& pos, UTF8Char& c) const } +bool +BasicTerminalBuffer::_PreviousLinePos(TerminalLine* lineBuffer, + TerminalLine*& line, TermPos& pos) const +{ + if (--pos.x < 0) { + // Hit the beginning of the line -- continue at the end of the + // previous line, if it soft-breaks. + pos.y--; + if ((line = _HistoryLineAt(pos.y, lineBuffer)) == NULL + || !line->softBreak || line->length == 0) { + return false; + } + pos.x = line->length - 1; + } + if (pos.x > 0 && IS_WIDTH(line->cells[pos.x - 1].attributes)) + pos.x--; + + return true; +} + + +bool +BasicTerminalBuffer::_NormalizeLinePos(TerminalLine* lineBuffer, + TerminalLine*& line, TermPos& pos) const +{ + if (pos.x < line->length) + return true; + + // Hit the end of the line -- if it soft-breaks continue with the + // next line. + if (!line->softBreak) + return false; + + pos.y++; + pos.x = 0; + line = _HistoryLineAt(pos.y, lineBuffer); + return line != NULL; +} + + #ifdef USE_DEBUG_SNAPSHOTS void diff --git a/src/apps/terminal/BasicTerminalBuffer.h b/src/apps/terminal/BasicTerminalBuffer.h index ed30bb09f2..757984f6b2 100644 --- a/src/apps/terminal/BasicTerminalBuffer.h +++ b/src/apps/terminal/BasicTerminalBuffer.h @@ -107,6 +107,14 @@ public: int32 LineLength(int32 index) const; int32 GetLineColor(int32 index) const; + bool PreviousLinePos(TermPos& pos) const; + bool NextLinePos(TermPos& pos, bool normalize) const; + // normalize specifies that the returned + // position must be a valid position, i.e. + // actually point to a character (as opposed + // to just pointing to the position after a + // character). + bool Find(const char* pattern, const TermPos& start, bool forward, bool caseSensitive, bool matchWord, TermPos& matchStart, @@ -205,6 +213,11 @@ protected: bool _PreviousChar(TermPos& pos, UTF8Char& c) const; bool _NextChar(TermPos& pos, UTF8Char& c) const; + bool _PreviousLinePos(TerminalLine* lineBuffer, + TerminalLine*& line, TermPos& pos) const; + bool _NormalizeLinePos(TerminalLine* lineBuffer, + TerminalLine*& line, TermPos& pos) const; + protected: // screen width/height int32 fWidth; diff --git a/src/apps/terminal/FindWindow.cpp b/src/apps/terminal/FindWindow.cpp index 181ddf2f69..02bd9c0fea 100644 --- a/src/apps/terminal/FindWindow.cpp +++ b/src/apps/terminal/FindWindow.cpp @@ -1,8 +1,11 @@ /* - * Copyright 2007-2010, Haiku, Inc. All rights reserved. + * Copyright 2007-2013 Haiku, Inc. All rights reserved. * Copyright 2003-2004 Kian Duffy, myob@users.sourceforge.net * Parts Copyright 1998-1999 Kazuho Okui and Takashi Murai. * All rights reserved. Distributed under the terms of the MIT license. + * + * Authors: + * John Scipione, jscipione@gmail.com */ #include "FindWindow.h" @@ -18,6 +21,7 @@ #include #include #include +#include #include #include @@ -26,11 +30,13 @@ const uint32 MSG_FIND_HIDE = 'Fhid'; const uint32 TOGGLE_FIND_CONTROL = 'MTFG'; const BRect kWindowFrame(10, 30, 250, 200); + #undef B_TRANSLATION_CONTEXT #define B_TRANSLATION_CONTEXT "Terminal FindWindow" + FindWindow::FindWindow(BMessenger messenger, const BString& str, - bool findSelection, bool matchWord, bool matchCase, bool forwardSearch) + bool findSelection, bool matchWord, bool matchCase, bool forwardSearch) : BWindow(kWindowFrame, B_TRANSLATE("Find"), B_FLOATING_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_CLOSE_ON_ESCAPE @@ -39,26 +45,31 @@ FindWindow::FindWindow(BMessenger messenger, const BString& str, { SetLayout(new BGroupLayout(B_VERTICAL)); - BBox *separator = new BBox("separator"); + BBox* separator = new BBox("separator"); separator->SetExplicitMinSize(BSize(250.0, B_SIZE_UNSET)); separator->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1.0)); BRadioButton* useSelection = NULL; const float spacing = be_control_look->DefaultItemSpacing(); - AddChild(BGroupLayoutBuilder(B_VERTICAL, 5.0) + AddChild(BGroupLayoutBuilder(B_VERTICAL, B_USE_SMALL_SPACING) .SetInsets(spacing, spacing, spacing, spacing) - .Add(BGridLayoutBuilder() + .Add(BGridLayoutBuilder(B_USE_SMALL_SPACING, B_USE_SMALL_SPACING) .Add(fTextRadio = new BRadioButton(B_TRANSLATE("Use text:"), new BMessage(TOGGLE_FIND_CONTROL)), 0, 0) .Add(fFindLabel = new BTextControl(NULL, NULL, NULL), 1, 0) .Add(useSelection = new BRadioButton(B_TRANSLATE("Use selection"), new BMessage(TOGGLE_FIND_CONTROL)), 0, 1)) + .Add(BSpaceLayoutItem::CreateVerticalStrut(spacing / 4)) .Add(separator) + .Add(BSpaceLayoutItem::CreateVerticalStrut(spacing / 4)) .Add(fForwardSearchBox = new BCheckBox(B_TRANSLATE("Search forward"))) .Add(fMatchCaseBox = new BCheckBox(B_TRANSLATE("Match case"))) .Add(fMatchWordBox = new BCheckBox(B_TRANSLATE("Match word"))) - .Add(fFindButton = new BButton(B_TRANSLATE("Find"), + .AddGroup(B_HORIZONTAL) + .AddGlue() + .Add(fFindButton = new BButton(B_TRANSLATE("Find"), new BMessage(MSG_FIND))) + .End() .TopView()); fFindLabel->SetDivider(0.0); @@ -87,8 +98,6 @@ FindWindow::FindWindow(BMessenger messenger, const BString& str, fFindButton->MakeDefault(true); AddShortcut((uint32)'W', B_COMMAND_KEY, new BMessage(MSG_FIND_HIDE)); - - Show(); } diff --git a/src/apps/terminal/FindWindow.h b/src/apps/terminal/FindWindow.h index f3c9bb3776..f2b6e3cf7a 100644 --- a/src/apps/terminal/FindWindow.h +++ b/src/apps/terminal/FindWindow.h @@ -1,5 +1,5 @@ /* - * Copyright 2007, Haiku, Inc. + * Copyright 2007-2013 Haiku, Inc. All rights reserved. * Copyright 2003-2004 Kian Duffy, myob@users.sourceforge.net * Parts Copyright 1998-1999 Kazuho Okui and Takashi Murai. * All rights reserved. Distributed under the terms of the MIT license. @@ -29,8 +29,8 @@ public: bool matchCase, bool forwardSearch); virtual ~FindWindow(); - virtual void Quit(); virtual void MessageReceived(BMessage* msg); + virtual void Quit(); private: void _SendFindMessage(); diff --git a/src/apps/terminal/HyperLink.cpp b/src/apps/terminal/HyperLink.cpp new file mode 100644 index 0000000000..97e294f7eb --- /dev/null +++ b/src/apps/terminal/HyperLink.cpp @@ -0,0 +1,45 @@ +/* + * Copyright 2013, Ingo Weinhold, ingo_weinhold@gmx.de. + * Distributed under the terms of the MIT License. + */ + + +#include "HyperLink.h" + +#include +#include + +#include "TermConst.h" + + +HyperLink::HyperLink() + : + fAddress(), + fType(TYPE_URL) +{ +} + + +HyperLink::HyperLink(const BString& address, Type type, + const BString& baseAddress) + : + fAddress(address), + fBaseAddress(baseAddress.IsEmpty() ? address : baseAddress), + fType(type) +{ +} + + +status_t +HyperLink::Open() +{ + if (!IsValid()) + return B_BAD_VALUE; + + // open with the "open" program + BString address(fAddress); + address.CharacterEscape(kShellEscapeCharacters, '\\'); + BString commandLine; + commandLine.SetToFormat("/bin/open %s", address.String()); + return system(commandLine) == 0 ? B_OK : errno; +} diff --git a/src/apps/terminal/HyperLink.h b/src/apps/terminal/HyperLink.h new file mode 100644 index 0000000000..735c84c50f --- /dev/null +++ b/src/apps/terminal/HyperLink.h @@ -0,0 +1,41 @@ +/* + * Copyright 2013, Ingo Weinhold, ingo_weinhold@gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef HYPER_LINK_H +#define HYPER_LINK_H + + +#include + + +class HyperLink { +public: + enum Type { + TYPE_URL, + TYPE_PATH, + TYPE_PATH_WITH_LINE, + TYPE_PATH_WITH_LINE_AND_COLUMN + }; + +public: + HyperLink(); + HyperLink(const BString& address, Type type, + const BString& baseAddress = BString()); + + bool IsValid() const { return !fAddress.IsEmpty(); } + + const BString& Address() const { return fAddress; } + const BString& BaseAddress() const { return fBaseAddress; } + Type GetType() const { return fType; } + + status_t Open(); + +private: + BString fAddress; + BString fBaseAddress; + Type fType; +}; + + +#endif // HYPER_LINK_H diff --git a/src/apps/terminal/Jamfile b/src/apps/terminal/Jamfile index c8a114e927..98a062afa8 100644 --- a/src/apps/terminal/Jamfile +++ b/src/apps/terminal/Jamfile @@ -16,6 +16,7 @@ Application Terminal : FindWindow.cpp Globals.cpp HistoryBuffer.cpp + HyperLink.cpp InlineInput.cpp PatternEvaluator.cpp PrefHandler.cpp @@ -33,6 +34,8 @@ Application Terminal : TermParse.cpp TermScrollView.cpp TermView.cpp + TermViewHighlight.cpp + TermViewStates.cpp TermWindow.cpp TitlePlaceholderMapper.cpp VTKeyTbl.c diff --git a/src/apps/terminal/TermConst.cpp b/src/apps/terminal/TermConst.cpp index 1b88bc0493..2e2c9cdf6a 100644 --- a/src/apps/terminal/TermConst.cpp +++ b/src/apps/terminal/TermConst.cpp @@ -31,3 +31,7 @@ const char* const kTooTipSetWindowTitlePlaceholders = B_TRANSLATE( "\t%p\t-\tThe name of the active process in the current tab.\n" "\t%t\t-\tThe title of the current tab.\n" "\t%%\t-\tThe character '%'."); + +const char* const kShellEscapeCharacters = " ~`#$&*()\\|[]{};'\"<>?!"; +const char* const kDefaultAdditionalWordCharacters = ":@-./_~"; +const char* const kURLAdditionalWordCharacters = ":/-._~[]?#@!$&'()*+,;="; diff --git a/src/apps/terminal/TermConst.h b/src/apps/terminal/TermConst.h index 942d9215d8..9d1c942f15 100644 --- a/src/apps/terminal/TermConst.h +++ b/src/apps/terminal/TermConst.h @@ -145,6 +145,10 @@ static const char* const PREF_WINDOW_TITLE = "Window title"; extern const char* const kTooTipSetTabTitlePlaceholders; extern const char* const kTooTipSetWindowTitlePlaceholders; +extern const char* const kShellEscapeCharacters; +extern const char* const kDefaultAdditionalWordCharacters; +extern const char* const kURLAdditionalWordCharacters; + // Cursor style enum { diff --git a/src/apps/terminal/TermView.cpp b/src/apps/terminal/TermView.cpp index 89faf10feb..610208e931 100644 --- a/src/apps/terminal/TermView.cpp +++ b/src/apps/terminal/TermView.cpp @@ -16,7 +16,6 @@ #include "TermView.h" -#include #include #include #include @@ -62,22 +61,13 @@ #include "TermConst.h" #include "TerminalBuffer.h" #include "TerminalCharClassifier.h" +#include "TermViewStates.h" #include "VTkeymap.h" -// defined in VTKeyTbl.c -extern int function_keycode_table[]; -extern char *function_key_char_table[]; - #define ROWS_DEFAULT 25 #define COLUMNS_DEFAULT 80 -// selection granularity -enum { - SELECT_CHARS, - SELECT_WORDS, - SELECT_LINES -}; #undef B_TRANSLATION_CONTEXT #define B_TRANSLATION_CONTEXT "Terminal TermView" @@ -101,7 +91,6 @@ static property_info sPropList[] = { static const uint32 kUpdateSigWinch = 'Rwin'; static const uint32 kBlinkCursor = 'BlCr'; -static const uint32 kAutoScroll = 'AScr'; static const bigtime_t kSyncUpdateGranularity = 100000; // 0.1 s @@ -112,9 +101,6 @@ static const bigtime_t kCursorBlinkInterval = 500000; static const rgb_color kBlackColor = { 0, 0, 0, 255 }; static const rgb_color kWhiteColor = { 255, 255, 255, 255 }; -static const char* kDefaultSpecialWordChars = ":@-./_~"; -static const char* kEscapeCharacters = " ~`#$&*()\\|[]{};'\"<>?!"; - // secondary mouse button drop const int32 kSecondaryMouseDropAction = 'SMDA'; @@ -135,40 +121,28 @@ restrict_value(const Type& value, const Type& min, const Type& max) } -// #pragma mark - CharClassifier +// #pragma mark - TextBufferSyncLocker -class TermView::CharClassifier : public TerminalCharClassifier { +class TermView::TextBufferSyncLocker { public: - CharClassifier(const char* specialWordChars) + TextBufferSyncLocker(TermView* view) + : + fView(view) { - const char* p = specialWordChars; - while (p != NULL && *p) { - int count = UTF8Char::ByteCount(*p); - if (count <= 0 || count > 4) - break; - fSpecialWordChars.push_back(UTF8Char(p, count)); - p += count; - } + fView->fTextBuffer->Lock(); } - virtual int Classify(const UTF8Char& character) + ~TextBufferSyncLocker() { - if (character.IsSpace()) - return CHAR_TYPE_SPACE; + fView->fTextBuffer->Unlock(); - if (character.IsAlNum()) - return CHAR_TYPE_WORD_CHAR; - - if (std::find(fSpecialWordChars.begin(), fSpecialWordChars.end(), - character) != fSpecialWordChars.end()) - return CHAR_TYPE_WORD_CHAR; - - return CHAR_TYPE_WORD_DELIMITER; + if (fView->fVisibleTextBufferChanged) + fView->_VisibleTextBufferChanged(); } private: - std::vector fSpecialWordChars; + TermView* fView; }; @@ -309,6 +283,7 @@ TermView::_InitObject(const ShellParameters& shellParameters) fCursor = TermPos(0, 0); fTextBuffer = NULL; fVisibleTextBuffer = NULL; + fVisibleTextBufferChanged = false; fScrollBar = NULL; fInline = NULL; fSelectForeColor = kWhiteColor; @@ -318,16 +293,19 @@ TermView::_InitObject(const ShellParameters& shellParameters) fScrolledSinceLastSync = 0; fSyncRunner = NULL; fConsiderClockedSync = false; - fSelStart = TermPos(-1, -1); - fSelEnd = TermPos(-1, -1); - fMouseTracking = false; - fCheckMouseTracking = false; + fSelection.SetHighlighter(this); + fSelection.SetRange(TermPos(0, 0), TermPos(0, 0)); fPrevPos = TermPos(-1, - 1); fReportX10MouseEvent = false; fReportNormalMouseEvent = false; fReportButtonMouseEvent = false; fReportAnyMouseEvent = false; fMouseClipboard = be_clipboard; + fDefaultState = new(std::nothrow) DefaultState(this); + fSelectState = new(std::nothrow) SelectState(this); + fHyperLinkState = new(std::nothrow) HyperLinkState(this); + fHyperLinkMenuState = new(std::nothrow) HyperLinkMenuState(this); + fActiveState = NULL; fTextBuffer = new(std::nothrow) TerminalBuffer; if (fTextBuffer == NULL) @@ -338,8 +316,8 @@ TermView::_InitObject(const ShellParameters& shellParameters) return B_NO_MEMORY; // TODO: Make the special word chars user-settable! - fCharClassifier = new(std::nothrow) CharClassifier( - kDefaultSpecialWordChars); + fCharClassifier = new(std::nothrow) DefaultCharClassifier( + kDefaultAdditionalWordCharacters); if (fCharClassifier == NULL) return B_NO_MEMORY; @@ -371,9 +349,18 @@ TermView::_InitObject(const ShellParameters& shellParameters) if (error < B_OK) return error; + fHighlights.AddItem(&fSelection); + + if (fDefaultState == NULL || fSelectState == NULL || fHyperLinkState == NULL + || fHyperLinkMenuState == NULL) { + return B_NO_MEMORY; + } + SetLowColor(fTextBackColor); SetViewColor(B_TRANSPARENT_32_BIT); + _NextState(fDefaultState); + return B_OK; } @@ -385,6 +372,10 @@ TermView::~TermView() _DetachShell(); + delete fDefaultState; + delete fSelectState; + delete fHyperLinkState; + delete fHyperLinkMenuState; delete fSyncRunner; delete fAutoScrollRunner; delete fCharClassifier; @@ -459,6 +450,20 @@ TermView::Archive(BMessage* data, bool deep) const } +rgb_color +TermView::ForegroundColor() +{ + return fSelectForeColor; +} + + +rgb_color +TermView::BackgroundColor() +{ + return fSelectBackColor; +} + + inline int32 TermView::_LineAt(float y) { @@ -480,7 +485,7 @@ TermView::_LineOffset(int32 index) // convert view coordinates to terminal text buffer position -inline TermPos +TermPos TermView::_ConvertToTerminal(const BPoint &p) { return TermPos(p.x >= 0 ? (int32)p.x / fFontWidth : -1, _LineAt(p.y)); @@ -584,12 +589,13 @@ TermView::SetTermSize(int rows, int columns, bool notifyShell) // synchronize the visible text buffer { - BAutolock _(fTextBuffer); + TextBufferSyncLocker _(this); _SynchronizeWithTextBuffer(0, -1); int32 offset = _LineAt(0); fVisibleTextBuffer->SynchronizeWith(fTextBuffer, offset, offset, offset + rows + 2); + fVisibleTextBufferChanged = true; } if (notifyShell) @@ -786,7 +792,8 @@ TermView::Copy(BClipboard *clipboard) return; BString copyStr; - fTextBuffer->GetStringFromRegion(copyStr, fSelStart, fSelEnd); + fTextBuffer->GetStringFromRegion(copyStr, fSelection.Start(), + fSelection.End()); if (clipboard->Lock()) { BMessage *clipMsg = NULL; @@ -936,8 +943,11 @@ TermView::_Deactivate() //! Draw part of a line in the given view. void TermView::_DrawLinePart(int32 x1, int32 y1, uint32 attr, char *buf, - int32 width, bool mouse, bool cursor, BView *inView) + int32 width, Highlight* highlight, bool cursor, BView *inView) { + if (highlight != NULL) + attr = highlight->Highlighter()->AdjustTextAttributes(attr); + inView->SetFont(IS_BOLD(attr) && !fEmulateBold ? &fBoldFont : &fHalfFont); // Set pen point @@ -960,9 +970,9 @@ TermView::_DrawLinePart(int32 x1, int32 y1, uint32 attr, char *buf, if (cursor) { rgb_fore = fCursorForeColor; rgb_back = fCursorBackColor; - } else if (mouse) { - rgb_fore = fSelectForeColor; - rgb_back = fSelectBackColor; + } else if (highlight != NULL) { + rgb_fore = highlight->Highlighter()->ForegroundColor(); + rgb_back = highlight->Highlighter()->BackgroundColor(); } else { // Reverse attribute(If selected area, don't reverse color). if (IS_INVERSE(attr)) { @@ -1027,7 +1037,7 @@ TermView::_DrawCursor() } } - bool selected = _CheckSelectedRegion(TermPos(fCursor.x, fCursor.y)); + Highlight* highlight = _CheckHighlightRegion(TermPos(fCursor.x, fCursor.y)); if (fVisibleTextBuffer->GetChar(fCursor.y - firstVisible, fCursor.x, character, attr) == A_CHAR && (fCursorStyle == BLOCK_CURSOR || !cursorVisible)) { @@ -1039,11 +1049,11 @@ TermView::_DrawCursor() buffer[bytes] = '\0'; _DrawLinePart(fCursor.x * fFontWidth, (int32)rect.top, attr, buffer, - width, selected, cursorVisible, this); + width, highlight, cursorVisible, this); } else { - if (selected) - SetHighColor(fSelectBackColor); - else if (cursorVisible ) + if (highlight != NULL) + SetHighColor(highlight->Highlighter()->BackgroundColor()); + else if (cursorVisible) SetHighColor(fCursorBackColor ); else { uint32 count = 0; @@ -1146,6 +1156,7 @@ void TermView::AttachedToWindow() { fMouseButtons = 0; + fModifiers = modifiers(); // update the terminal size because it may have changed while the TermView // was detached from the window. On such conditions FrameResized was not @@ -1164,7 +1175,7 @@ TermView::AttachedToWindow() &message, 500000); { - BAutolock _(fTextBuffer); + TextBufferSyncLocker _(this); fTextBuffer->SetListener(thisMessenger); _SynchronizeWithTextBuffer(0, -1); } @@ -1242,15 +1253,15 @@ TermView::Draw(BRect updateRect) for (int32 i = k; i <= x2;) { int32 lastColumn = x2; - bool insideSelection = _CheckSelectedRegion(j, i, lastColumn); + Highlight* highlight = _CheckHighlightRegion(j, i, lastColumn); // This will clip lastColumn to the selection start or end // to ensure the selection is not drawn at the same time as // something else int32 count = fVisibleTextBuffer->GetString(j - firstVisible, i, lastColumn, buf, attr); -// debug_printf(" fVisibleTextBuffer->GetString(%ld, %ld, %ld) -> (%ld, \"%.*s\"), selected: %d\n", -// j - firstVisible, i, lastColumn, count, (int)count, buf, insideSelection); +// debug_printf(" fVisibleTextBuffer->GetString(%ld, %ld, %ld) -> (%ld, \"%.*s\"), highlight: %p\n", +// j - firstVisible, i, lastColumn, count, (int)count, buf, highlight); if (count == 0) { // No chars to draw : we just fill the rectangle with the @@ -1260,8 +1271,9 @@ TermView::Draw(BRect updateRect) fFontWidth * nextColumn - 1, 0); rect.bottom = rect.top + fFontHeight - 1; - rgb_color rgb_back = insideSelection - ? fSelectBackColor : fTextBackColor; + rgb_color rgb_back = highlight != NULL + ? highlight->Highlighter()->BackgroundColor() + : fTextBackColor; if (fTextBuffer->IsAlternateScreenActive()) { // alternate screen uses cell attributes @@ -1296,7 +1308,7 @@ TermView::Draw(BRect updateRect) count = FULL_WIDTH; _DrawLinePart(fFontWidth * i, (int32)_LineOffset(j), - attr, buf, count, insideSelection, false, this); + attr, buf, count, highlight, false, this); i += count; } } @@ -1367,6 +1379,15 @@ TermView::WindowActivated(bool active) if (fActive) _Deactivate(); } + + fActiveState->WindowActivated(active); + + if (active) { + int32 oldModifiers = fModifiers; + fModifiers = modifiers(); + if (fModifiers != oldModifiers) + fActiveState->ModifiersChanged(oldModifiers, fModifiers); + } } @@ -1388,165 +1409,7 @@ TermView::MakeFocus(bool focusState) void TermView::KeyDown(const char *bytes, int32 numBytes) { - int32 key, mod, rawChar; - BMessage *currentMessage = Looper()->CurrentMessage(); - if (currentMessage == NULL) - return; - - currentMessage->FindInt32("modifiers", &mod); - currentMessage->FindInt32("key", &key); - currentMessage->FindInt32("raw_char", &rawChar); - - _ActivateCursor(true); - - // handle multi-byte chars - if (numBytes > 1) { - if (fEncoding != M_UTF8) { - char destBuffer[16]; - int32 destLen = sizeof(destBuffer); - int32 state = 0; - convert_from_utf8(fEncoding, bytes, &numBytes, destBuffer, - &destLen, &state, '?'); - _ScrollTo(0, true); - fShell->Write(destBuffer, destLen); - return; - } - - _ScrollTo(0, true); - fShell->Write(bytes, numBytes); - return; - } - - // Terminal filters RET, ENTER, F1...F12, and ARROW key code. - const char *toWrite = NULL; - - switch (*bytes) { - case B_RETURN: - if (rawChar == B_RETURN) - toWrite = "\r"; - break; - - case B_DELETE: - toWrite = DELETE_KEY_CODE; - break; - - case B_BACKSPACE: - // Translate only the actual backspace key to the backspace - // code. CTRL-H shall just be echoed. - if (!((mod & B_CONTROL_KEY) && rawChar == 'h')) - toWrite = BACKSPACE_KEY_CODE; - break; - - case B_LEFT_ARROW: - if (rawChar == B_LEFT_ARROW) { - if ((mod & B_SHIFT_KEY) != 0) { - if (fListener != NULL) - fListener->PreviousTermView(this); - return; - } - if ((mod & B_CONTROL_KEY) || (mod & B_COMMAND_KEY)) - toWrite = CTRL_LEFT_ARROW_KEY_CODE; - else - toWrite = LEFT_ARROW_KEY_CODE; - } - break; - - case B_RIGHT_ARROW: - if (rawChar == B_RIGHT_ARROW) { - if ((mod & B_SHIFT_KEY) != 0) { - if (fListener != NULL) - fListener->NextTermView(this); - return; - } - if ((mod & B_CONTROL_KEY) || (mod & B_COMMAND_KEY)) - toWrite = CTRL_RIGHT_ARROW_KEY_CODE; - else - toWrite = RIGHT_ARROW_KEY_CODE; - } - break; - - case B_UP_ARROW: - if (mod & B_SHIFT_KEY) { - _ScrollTo(fScrollOffset - fFontHeight, true); - return; - } - if (rawChar == B_UP_ARROW) { - if (mod & B_CONTROL_KEY) - toWrite = CTRL_UP_ARROW_KEY_CODE; - else - toWrite = UP_ARROW_KEY_CODE; - } - break; - - case B_DOWN_ARROW: - if (mod & B_SHIFT_KEY) { - _ScrollTo(fScrollOffset + fFontHeight, true); - return; - } - - if (rawChar == B_DOWN_ARROW) { - if (mod & B_CONTROL_KEY) - toWrite = CTRL_DOWN_ARROW_KEY_CODE; - else - toWrite = DOWN_ARROW_KEY_CODE; - } - break; - - case B_INSERT: - if (rawChar == B_INSERT) - toWrite = INSERT_KEY_CODE; - break; - - case B_HOME: - if (rawChar == B_HOME) - toWrite = HOME_KEY_CODE; - break; - - case B_END: - if (rawChar == B_END) - toWrite = END_KEY_CODE; - break; - - case B_PAGE_UP: - if (mod & B_SHIFT_KEY) { - _ScrollTo(fScrollOffset - fFontHeight * fRows, true); - return; - } - if (rawChar == B_PAGE_UP) - toWrite = PAGE_UP_KEY_CODE; - break; - - case B_PAGE_DOWN: - if (mod & B_SHIFT_KEY) { - _ScrollTo(fScrollOffset + fFontHeight * fRows, true); - return; - } - if (rawChar == B_PAGE_DOWN) - toWrite = PAGE_DOWN_KEY_CODE; - break; - - case B_FUNCTION_KEY: - for (int32 i = 0; i < 12; i++) { - if (key == function_keycode_table[i]) { - toWrite = function_key_char_table[i]; - break; - } - } - break; - } - - // If the above code proposed an alternative string to write, we get it's - // length. Otherwise we write exactly the bytes passed to this method. - size_t toWriteLen; - if (toWrite != NULL) { - toWriteLen = strlen(toWrite); - } else { - toWrite = bytes; - toWriteLen = numBytes; - } - - _ScrollTo(0, true); - fShell->Write(toWrite, toWriteLen); + fActiveState->KeyDown(bytes, numBytes); } @@ -1593,6 +1456,9 @@ TermView::FrameResized(float width, float height) void TermView::MessageReceived(BMessage *msg) { + if (fActiveState->MessageReceived(msg)) + return; + entry_ref ref; const char *ctrl_l = "\x0c"; @@ -1733,6 +1599,15 @@ TermView::MessageReceived(BMessage *msg) break; } + case B_MODIFIERS_CHANGED: + { + int32 oldModifiers = fModifiers; + fModifiers = msg->GetInt32("modifiers", 0); + if (fModifiers != oldModifiers) + fActiveState->ModifiersChanged(oldModifiers, fModifiers); + break; + } + case B_INPUT_METHOD_EVENT: { int32 opcode; @@ -1829,15 +1704,12 @@ TermView::MessageReceived(BMessage *msg) case kUpdateSigWinch: _UpdateSIGWINCH(); break; - case kAutoScroll: - _AutoScrollUpdate(); - break; case kSecondaryMouseDropAction: _DoSecondaryMouseDropAction(msg); break; case MSG_TERMINAL_BUFFER_CHANGED: { - BAutolock _(fTextBuffer); + TextBufferSyncLocker _(this); _SynchronizeWithTextBuffer(0, -1); break; } @@ -2002,7 +1874,7 @@ TermView::ScrollTo(BPoint where) //debug_printf("fVisibleTextBuffer->ScrollBy(%ld)\n", newFirstLine - oldFirstLine); fVisibleTextBuffer->ScrollBy(newFirstLine - oldFirstLine); } - BAutolock _(fTextBuffer); + TextBufferSyncLocker _(this); if (diff < 0) _SynchronizeWithTextBuffer(newFirstLine, oldFirstLine - 1); else @@ -2164,11 +2036,11 @@ TermView::_DoSecondaryMouseDropAction(BMessage* msg) int32 slash = string.FindLast("/"); string.Truncate(slash); } - string.CharacterEscape(kEscapeCharacters, '\\'); + string.CharacterEscape(kShellEscapeCharacters, '\\'); itemString += string; break; } - string.CharacterEscape(kEscapeCharacters, '\\'); + string.CharacterEscape(kShellEscapeCharacters, '\\'); itemString += string; } @@ -2195,7 +2067,7 @@ TermView::_DoFileDrop(entry_ref& ref) BPath path(&ent); BString string(path.Path()); - string.CharacterEscape(kEscapeCharacters, '\\'); + string.CharacterEscape(kShellEscapeCharacters, '\\'); _WritePTY(string.String(), string.Length()); } @@ -2259,7 +2131,9 @@ TermView::_SynchronizeWithTextBuffer(int32 visibleDirtyTop, // sync time not passed yet -- keep counting fScrolledSinceLastSync += linesScrolled; return; - } else if (fScrolledSinceLastSync + linesScrolled <= fRows) { + } + + if (fScrolledSinceLastSync + linesScrolled <= fRows) { // time's up, but not enough happened delete fSyncRunner; fSyncRunner = NULL; @@ -2271,6 +2145,8 @@ TermView::_SynchronizeWithTextBuffer(int32 visibleDirtyTop, fScrolledSinceLastSync = 0; } + fVisibleTextBufferChanged = true; + // Simple case first -- complete invalidation. if (info.invalidateAll) { Invalidate(); @@ -2354,15 +2230,23 @@ TermView::_SynchronizeWithTextBuffer(int32 visibleDirtyTop, fVisibleTextBuffer->ScrollBy(linesScrolled); } - // move selection - if (fSelStart != fSelEnd) { - fSelStart.y -= linesScrolled; - fSelEnd.y -= linesScrolled; - fInitialSelectionStart.y -= linesScrolled; - fInitialSelectionEnd.y -= linesScrolled; + // move highlights + for (int32 i = 0; Highlight* highlight = fHighlights.ItemAt(i); i++) { + if (highlight->IsEmpty()) + continue; - if (fSelStart.y < -historySize) - _Deselect(); + highlight->ScrollRange(linesScrolled); + if (highlight == &fSelection) { + fInitialSelectionStart.y -= linesScrolled; + fInitialSelectionEnd.y -= linesScrolled; + } + + if (highlight->Start().y < -historySize) { + if (highlight == &fSelection) + _Deselect(); + else + _ClearHighlight(highlight); + } } } @@ -2372,12 +2256,13 @@ TermView::_SynchronizeWithTextBuffer(int32 visibleDirtyTop, info.dirtyBottom); // clear the selection, if affected - if (fSelStart != fSelEnd) { + if (!fSelection.IsEmpty()) { // TODO: We're clearing the selection more often than necessary -- // to avoid that, we'd also need to track the x coordinates of the // dirty range. - int32 selectionBottom = fSelEnd.x > 0 ? fSelEnd.y : fSelEnd.y - 1; - if (fSelStart.y <= info.dirtyBottom + int32 selectionBottom = fSelection.End().x > 0 + ? fSelection.End().y : fSelection.End().y - 1; + if (fSelection.Start().y <= info.dirtyBottom && info.dirtyTop <= selectionBottom) { _Deselect(); } @@ -2407,6 +2292,17 @@ TermView::_SynchronizeWithTextBuffer(int32 visibleDirtyTop, } +void +TermView::_VisibleTextBufferChanged() +{ + if (!fVisibleTextBufferChanged) + return; + + fVisibleTextBufferChanged = false; + fActiveState->VisibleTextBufferChanged(); +} + + /*! Write strings to PTY device. If encoding system isn't UTF8, change encoding to UTF8 before writing PTY. */ @@ -2480,98 +2376,12 @@ TermView::MouseDown(BPoint where) if (!IsFocus()) MakeFocus(); - int32 buttons; - int32 modifier; - Window()->CurrentMessage()->FindInt32("buttons", &buttons); - Window()->CurrentMessage()->FindInt32("modifiers", &modifier); + BMessage* currentMessage = Window()->CurrentMessage(); + int32 buttons = currentMessage->GetInt32("buttons", 0); + + fActiveState->MouseDown(where, buttons, fModifiers); fMouseButtons = buttons; - - if (fReportAnyMouseEvent || fReportButtonMouseEvent - || fReportNormalMouseEvent || fReportX10MouseEvent) { - TermPos clickPos = _ConvertToTerminal(where); - _SendMouseEvent(buttons, modifier, clickPos.x, clickPos.y, false); - return; - } - - // paste button - if ((buttons & (B_SECONDARY_MOUSE_BUTTON | B_TERTIARY_MOUSE_BUTTON)) != 0) { - Paste(fMouseClipboard); - fLastClickPoint = where; - return; - } - - // Select Region - if (buttons == B_PRIMARY_MOUSE_BUTTON) { - int32 clicks; - Window()->CurrentMessage()->FindInt32("clicks", &clicks); - - if (_HasSelection()) { - TermPos inPos = _ConvertToTerminal(where); - if (_CheckSelectedRegion(inPos)) { - if (modifier & B_CONTROL_KEY) { - BPoint p; - uint32 bt; - do { - GetMouse(&p, &bt); - - if (bt == 0) { - _Deselect(); - return; - } - - snooze(40000); - - } while (abs((int)(where.x - p.x)) < 4 - && abs((int)(where.y - p.y)) < 4); - - InitiateDrag(); - return; - } - } - } - - // If mouse has moved too much, disable double/triple click. - if (_MouseDistanceSinceLastClick(where) > 8) - clicks = 1; - - SetMouseEventMask(B_POINTER_EVENTS | B_KEYBOARD_EVENTS, - B_NO_POINTER_HISTORY | B_LOCK_WINDOW_FOCUS); - - TermPos clickPos = _ConvertToTerminal(where); - - if (modifier & B_SHIFT_KEY) { - fInitialSelectionStart = clickPos; - fInitialSelectionEnd = clickPos; - _ExtendSelection(fInitialSelectionStart, true, false); - } else { - _Deselect(); - fInitialSelectionStart = clickPos; - fInitialSelectionEnd = clickPos; - } - - // If clicks larger than 3, reset mouse click counter. - clicks = (clicks - 1) % 3 + 1; - - switch (clicks) { - case 1: - fCheckMouseTracking = true; - fSelectGranularity = SELECT_CHARS; - break; - - case 2: - _SelectWord(where, (modifier & B_SHIFT_KEY) != 0, false); - fMouseTracking = true; - fSelectGranularity = SELECT_WORDS; - break; - - case 3: - _SelectLine(where, (modifier & B_SHIFT_KEY) != 0, false); - fMouseTracking = true; - fSelectGranularity = SELECT_LINES; - break; - } - } fLastClickPoint = where; } @@ -2579,111 +2389,17 @@ TermView::MouseDown(BPoint where) void TermView::MouseMoved(BPoint where, uint32 transit, const BMessage *message) { - if (fReportAnyMouseEvent || fReportButtonMouseEvent) { - int32 modifier; - Window()->CurrentMessage()->FindInt32("modifiers", &modifier); - - TermPos clickPos = _ConvertToTerminal(where); - - if (fReportButtonMouseEvent) { - if (fPrevPos.x != clickPos.x || fPrevPos.y != clickPos.y) { - _SendMouseEvent(fMouseButtons, modifier, clickPos.x, clickPos.y, - true); - } - fPrevPos = clickPos; - return; - } - _SendMouseEvent(fMouseButtons, modifier, clickPos.x, clickPos.y, true); - return; - } - - if (fCheckMouseTracking) { - if (_MouseDistanceSinceLastClick(where) > 9) - fMouseTracking = true; - } - if (!fMouseTracking) - return; - - bool doAutoScroll = false; - - if (where.y < 0) { - doAutoScroll = true; - fAutoScrollSpeed = where.y; - where.x = 0; - where.y = 0; - } - - BRect bounds(Bounds()); - if (where.y > bounds.bottom) { - doAutoScroll = true; - fAutoScrollSpeed = where.y - bounds.bottom; - where.x = bounds.right; - where.y = bounds.bottom; - } - - if (doAutoScroll) { - if (fAutoScrollRunner == NULL) { - BMessage message(kAutoScroll); - fAutoScrollRunner = new (std::nothrow) BMessageRunner( - BMessenger(this), &message, 10000); - } - } else { - delete fAutoScrollRunner; - fAutoScrollRunner = NULL; - } - - switch (fSelectGranularity) { - case SELECT_CHARS: - { - // If we just start selecting, we first select the initially - // hit char, so that we get a proper initial selection -- the char - // in question, which will thus always be selected, regardless of - // whether selecting forward or backward. - if (fInitialSelectionStart == fInitialSelectionEnd) { - _Select(fInitialSelectionStart, fInitialSelectionEnd, true, - true); - } - - _ExtendSelection(_ConvertToTerminal(where), true, true); - break; - } - case SELECT_WORDS: - _SelectWord(where, true, true); - break; - case SELECT_LINES: - _SelectLine(where, true, true); - break; - } + fActiveState->MouseMoved(where, transit, message, fModifiers); } void TermView::MouseUp(BPoint where) { - fCheckMouseTracking = false; - fMouseTracking = false; + int32 buttons = Window()->CurrentMessage()->GetInt32("buttons", 0); - if (fAutoScrollRunner != NULL) { - delete fAutoScrollRunner; - fAutoScrollRunner = NULL; - } + fActiveState->MouseUp(where, buttons); - // When releasing the first mouse button, we copy the selected text to the - // clipboard. - int32 buttons; - Window()->CurrentMessage()->FindInt32("buttons", &buttons); - - if (fReportAnyMouseEvent || fReportButtonMouseEvent - || fReportNormalMouseEvent) { - TermPos clickPos = _ConvertToTerminal(where); - _SendMouseEvent(0, 0, clickPos.x, clickPos.y, false); - } else { - if ((buttons & B_PRIMARY_MOUSE_BUTTON) == 0 - && (fMouseButtons & B_PRIMARY_MOUSE_BUTTON) != 0) { - Copy(fMouseClipboard); - } - - } fMouseButtons = buttons; } @@ -2693,7 +2409,7 @@ void TermView::_Select(TermPos start, TermPos end, bool inclusive, bool setInitialSelection) { - BAutolock _(fTextBuffer); + TextBufferSyncLocker _(this); _SynchronizeWithTextBuffer(0, -1); @@ -2735,18 +2451,17 @@ TermView::_Select(TermPos start, TermPos end, bool inclusive, end.x = fColumns; } - if (fSelStart != fSelEnd) - _InvalidateTextRange(fSelStart, fSelEnd); + if (!fSelection.IsEmpty()) + _InvalidateTextRange(fSelection.Start(), fSelection.End()); - fSelStart = start; - fSelEnd = end; + fSelection.SetRange(start, end); if (setInitialSelection) { - fInitialSelectionStart = fSelStart; - fInitialSelectionEnd = fSelEnd; + fInitialSelectionStart = fSelection.Start(); + fInitialSelectionEnd = fSelection.End(); } - _InvalidateTextRange(fSelStart, fSelEnd); + _InvalidateTextRange(fSelection.Start(), fSelection.End()); } @@ -2758,8 +2473,8 @@ TermView::_ExtendSelection(TermPos pos, bool inclusive, if (!useInitialSelection && !_HasSelection()) return; - TermPos start = fSelStart; - TermPos end = fSelEnd; + TermPos start = fSelection.Start(); + TermPos end = fSelection.End(); if (useInitialSelection) { start = fInitialSelectionStart; @@ -2785,22 +2500,17 @@ void TermView::_Deselect() { //debug_printf("TermView::_Deselect(): has selection: %d\n", _HasSelection()); - if (!_HasSelection()) - return; - - _InvalidateTextRange(fSelStart, fSelEnd); - - fSelStart.SetTo(0, 0); - fSelEnd.SetTo(0, 0); - fInitialSelectionStart.SetTo(0, 0); - fInitialSelectionEnd.SetTo(0, 0); + if (_ClearHighlight(&fSelection)) { + fInitialSelectionStart.SetTo(0, 0); + fInitialSelectionEnd.SetTo(0, 0); + } } bool TermView::_HasSelection() const { - return fSelStart != fSelEnd; + return !fSelection.IsEmpty(); } @@ -2815,11 +2525,15 @@ TermView::_SelectWord(BPoint where, bool extend, bool useInitialSelection) return; if (extend) { - if (start < (useInitialSelection ? fInitialSelectionStart : fSelStart)) + if (start + < (useInitialSelection + ? fInitialSelectionStart : fSelection.Start())) { _ExtendSelection(start, false, useInitialSelection); - else if (end > (useInitialSelection ? fInitialSelectionEnd : fSelEnd)) + } else if (end + > (useInitialSelection + ? fInitialSelectionEnd : fSelection.End())) { _ExtendSelection(end, false, useInitialSelection); - else if (useInitialSelection) + } else if (useInitialSelection) _Select(start, end, false, false); } else _Select(start, end, false, !useInitialSelection); @@ -2833,11 +2547,15 @@ TermView::_SelectLine(BPoint where, bool extend, bool useInitialSelection) TermPos end = TermPos(0, start.y + 1); if (extend) { - if (start < (useInitialSelection ? fInitialSelectionStart : fSelStart)) + if (start + < (useInitialSelection + ? fInitialSelectionStart : fSelection.Start())) { _ExtendSelection(start, false, useInitialSelection); - else if (end > (useInitialSelection ? fInitialSelectionEnd : fSelEnd)) + } else if (end + > (useInitialSelection + ? fInitialSelectionEnd : fSelection.End())) { _ExtendSelection(end, false, useInitialSelection); - else if (useInitialSelection) + } else if (useInitialSelection) _Select(start, end, false, false); } else _Select(start, end, false, !useInitialSelection); @@ -2845,51 +2563,85 @@ TermView::_SelectLine(BPoint where, bool extend, bool useInitialSelection) void -TermView::_AutoScrollUpdate() +TermView::_AddHighlight(Highlight* highlight) { - if (fMouseTracking && fAutoScrollRunner != NULL && fScrollBar != NULL) { - float value = fScrollBar->Value(); - _ScrollTo(value + fAutoScrollSpeed, true); - if (fAutoScrollSpeed < 0) { - _ExtendSelection(_ConvertToTerminal(BPoint(0, 0)), true, true); - } else { - _ExtendSelection(_ConvertToTerminal(Bounds().RightBottom()), true, - true); - } + fHighlights.AddItem(highlight); + + if (!highlight->IsEmpty()) + _InvalidateTextRange(highlight->Start(), highlight->End()); +} + + +void +TermView::_RemoveHighlight(Highlight* highlight) +{ + fHighlights.RemoveItem(highlight); + + if (!highlight->IsEmpty()) + _InvalidateTextRange(highlight->Start(), highlight->End()); +} + + +bool +TermView::_ClearHighlight(Highlight* highlight) +{ + if (highlight->IsEmpty()) + return false; + + _InvalidateTextRange(highlight->Start(), highlight->End()); + + highlight->SetRange(TermPos(0, 0), TermPos(0, 0)); + return true; +} + + +TermView::Highlight* +TermView::_CheckHighlightRegion(const TermPos &pos) const +{ + for (int32 i = 0; Highlight* highlight = fHighlights.ItemAt(i); i++) { + if (highlight->RangeContains(pos)) + return highlight; } + + return NULL; } -bool -TermView::_CheckSelectedRegion(const TermPos &pos) const -{ - return pos >= fSelStart && pos < fSelEnd; -} - - -bool -TermView::_CheckSelectedRegion(int32 row, int32 firstColumn, +TermView::Highlight* +TermView::_CheckHighlightRegion(int32 row, int32 firstColumn, int32& lastColumn) const { - if (fSelStart == fSelEnd) - return false; + Highlight* nextHighlight = NULL; - if (row == fSelStart.y && firstColumn < fSelStart.x - && lastColumn >= fSelStart.x) { - // region starts before the selection, but intersects with it - lastColumn = fSelStart.x - 1; - return false; + for (int32 i = 0; Highlight* highlight = fHighlights.ItemAt(i); i++) { + if (highlight->IsEmpty()) + continue; + + if (row == highlight->Start().y && firstColumn < highlight->Start().x + && lastColumn >= highlight->Start().x) { + // region starts before the highlight, but intersects with it + if (nextHighlight == NULL + || highlight->Start().x < nextHighlight->Start().x) { + nextHighlight = highlight; + } + continue; + } + + if (row == highlight->End().y && firstColumn < highlight->End().x + && lastColumn >= highlight->End().x) { + // region starts in the highlight, but exceeds the end + lastColumn = highlight->End().x - 1; + return highlight; + } + + TermPos pos(firstColumn, row); + if (highlight->RangeContains(pos)) + return highlight; } - if (row == fSelEnd.y && firstColumn < fSelEnd.x - && lastColumn >= fSelEnd.x) { - // region starts in the selection, but exceeds the end - lastColumn = fSelEnd.x - 1; - return true; - } - - TermPos pos(firstColumn, row); - return pos >= fSelStart && pos < fSelEnd; + if (nextHighlight != NULL) + lastColumn = nextHighlight->Start().x - 1; + return NULL; } @@ -2915,15 +2667,15 @@ bool TermView::Find(const BString &str, bool forwardSearch, bool matchCase, bool matchWord) { - BAutolock _(fTextBuffer); + TextBufferSyncLocker _(this); _SynchronizeWithTextBuffer(0, -1); TermPos start; if (_HasSelection()) { if (forwardSearch) - start = fSelEnd; + start = fSelection.End(); else - start = fSelStart; + start = fSelection.Start(); } else { // search from the very beginning/end if (forwardSearch) @@ -2939,7 +2691,7 @@ TermView::Find(const BString &str, bool forwardSearch, bool matchCase, } _Select(matchStart, matchEnd, false, true); - _ScrollToRange(fSelStart, fSelEnd); + _ScrollToRange(fSelection.Start(), fSelection.End()); return true; } @@ -2951,7 +2703,7 @@ TermView::GetSelection(BString &str) { str.SetTo(""); BAutolock _(fTextBuffer); - fTextBuffer->GetStringFromRegion(str, fSelStart, fSelEnd); + fTextBuffer->GetStringFromRegion(str, fSelection.Start(), fSelection.End()); } @@ -2974,17 +2726,18 @@ TermView::InitiateDrag() BAutolock _(fTextBuffer); BString copyStr(""); - fTextBuffer->GetStringFromRegion(copyStr, fSelStart, fSelEnd); + fTextBuffer->GetStringFromRegion(copyStr, fSelection.Start(), + fSelection.End()); BMessage message(B_MIME_DATA); message.AddData("text/plain", B_MIME_TYPE, copyStr.String(), copyStr.Length()); - BPoint start = _ConvertFromTerminal(fSelStart); - BPoint end = _ConvertFromTerminal(fSelEnd); + BPoint start = _ConvertFromTerminal(fSelection.Start()); + BPoint end = _ConvertFromTerminal(fSelection.End()); BRect rect; - if (fSelStart.y == fSelEnd.y) + if (fSelection.Start().y == fSelection.End().y) rect.Set(start.x, start.y, end.x + fFontWidth, end.y + fFontHeight); else rect.Set(0, start.y, fColumns * fFontWidth, end.y + fFontHeight); @@ -3222,6 +2975,18 @@ TermView::_CancelInputMethod() } +void +TermView::_NextState(State* state) +{ + if (state != fActiveState) { + if (fActiveState != NULL) + fActiveState->Exited(); + fActiveState = state; + fActiveState->Entered(); + } +} + + // #pragma mark - Listener @@ -3254,6 +3019,9 @@ TermView::Listener::NextTermView(TermView* view) } +// #pragma mark - + + #ifdef USE_DEBUG_SNAPSHOTS void diff --git a/src/apps/terminal/TermView.h b/src/apps/terminal/TermView.h index 9e0721511a..a1ab24ed22 100644 --- a/src/apps/terminal/TermView.h +++ b/src/apps/terminal/TermView.h @@ -16,10 +16,12 @@ #include #include +#include #include #include #include "TermPos.h" +#include "TermViewHighlight.h" class ActiveProcessInfo; @@ -30,6 +32,7 @@ class BScrollView; class BString; class BStringView; class BasicTerminalBuffer; +class DefaultCharClassifier; class InlineInput; class ResizeWindow; class ShellInfo; @@ -38,10 +41,14 @@ class TermBuffer; class TerminalBuffer; class Shell; -class TermView : public BView { + +class TermView : public BView, private TermViewHighlighter { public: class Listener; + typedef TermViewHighlighter Highlighter; + typedef TermViewHighlight Highlight; + public: TermView(BRect frame, const ShellParameters& shellParameters, @@ -141,13 +148,35 @@ protected: const char* property); private: - class CharClassifier; + class TextBufferSyncLocker; + friend class TextBufferSyncLocker; + + class State; + class StandardBaseState; + class DefaultState; + class SelectState; + class HyperLinkState; + class HyperLinkMenuState; + + friend class State; + friend class StandardBaseState; + friend class DefaultState; + friend class SelectState; + friend class HyperLinkState; + friend class HyperLinkMenuState; + + typedef BObjectList HighlightList; + +private: + // TermViewHighlighter + virtual rgb_color ForegroundColor(); + virtual rgb_color BackgroundColor(); private: // point and text offset conversion inline int32 _LineAt(float y); inline float _LineOffset(int32 index); - inline TermPos _ConvertToTerminal(const BPoint& point); + TermPos _ConvertToTerminal(const BPoint& point); inline BPoint _ConvertFromTerminal(const TermPos& pos); inline void _InvalidateTextRect(int32 x1, int32 y1, @@ -164,8 +193,9 @@ private: void _SwitchCursorBlinking(bool blinkingOn); void _DrawLinePart(int32 x1, int32 y1, uint32 attr, - char* buffer, int32 width, bool mouse, - bool cursor, BView* inView); + char* buffer, int32 width, + Highlight* highlight, bool cursor, + BView* inView); void _DrawCursor(); void _InvalidateTextRange(TermPos start, TermPos end); @@ -183,6 +213,7 @@ private: void _SynchronizeWithTextBuffer( int32 visibleDirtyTop, int32 visibleDirtyBottom); + void _VisibleTextBufferChanged(); void _WritePTY(const char* text, int32 numBytes); @@ -199,10 +230,12 @@ private: void _SelectLine(BPoint where, bool extend, bool useInitialSelection); - void _AutoScrollUpdate(); + void _AddHighlight(Highlight* highlight); + void _RemoveHighlight(Highlight* highlight); + bool _ClearHighlight(Highlight* highlight); - bool _CheckSelectedRegion(const TermPos& pos) const; - bool _CheckSelectedRegion(int32 row, + Highlight* _CheckHighlightRegion(const TermPos& pos) const; + Highlight* _CheckHighlightRegion(int32 row, int32 firstColumn, int32& lastColumn) const; void _UpdateSIGWINCH(); @@ -218,6 +251,8 @@ private: void _HandleInputMethodLocationRequest(); void _CancelInputMethod(); + void _NextState(State* state); + private: Listener* fListener; Shell* fShell; @@ -227,7 +262,7 @@ private: BMessageRunner* fAutoScrollRunner; BMessageRunner* fResizeRunner; BStringView* fResizeView; - CharClassifier* fCharClassifier; + DefaultCharClassifier* fCharClassifier; // Font and Width BFont fHalfFont; @@ -252,8 +287,6 @@ private: // Cursor position. TermPos fCursor; - int32 fMouseButtons; - // Terminal rows and columns. int fColumns; int fRows; @@ -264,6 +297,7 @@ private: // Object pointer. TerminalBuffer* fTextBuffer; BasicTerminalBuffer* fVisibleTextBuffer; + bool fVisibleTextBufferChanged; BScrollBar* fScrollBar; InlineInput* fInline; @@ -289,22 +323,29 @@ private: bool fConsiderClockedSync; // selection - TermPos fSelStart; - TermPos fSelEnd; + Highlight fSelection; TermPos fInitialSelectionStart; TermPos fInitialSelectionEnd; - bool fMouseTracking; - bool fCheckMouseTracking; - int fSelectGranularity; BPoint fLastClickPoint; + HighlightList fHighlights; + // mouse + int32 fMouseButtons; + int32 fModifiers; TermPos fPrevPos; bool fReportX10MouseEvent; bool fReportNormalMouseEvent; bool fReportButtonMouseEvent; bool fReportAnyMouseEvent; BClipboard* fMouseClipboard; + + // states + DefaultState* fDefaultState; + SelectState* fSelectState; + HyperLinkState* fHyperLinkState; + HyperLinkMenuState* fHyperLinkMenuState; + State* fActiveState; }; diff --git a/src/apps/terminal/TermViewHighlight.cpp b/src/apps/terminal/TermViewHighlight.cpp new file mode 100644 index 0000000000..b14f3c9e6f --- /dev/null +++ b/src/apps/terminal/TermViewHighlight.cpp @@ -0,0 +1,19 @@ +/* + * Copyright 2013, Ingo Weinhold, ingo_weinhold@gmx.de. + * Distributed under the terms of the MIT License. + */ + + +#include "TermViewHighlight.h" + + +TermViewHighlighter::~TermViewHighlighter() +{ +} + + +uint32 +TermViewHighlighter::AdjustTextAttributes(uint32 attributes) +{ + return attributes; +} diff --git a/src/apps/terminal/TermViewHighlight.h b/src/apps/terminal/TermViewHighlight.h new file mode 100644 index 0000000000..1e9e5736bd --- /dev/null +++ b/src/apps/terminal/TermViewHighlight.h @@ -0,0 +1,83 @@ +/* + * Copyright 2013, Ingo Weinhold, ingo_weinhold@gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef TERMVIEW_HIGHLIGHT_H +#define TERMVIEW_HIGHLIGHT_H + + +#include + +#include "TermPos.h" + + +class TermViewHighlighter { +public: + virtual ~TermViewHighlighter(); + + virtual rgb_color ForegroundColor() = 0; + virtual rgb_color BackgroundColor() = 0; + virtual uint32 AdjustTextAttributes(uint32 attributes); +}; + + +class TermViewHighlight { +public: + TermViewHighlight() + : + fHighlighter(NULL), + fStart(-1, -1), + fEnd(-1, -1) + { + } + + TermViewHighlighter* Highlighter() const + { + return fHighlighter; + } + + void SetHighlighter(TermViewHighlighter* highligher) + { + fHighlighter = highligher; + } + + const TermPos& Start() const + { + return fStart; + } + + const TermPos& End() const + { + return fEnd; + } + + bool IsEmpty() const + { + return fStart == fEnd; + } + + bool RangeContains(const TermPos& pos) const + { + return pos >= fStart && pos < fEnd; + } + + void SetRange(const TermPos& start, const TermPos& end) + { + fStart = start; + fEnd = end; + } + + void ScrollRange(int32 byLines) + { + fStart.y -= byLines; + fEnd.y -= byLines; + } + +private: + TermViewHighlighter* fHighlighter; + TermPos fStart; + TermPos fEnd; +}; + + +#endif // TERMVIEW_HIGHLIGHT_H diff --git a/src/apps/terminal/TermViewStates.cpp b/src/apps/terminal/TermViewStates.cpp new file mode 100644 index 0000000000..9591983adf --- /dev/null +++ b/src/apps/terminal/TermViewStates.cpp @@ -0,0 +1,1002 @@ +/* + * Copyright 2001-2013, Haiku, Inc. + * Copyright 2003-2004 Kian Duffy, myob@users.sourceforge.net + * Parts Copyright 1998-1999 Kazuho Okui and Takashi Murai. + * All rights reserved. Distributed under the terms of the MIT license. + * + * Authors: + * Stefano Ceccherini, stefano.ceccherini@gmail.com + * Kian Duffy, myob@users.sourceforge.net + * Y.Hayakawa, hida@sawada.riec.tohoku.ac.jp + * Ingo Weinhold, ingo_weinhold@gmx.de + * Clemens Zeidler, haiku@Clemens-Zeidler.de + * Siarzhuk Zharski, zharik@gmx.li + */ + + +#include "TermViewStates.h" + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "Shell.h" +#include "TermConst.h" +#include "TerminalBuffer.h" +#include "VTkeymap.h" +#include "VTKeyTbl.h" + + +#undef B_TRANSLATION_CONTEXT +#define B_TRANSLATION_CONTEXT "Terminal TermView" + + +// selection granularity +enum { + SELECT_CHARS, + SELECT_WORDS, + SELECT_LINES +}; + +static const uint32 kAutoScroll = 'AScr'; + +static const uint32 kMessageOpenLink = 'OLnk'; +static const uint32 kMessageCopyLink = 'CLnk'; +static const uint32 kMessageMenuClosed = 'MClo'; + + +static const char* const kKnownURLProtocols = "http:https:ftp:mailto"; + + +// #pragma mark - State + + +TermView::State::State(TermView* view) + : + fView(view) +{ +} + + +TermView::State::~State() +{ +} + + +void +TermView::State::Entered() +{ +} + + +void +TermView::State::Exited() +{ +} + + +bool +TermView::State::MessageReceived(BMessage* message) +{ + return false; +} + + +void +TermView::State::ModifiersChanged(int32 oldModifiers, int32 modifiers) +{ +} + + +void +TermView::State::KeyDown(const char* bytes, int32 numBytes) +{ +} + + +void +TermView::State::MouseDown(BPoint where, int32 buttons, int32 modifiers) +{ +} + + +void +TermView::State::MouseMoved(BPoint where, uint32 transit, + const BMessage* message, int32 modifiers) +{ +} + + +void +TermView::State::MouseUp(BPoint where, int32 buttons) +{ +} + + +void +TermView::State::WindowActivated(bool active) +{ +} + + +void +TermView::State::VisibleTextBufferChanged() +{ +} + + +// #pragma mark - StandardBaseState + + +TermView::StandardBaseState::StandardBaseState(TermView* view) + : + State(view) +{ +} + + +bool +TermView::StandardBaseState::_StandardMouseMoved(BPoint where, int32 modifiers) +{ + if (!fView->fReportAnyMouseEvent && !fView->fReportButtonMouseEvent) + return false; + + TermPos clickPos = fView->_ConvertToTerminal(where); + + if (fView->fReportButtonMouseEvent) { + if (fView->fPrevPos.x != clickPos.x + || fView->fPrevPos.y != clickPos.y) { + fView->_SendMouseEvent(fView->fMouseButtons, modifiers, + clickPos.x, clickPos.y, true); + } + fView->fPrevPos = clickPos; + } else { + fView->_SendMouseEvent(fView->fMouseButtons, modifiers, clickPos.x, + clickPos.y, true); + } + + return true; +} + + +// #pragma mark - DefaultState + + +TermView::DefaultState::DefaultState(TermView* view) + : + StandardBaseState(view) +{ +} + + +void +TermView::DefaultState::ModifiersChanged(int32 oldModifiers, int32 modifiers) +{ + _CheckEnterHyperLinkState(modifiers); +} + + +void +TermView::DefaultState::KeyDown(const char* bytes, int32 numBytes) +{ + int32 key, mod, rawChar; + BMessage *currentMessage = fView->Looper()->CurrentMessage(); + if (currentMessage == NULL) + return; + + currentMessage->FindInt32("modifiers", &mod); + currentMessage->FindInt32("key", &key); + currentMessage->FindInt32("raw_char", &rawChar); + + fView->_ActivateCursor(true); + + // handle multi-byte chars + if (numBytes > 1) { + if (fView->fEncoding != M_UTF8) { + char destBuffer[16]; + int32 destLen = sizeof(destBuffer); + int32 state = 0; + convert_from_utf8(fView->fEncoding, bytes, &numBytes, destBuffer, + &destLen, &state, '?'); + fView->_ScrollTo(0, true); + fView->fShell->Write(destBuffer, destLen); + return; + } + + fView->_ScrollTo(0, true); + fView->fShell->Write(bytes, numBytes); + return; + } + + // Terminal filters RET, ENTER, F1...F12, and ARROW key code. + const char *toWrite = NULL; + + switch (*bytes) { + case B_RETURN: + if (rawChar == B_RETURN) + toWrite = "\r"; + break; + + case B_DELETE: + toWrite = DELETE_KEY_CODE; + break; + + case B_BACKSPACE: + // Translate only the actual backspace key to the backspace + // code. CTRL-H shall just be echoed. + if (!((mod & B_CONTROL_KEY) && rawChar == 'h')) + toWrite = BACKSPACE_KEY_CODE; + break; + + case B_LEFT_ARROW: + if (rawChar == B_LEFT_ARROW) { + if ((mod & B_SHIFT_KEY) != 0) { + if (fView->fListener != NULL) + fView->fListener->PreviousTermView(fView); + return; + } + if ((mod & B_CONTROL_KEY) || (mod & B_COMMAND_KEY)) + toWrite = CTRL_LEFT_ARROW_KEY_CODE; + else + toWrite = LEFT_ARROW_KEY_CODE; + } + break; + + case B_RIGHT_ARROW: + if (rawChar == B_RIGHT_ARROW) { + if ((mod & B_SHIFT_KEY) != 0) { + if (fView->fListener != NULL) + fView->fListener->NextTermView(fView); + return; + } + if ((mod & B_CONTROL_KEY) || (mod & B_COMMAND_KEY)) + toWrite = CTRL_RIGHT_ARROW_KEY_CODE; + else + toWrite = RIGHT_ARROW_KEY_CODE; + } + break; + + case B_UP_ARROW: + if (mod & B_SHIFT_KEY) { + fView->_ScrollTo(fView->fScrollOffset - fView->fFontHeight, + true); + return; + } + if (rawChar == B_UP_ARROW) { + if (mod & B_CONTROL_KEY) + toWrite = CTRL_UP_ARROW_KEY_CODE; + else + toWrite = UP_ARROW_KEY_CODE; + } + break; + + case B_DOWN_ARROW: + if (mod & B_SHIFT_KEY) { + fView->_ScrollTo(fView->fScrollOffset + fView->fFontHeight, + true); + return; + } + + if (rawChar == B_DOWN_ARROW) { + if (mod & B_CONTROL_KEY) + toWrite = CTRL_DOWN_ARROW_KEY_CODE; + else + toWrite = DOWN_ARROW_KEY_CODE; + } + break; + + case B_INSERT: + if (rawChar == B_INSERT) + toWrite = INSERT_KEY_CODE; + break; + + case B_HOME: + if (rawChar == B_HOME) + toWrite = HOME_KEY_CODE; + break; + + case B_END: + if (rawChar == B_END) + toWrite = END_KEY_CODE; + break; + + case B_PAGE_UP: + if (mod & B_SHIFT_KEY) { + fView->_ScrollTo( + fView->fScrollOffset - fView->fFontHeight * fView->fRows, + true); + return; + } + if (rawChar == B_PAGE_UP) + toWrite = PAGE_UP_KEY_CODE; + break; + + case B_PAGE_DOWN: + if (mod & B_SHIFT_KEY) { + fView->_ScrollTo( + fView->fScrollOffset + fView->fFontHeight * fView->fRows, + true); + return; + } + if (rawChar == B_PAGE_DOWN) + toWrite = PAGE_DOWN_KEY_CODE; + break; + + case B_FUNCTION_KEY: + for (int32 i = 0; i < 12; i++) { + if (key == function_keycode_table[i]) { + toWrite = function_key_char_table[i]; + break; + } + } + break; + } + + // If the above code proposed an alternative string to write, we get it's + // length. Otherwise we write exactly the bytes passed to this method. + size_t toWriteLen; + if (toWrite != NULL) { + toWriteLen = strlen(toWrite); + } else { + toWrite = bytes; + toWriteLen = numBytes; + } + + fView->_ScrollTo(0, true); + fView->fShell->Write(toWrite, toWriteLen); +} + + +void +TermView::DefaultState::MouseDown(BPoint where, int32 buttons, int32 modifiers) +{ + if (fView->fReportAnyMouseEvent || fView->fReportButtonMouseEvent + || fView->fReportNormalMouseEvent || fView->fReportX10MouseEvent) { + TermPos clickPos = fView->_ConvertToTerminal(where); + fView->_SendMouseEvent(buttons, modifiers, clickPos.x, clickPos.y, + false); + return; + } + + // paste button + if ((buttons & (B_SECONDARY_MOUSE_BUTTON | B_TERTIARY_MOUSE_BUTTON)) != 0) { + fView->Paste(fView->fMouseClipboard); + return; + } + + // Select Region + if (buttons == B_PRIMARY_MOUSE_BUTTON) { + fView->fSelectState->Prepare(where, modifiers); + fView->_NextState(fView->fSelectState); + } +} + + +void +TermView::DefaultState::MouseMoved(BPoint where, uint32 transit, + const BMessage* message, int32 modifiers) +{ + if (_CheckEnterHyperLinkState(modifiers)) + return; + + _StandardMouseMoved(where, modifiers); +} + + +void +TermView::DefaultState::WindowActivated(bool active) +{ + if (active) + _CheckEnterHyperLinkState(fView->fModifiers); +} + + +bool +TermView::DefaultState::_CheckEnterHyperLinkState(int32 modifiers) +{ + if ((modifiers & B_COMMAND_KEY) != 0 && fView->Window()->IsActive()) { + fView->_NextState(fView->fHyperLinkState); + return true; + } + + return false; +} + + +// #pragma mark - SelectState + + +TermView::SelectState::SelectState(TermView* view) + : + StandardBaseState(view), + fSelectGranularity(SELECT_CHARS), + fCheckMouseTracking(false), + fMouseTracking(false) +{ +} + + +void +TermView::SelectState::Prepare(BPoint where, int32 modifiers) +{ + int32 clicks; + fView->Window()->CurrentMessage()->FindInt32("clicks", &clicks); + + if (fView->_HasSelection()) { + TermPos inPos = fView->_ConvertToTerminal(where); + if (fView->fSelection.RangeContains(inPos)) { + if (modifiers & B_CONTROL_KEY) { + BPoint p; + uint32 bt; + do { + fView->GetMouse(&p, &bt); + + if (bt == 0) { + fView->_Deselect(); + return; + } + + snooze(40000); + + } while (abs((int)(where.x - p.x)) < 4 + && abs((int)(where.y - p.y)) < 4); + + fView->InitiateDrag(); + return; + } + } + } + + // If mouse has moved too much, disable double/triple click. + if (fView->_MouseDistanceSinceLastClick(where) > 8) + clicks = 1; + + fView->SetMouseEventMask(B_POINTER_EVENTS | B_KEYBOARD_EVENTS, + B_NO_POINTER_HISTORY | B_LOCK_WINDOW_FOCUS); + + TermPos clickPos = fView->_ConvertToTerminal(where); + + if (modifiers & B_SHIFT_KEY) { + fView->fInitialSelectionStart = clickPos; + fView->fInitialSelectionEnd = clickPos; + fView->_ExtendSelection(fView->fInitialSelectionStart, true, false); + } else { + fView->_Deselect(); + fView->fInitialSelectionStart = clickPos; + fView->fInitialSelectionEnd = clickPos; + } + + // If clicks larger than 3, reset mouse click counter. + clicks = (clicks - 1) % 3 + 1; + + switch (clicks) { + case 1: + fCheckMouseTracking = true; + fSelectGranularity = SELECT_CHARS; + break; + + case 2: + fView->_SelectWord(where, (modifiers & B_SHIFT_KEY) != 0, false); + fMouseTracking = true; + fSelectGranularity = SELECT_WORDS; + break; + + case 3: + fView->_SelectLine(where, (modifiers & B_SHIFT_KEY) != 0, false); + fMouseTracking = true; + fSelectGranularity = SELECT_LINES; + break; + } +} + + +bool +TermView::SelectState::MessageReceived(BMessage* message) +{ + if (message->what == kAutoScroll) { + _AutoScrollUpdate(); + return true; + } + + return false; +} + + +void +TermView::SelectState::MouseMoved(BPoint where, uint32 transit, + const BMessage* message, int32 modifiers) +{ + if (_StandardMouseMoved(where, modifiers)) + return; + + if (fCheckMouseTracking) { + if (fView->_MouseDistanceSinceLastClick(where) > 9) + fMouseTracking = true; + } + if (!fMouseTracking) + return; + + bool doAutoScroll = false; + + if (where.y < 0) { + doAutoScroll = true; + fView->fAutoScrollSpeed = where.y; + where.x = 0; + where.y = 0; + } + + BRect bounds(fView->Bounds()); + if (where.y > bounds.bottom) { + doAutoScroll = true; + fView->fAutoScrollSpeed = where.y - bounds.bottom; + where.x = bounds.right; + where.y = bounds.bottom; + } + + if (doAutoScroll) { + if (fView->fAutoScrollRunner == NULL) { + BMessage message(kAutoScroll); + fView->fAutoScrollRunner = new (std::nothrow) BMessageRunner( + BMessenger(fView), &message, 10000); + } + } else { + delete fView->fAutoScrollRunner; + fView->fAutoScrollRunner = NULL; + } + + switch (fSelectGranularity) { + case SELECT_CHARS: + { + // If we just start selecting, we first select the initially + // hit char, so that we get a proper initial selection -- the char + // in question, which will thus always be selected, regardless of + // whether selecting forward or backward. + if (fView->fInitialSelectionStart == fView->fInitialSelectionEnd) { + fView->_Select(fView->fInitialSelectionStart, + fView->fInitialSelectionEnd, true, true); + } + + fView->_ExtendSelection(fView->_ConvertToTerminal(where), true, + true); + break; + } + case SELECT_WORDS: + fView->_SelectWord(where, true, true); + break; + case SELECT_LINES: + fView->_SelectLine(where, true, true); + break; + } +} + + +void +TermView::SelectState::MouseUp(BPoint where, int32 buttons) +{ + fCheckMouseTracking = false; + fMouseTracking = false; + + if (fView->fAutoScrollRunner != NULL) { + delete fView->fAutoScrollRunner; + fView->fAutoScrollRunner = NULL; + } + + // When releasing the first mouse button, we copy the selected text to the + // clipboard. + + if (fView->fReportAnyMouseEvent || fView->fReportButtonMouseEvent + || fView->fReportNormalMouseEvent) { + TermPos clickPos = fView->_ConvertToTerminal(where); + fView->_SendMouseEvent(0, 0, clickPos.x, clickPos.y, false); + } else { + if ((buttons & B_PRIMARY_MOUSE_BUTTON) == 0 + && (fView->fMouseButtons & B_PRIMARY_MOUSE_BUTTON) != 0) { + fView->Copy(fView->fMouseClipboard); + } + + } + + fView->_NextState(fView->fDefaultState); +} + + +void +TermView::SelectState::_AutoScrollUpdate() +{ + if (fMouseTracking && fView->fAutoScrollRunner != NULL + && fView->fScrollBar != NULL) { + float value = fView->fScrollBar->Value(); + fView->_ScrollTo(value + fView->fAutoScrollSpeed, true); + if (fView->fAutoScrollSpeed < 0) { + fView->_ExtendSelection( + fView->_ConvertToTerminal(BPoint(0, 0)), true, true); + } else { + fView->_ExtendSelection( + fView->_ConvertToTerminal(fView->Bounds().RightBottom()), true, + true); + } + } +} + + +// #pragma mark - HyperLinkState + + +TermView::HyperLinkState::HyperLinkState(TermView* view) + : + State(view), + fURLCharClassifier(kURLAdditionalWordCharacters), + fPathComponentCharClassifier( + BString(kDefaultAdditionalWordCharacters).RemoveFirst("/")), + fHighlight(), + fHighlightActive(false) +{ + fHighlight.SetHighlighter(this); +} + + +void +TermView::HyperLinkState::Entered() +{ + _UpdateHighlight(); +} + + +void +TermView::HyperLinkState::Exited() +{ + _DeactivateHighlight(); +} + + +void +TermView::HyperLinkState::ModifiersChanged(int32 oldModifiers, int32 modifiers) +{ + if ((modifiers & B_COMMAND_KEY) == 0) + fView->_NextState(fView->fDefaultState); + else + _UpdateHighlight(); +} + + +void +TermView::HyperLinkState::MouseDown(BPoint where, int32 buttons, + int32 modifiers) +{ + TermPos start; + TermPos end; + HyperLink link; + bool pathPrefixOnly = (modifiers & B_SHIFT_KEY) != 0; + if (!_GetHyperLinkAt(where, pathPrefixOnly, link, start, end)) + return; + + if ((buttons & B_PRIMARY_MOUSE_BUTTON) != 0) { + link.Open(); + } else if ((buttons & B_SECONDARY_MOUSE_BUTTON) != 0) { + fView->fHyperLinkMenuState->Prepare(where, link); + fView->_NextState(fView->fHyperLinkMenuState); + } +} + + +void +TermView::HyperLinkState::MouseMoved(BPoint where, uint32 transit, + const BMessage* message, int32 modifiers) +{ + _UpdateHighlight(where, modifiers); +} + + +void +TermView::HyperLinkState::WindowActivated(bool active) +{ + if (!active) + fView->_NextState(fView->fDefaultState); +} + + +void +TermView::HyperLinkState::VisibleTextBufferChanged() +{ + _UpdateHighlight(); +} + + +rgb_color +TermView::HyperLinkState::ForegroundColor() +{ + return make_color(0, 0, 255); +} + + +rgb_color +TermView::HyperLinkState::BackgroundColor() +{ + return fView->fTextBackColor; +} + + +uint32 +TermView::HyperLinkState::AdjustTextAttributes(uint32 attributes) +{ + return attributes | UNDERLINE; +} + + +bool +TermView::HyperLinkState::_GetHyperLinkAt(BPoint where, bool pathPrefixOnly, + HyperLink& _link, TermPos& _start, TermPos& _end) +{ + TerminalBuffer* textBuffer = fView->fTextBuffer; + BAutolock textBufferLocker(textBuffer); + + TermPos pos = fView->_ConvertToTerminal(where); + + // try to get a URL first + BString text; + if (!textBuffer->FindWord(pos, &fURLCharClassifier, false, _start, _end)) + return false; + + text.Truncate(0); + textBuffer->GetStringFromRegion(text, _start, _end); + text.Trim(); + + // We're only happy, if it has a protocol part which we know. + int32 colonIndex = text.FindFirst(':'); + if (colonIndex >= 0) { + BString protocol(text, colonIndex); + if (strstr(kKnownURLProtocols, protocol) != NULL) { + _link = HyperLink(text, HyperLink::TYPE_URL); + return true; + } + } + + // no obvious URL -- try file name + if (!textBuffer->FindWord(pos, fView->fCharClassifier, false, _start, _end)) + return false; + + // In path-prefix-only mode we determine the end position anew by omitting + // the '/' in the allowed word chars. + if (pathPrefixOnly) { + TermPos componentStart; + TermPos componentEnd; + if (textBuffer->FindWord(pos, &fPathComponentCharClassifier, false, + componentStart, componentEnd)) { + _end = componentEnd; + } else { + // That means pos points to a '/'. We simply use the previous + // position. + _end = pos; + if (_start == _end) { + // Well, must be just "/". Advance to the next position. + if (!textBuffer->NextLinePos(_end, false)) + return false; + } + } + } + + text.Truncate(0); + textBuffer->GetStringFromRegion(text, _start, _end); + text.Trim(); + if (text.IsEmpty()) + return false; + + // check, whether the file exists + struct stat st; + if (lstat(text, &st) == 0) { + _link = HyperLink(text, HyperLink::TYPE_PATH); + return true; + } + + // As such this isn't an existing path. Try a few common alternative cases: + // * ":" + // * ":" + // * "::" + // * "::" + // * ":::" + + if (text.Length() <= 1) + return false; + + if (text[text.Length() - 1] == ':') { + text.Truncate(text.Length() - 1); + if (!textBuffer->PreviousLinePos(_end)) + return false; + + if (lstat(text, &st) == 0) { + _link = HyperLink(text, HyperLink::TYPE_PATH); + return true; + } + } + + BString path = text; + + for (int32 i = 0; i < 2; i++) { + int32 colonIndex = path.FindLast(':'); + if (colonIndex <= 0 || colonIndex == path.Length() - 1) + return false; + + char* numberEnd; + strtol(path.String() + colonIndex + 1, &numberEnd, 0); + if (*numberEnd != '\0') + return false; + + path.Truncate(colonIndex); + if (lstat(path, &st) == 0) { + _link = HyperLink(text, + i == 0 + ? HyperLink::TYPE_PATH_WITH_LINE + : HyperLink::TYPE_PATH_WITH_LINE_AND_COLUMN, + path); + return true; + } + } + + return false; +} + + +void +TermView::HyperLinkState::_UpdateHighlight() +{ + BPoint where; + uint32 buttons; + fView->GetMouse(&where, &buttons, false); + _UpdateHighlight(where, fView->fModifiers); +} + +void +TermView::HyperLinkState::_UpdateHighlight(BPoint where, int32 modifiers) +{ + TermPos start; + TermPos end; + HyperLink link; + bool pathPrefixOnly = (modifiers & B_SHIFT_KEY) != 0; + if (_GetHyperLinkAt(where, pathPrefixOnly, link, start, end)) + _ActivateHighlight(start, end); + else + _DeactivateHighlight(); +} + + +void +TermView::HyperLinkState::_ActivateHighlight(const TermPos& start, + const TermPos& end) +{ + if (fHighlightActive) { + if (fHighlight.Start() == start && fHighlight.End() == end) + return; + _DeactivateHighlight(); + } + + fHighlight.SetRange(start, end); + fView->_AddHighlight(&fHighlight); + BCursor cursor(B_CURSOR_ID_FOLLOW_LINK); + fView->SetViewCursor(&cursor); + fHighlightActive = true; +} + + +void +TermView::HyperLinkState::_DeactivateHighlight() +{ + if (fHighlightActive) { + fView->_RemoveHighlight(&fHighlight); + BCursor cursor(B_CURSOR_ID_SYSTEM_DEFAULT); + fView->SetViewCursor(&cursor); + fHighlightActive = false; + } +} + + +// #pragma mark - HyperLinkMenuState + + +class TermView::HyperLinkMenuState::PopUpMenu : public BPopUpMenu { +public: + PopUpMenu(const BMessenger& messageTarget) + : + BPopUpMenu("open hyperlink"), + fMessageTarget(messageTarget) + { + SetAsyncAutoDestruct(true); + } + + ~PopUpMenu() + { + fMessageTarget.SendMessage(kMessageMenuClosed); + } + +private: + BMessenger fMessageTarget; +}; + + +TermView::HyperLinkMenuState::HyperLinkMenuState(TermView* view) + : + State(view), + fLink() +{ +} + + +void +TermView::HyperLinkMenuState::Prepare(BPoint point, const HyperLink& link) +{ + fLink = link; + + // open context menu + PopUpMenu* menu = new PopUpMenu(fView); + BLayoutBuilder::Menu<> menuBuilder(menu); + switch (link.GetType()) { + case HyperLink::TYPE_URL: + menuBuilder + .AddItem(B_TRANSLATE("Open link"), kMessageOpenLink) + .AddItem(B_TRANSLATE("Copy link location"), kMessageCopyLink); + break; + + case HyperLink::TYPE_PATH: + case HyperLink::TYPE_PATH_WITH_LINE: + case HyperLink::TYPE_PATH_WITH_LINE_AND_COLUMN: + menuBuilder + .AddItem(B_TRANSLATE("Open path"), kMessageOpenLink) + .AddItem(B_TRANSLATE("Copy path"), kMessageCopyLink); + break; + } + menu->SetTargetForItems(fView); + menu->Go(fView->ConvertToScreen(point), true, true, true); +} + + +void +TermView::HyperLinkMenuState::Exited() +{ + fLink = HyperLink(); +} + + +bool +TermView::HyperLinkMenuState::MessageReceived(BMessage* message) +{ + switch (message->what) { + case kMessageOpenLink: + if (fLink.IsValid()) + fLink.Open(); + return true; + + case kMessageCopyLink: + if (fLink.IsValid()) { + if (!be_clipboard->Lock()) + return true; + + be_clipboard->Clear(); + + if (BMessage *data = be_clipboard->Data()) { + data->AddData("text/plain", B_MIME_TYPE, + fLink.Address().String(), + fLink.Address().Length()); + be_clipboard->Commit(); + } + + be_clipboard->Unlock(); + } + return true; + + case kMessageMenuClosed: + fView->_NextState(fView->fDefaultState); + return true; + } + + return false; +} + diff --git a/src/apps/terminal/TermViewStates.h b/src/apps/terminal/TermViewStates.h new file mode 100644 index 0000000000..af8e2955a8 --- /dev/null +++ b/src/apps/terminal/TermViewStates.h @@ -0,0 +1,168 @@ +/* + * Copyright 2001-2013, Haiku, Inc. + * Copyright (c) 2003-4 Kian Duffy + * Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai. + * + * Distributed under the terms of the MIT license. + * Authors: + * Stefano Ceccherini, stefano.ceccherini@gmail.com + * Kian Duffy, myob@users.sourceforge.net + * Ingo Weinhold, ingo_weinhold@gmx.de + * Siarzhuk Zharski, zharik@gmx.li + */ +#ifndef TERMVIEW_STATES_H +#define TERMVIEW_STATES_H + + +#include "HyperLink.h" +#include "TerminalCharClassifier.h" +#include "TermView.h" + + +class TermView::State { +public: + State(TermView* view); + virtual ~State(); + + virtual void Entered(); + virtual void Exited(); + + virtual bool MessageReceived(BMessage* message); + // returns true, if handled + + virtual void ModifiersChanged(int32 oldModifiers, + int32 modifiers); + virtual void KeyDown(const char* bytes, int32 numBytes); + + virtual void MouseDown(BPoint where, int32 buttons, + int32 modifiers); + virtual void MouseMoved(BPoint where, uint32 transit, + const BMessage* message, int32 modifiers); + virtual void MouseUp(BPoint where, int32 buttons); + + virtual void WindowActivated(bool active); + + virtual void VisibleTextBufferChanged(); + +protected: + TermView* fView; +}; + + +class TermView::StandardBaseState : public TermView::State { +public: + StandardBaseState(TermView* view); + +protected: + bool _StandardMouseMoved(BPoint where, + int32 modifiers); +}; + + +class TermView::DefaultState : public TermView::StandardBaseState { +public: + DefaultState(TermView* view); + + virtual void ModifiersChanged(int32 oldModifiers, + int32 modifiers); + + virtual void KeyDown(const char* bytes, int32 numBytes); + + virtual void MouseDown(BPoint where, int32 buttons, + int32 modifiers); + virtual void MouseMoved(BPoint where, uint32 transit, + const BMessage* message, int32 modifiers); + + virtual void WindowActivated(bool active); + +private: + bool _CheckEnterHyperLinkState(int32 modifiers); +}; + + +class TermView::SelectState : public TermView::StandardBaseState { +public: + SelectState(TermView* view); + + void Prepare(BPoint where, int32 modifiers); + + virtual bool MessageReceived(BMessage* message); + + virtual void MouseMoved(BPoint where, uint32 transit, + const BMessage* message, int32 modifiers); + virtual void MouseUp(BPoint where, int32 buttons); + +private: + void _AutoScrollUpdate(); + +private: + int32 fSelectGranularity; + bool fCheckMouseTracking; + bool fMouseTracking; +}; + + +class TermView::HyperLinkState : public TermView::State, + private TermViewHighlighter { +public: + HyperLinkState(TermView* view); + + virtual void Entered(); + virtual void Exited(); + + virtual void ModifiersChanged(int32 oldModifiers, + int32 modifiers); + + virtual void MouseDown(BPoint where, int32 buttons, + int32 modifiers); + virtual void MouseMoved(BPoint where, uint32 transit, + const BMessage* message, int32 modifiers); + + virtual void WindowActivated(bool active); + + virtual void VisibleTextBufferChanged(); + +private: + // TermViewHighlighter + virtual rgb_color ForegroundColor(); + virtual rgb_color BackgroundColor(); + virtual uint32 AdjustTextAttributes(uint32 attributes); + +private: + bool _GetHyperLinkAt(BPoint where, + bool pathPrefixOnly, HyperLink& _link, + TermPos& _start, TermPos& _end); + + void _UpdateHighlight(); + void _UpdateHighlight(BPoint where, int32 modifiers); + void _ActivateHighlight(const TermPos& start, + const TermPos& end); + void _DeactivateHighlight(); + +private: + DefaultCharClassifier fURLCharClassifier; + DefaultCharClassifier fPathComponentCharClassifier; + TermViewHighlight fHighlight; + bool fHighlightActive; +}; + + +class TermView::HyperLinkMenuState : public TermView::State { +public: + HyperLinkMenuState(TermView* view); + + void Prepare(BPoint point, const HyperLink& link); + + virtual void Exited(); + + virtual bool MessageReceived(BMessage* message); + +private: + class PopUpMenu; + +private: + HyperLink fLink; +}; + + +#endif // TERMVIEW_STATES_H diff --git a/src/apps/terminal/TermWindow.cpp b/src/apps/terminal/TermWindow.cpp index 5c734312c1..073a697279 100644 --- a/src/apps/terminal/TermWindow.cpp +++ b/src/apps/terminal/TermWindow.cpp @@ -9,6 +9,7 @@ * Authors: * Kian Duffy, myob@users.sourceforge.net * Daniel Furrer, assimil8or@users.sourceforge.net + * John Scipione, jscipione@gmail.com * Siarzhuk Zharski, zharik@gmx.li */ @@ -38,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -729,9 +731,32 @@ TermWindow::MessageReceived(BMessage *message) break; case MENU_FIND_STRING: - if (!fFindPanel) { + if (fFindPanel == NULL) { fFindPanel = new FindWindow(this, fFindString, fFindSelection, fMatchWord, fMatchCase, fForwardSearch); + + // position the window under the mouse pointer + BPoint where; + uint32 buttons; + ChildAt(0)->GetMouse(&where, &buttons); + fFindPanel->MoveTo(ConvertToScreen(where)); + + // move window if outside of screen frame + BRect screenFrame = (BScreen(this)).Frame(); + BRect frame = fFindPanel->Frame(); + float extra = 30.0f; + if (frame.bottom + extra * 2 > screenFrame.bottom) { + fFindPanel->MoveBy(0, + screenFrame.bottom - frame.bottom - extra * 2); + } else if (frame.top - extra < screenFrame.top) + fFindPanel->MoveBy(0, screenFrame.top - frame.top + extra); + + if (frame.right + extra > screenFrame.right) { + fFindPanel->MoveBy(screenFrame.right - frame.right + - extra, 0); + } + + fFindPanel->Show(); } else fFindPanel->Activate(); break; diff --git a/src/apps/terminal/TerminalCharClassifier.cpp b/src/apps/terminal/TerminalCharClassifier.cpp index acdd2f59fb..86a3c9c606 100644 --- a/src/apps/terminal/TerminalCharClassifier.cpp +++ b/src/apps/terminal/TerminalCharClassifier.cpp @@ -1,11 +1,52 @@ /* - * Copyright 2008, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2008-2013, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ #include "TerminalCharClassifier.h" +#include + +#include + + +// #pragma mark - TerminalCharClassifier + TerminalCharClassifier::~TerminalCharClassifier() { } + + +// #pragma mark - DefaultCharClassifier + + +DefaultCharClassifier::DefaultCharClassifier(const char* additionalWordChars) +{ + const char* p = additionalWordChars; + while (p != NULL && *p != '\0') { + int count = UTF8Char::ByteCount(*p); + if (count <= 0 || count > 4) + break; + fAdditionalWordChars.push_back(UTF8Char(p, count)); + p += count; + } +} + + +int +DefaultCharClassifier::Classify(const UTF8Char& character) +{ + if (character.IsSpace()) + return CHAR_TYPE_SPACE; + + if (character.IsAlNum()) + return CHAR_TYPE_WORD_CHAR; + + if (std::find(fAdditionalWordChars.begin(), fAdditionalWordChars.end(), + character) != fAdditionalWordChars.end()) { + return CHAR_TYPE_WORD_CHAR; + } + + return CHAR_TYPE_WORD_DELIMITER; +} diff --git a/src/apps/terminal/TerminalCharClassifier.h b/src/apps/terminal/TerminalCharClassifier.h index 236f31c3aa..de0d36411f 100644 --- a/src/apps/terminal/TerminalCharClassifier.h +++ b/src/apps/terminal/TerminalCharClassifier.h @@ -1,11 +1,16 @@ /* - * Copyright 2008, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2008-2013, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ #ifndef TERMINAL_CHAR_CLASSIFIER_H #define TERMINAL_CHAR_CLASSIFIER_H +#include + +#include "UTF8Char.h" + + enum { CHAR_TYPE_SPACE, CHAR_TYPE_WORD_CHAR, @@ -23,4 +28,16 @@ public: }; +class DefaultCharClassifier: public TerminalCharClassifier { +public: + DefaultCharClassifier( + const char* additionalWordChars); + + virtual int Classify(const UTF8Char& character); + +private: + std::vector fAdditionalWordChars; +}; + + #endif // TERMINAL_CHAR_CLASSIFIER_H diff --git a/src/apps/terminal/VTKeyTbl.c b/src/apps/terminal/VTKeyTbl.c index 51e877a611..ff5ada40f0 100644 --- a/src/apps/terminal/VTKeyTbl.c +++ b/src/apps/terminal/VTKeyTbl.c @@ -28,8 +28,12 @@ * */ + +#include "VTKeyTbl.h" + #include "VTkeymap.h" + int function_keycode_table[] = { F1_KEY, diff --git a/src/apps/terminal/VTKeyTbl.h b/src/apps/terminal/VTKeyTbl.h new file mode 100644 index 0000000000..8f4c284203 --- /dev/null +++ b/src/apps/terminal/VTKeyTbl.h @@ -0,0 +1,13 @@ +/* + * Copyright 2013 Ingo Weinhold, ingo_weinhold@gmx.de. All rights reserved. + * Distributed under the terms of the MIT license. + */ +#ifndef VT_KEY_TABLE_H +#define VT_KEY_TABLE_H + + +extern int function_keycode_table[]; +extern char* function_key_char_table[]; + + +#endif // VT_KEY_TABLE_H diff --git a/src/apps/text_search/Grepper.cpp b/src/apps/text_search/Grepper.cpp index a20103e7d0..00b6657a86 100644 --- a/src/apps/text_search/Grepper.cpp +++ b/src/apps/text_search/Grepper.cpp @@ -69,8 +69,8 @@ strdup_to_utf8(uint32 encode, const char* src, int32 length) char* dup = strdup(dst); delete[] dst; if (srcLen != length) { - fprintf(stderr, "strdup_to_utf8(%ld, %ld) dst allocate smalled(%ld)\n", - encode, length, dstLen); + fprintf(stderr, "strdup_to_utf8(%" B_PRId32 ", %" B_PRId32 + ") dst allocate smalled(%" B_PRId32 ")\n", encode, length, dstLen); } return dup; } @@ -91,8 +91,8 @@ strdup_from_utf8(uint32 encode, const char* src, int32 length) char* dup = strdup(dst); delete[] dst; if (srcLen != length) { - fprintf(stderr, "strdup_from_utf8(%ld, %ld) dst allocate " - "smalled(%ld)\n", encode, length, dstLen); + fprintf(stderr, "strdup_from_utf8(%" B_PRId32 ", %" B_PRId32 + ") dst allocate smalled(%" B_PRId32 ")\n", encode, length, dstLen); } return dup; } @@ -183,7 +183,7 @@ Grepper::_GrepperThread() char command[B_PATH_NAME_LENGTH + 32]; BPath tempFile; - sprintf(fileName, "/tmp/SearchText%ld", fThreadId); + sprintf(fileName, "/tmp/SearchText%" B_PRId32, fThreadId); tempFile.SetTo(fileName); while (!fMustQuit && fIterator->GetNextName(fileName)) { diff --git a/src/apps/text_search/Model.cpp b/src/apps/text_search/Model.cpp index d90d6e3873..eb847a963b 100644 --- a/src/apps/text_search/Model.cpp +++ b/src/apps/text_search/Model.cpp @@ -29,7 +29,7 @@ using std::nothrow; Model::Model() : fDirectory(), - fSelectedFiles(0UL), + fSelectedFiles((uint32)0), fRecurseDirs(true), fRecurseLinks(false), @@ -204,7 +204,7 @@ Model::AddToHistory(const char* text) } while (items.CountItems() >= HISTORY_LIMIT) - delete static_cast(items.RemoveItem(0L)); + delete static_cast(items.RemoveItem((int32)0)); _SaveHistory(items); _FreeHistory(items); diff --git a/src/apps/webwatch/WatchView.cpp b/src/apps/webwatch/WatchView.cpp index 3488baecc4..ad5f3b441a 100644 --- a/src/apps/webwatch/WatchView.cpp +++ b/src/apps/webwatch/WatchView.cpp @@ -97,7 +97,7 @@ void WatchView::Draw(BRect updateRect) super::Draw(updateRect); char string[5]; - sprintf(string, "@%03ld", GetInternetTime()); + sprintf(string, "@%03" B_PRId32, GetInternetTime()); font_height height; // center the text horizontally GetFontHeight(&height); // and vertically in the Deskbar diff --git a/src/bin/bfs_tools/bfsinfo.cpp b/src/bin/bfs_tools/bfsinfo.cpp index 44b64ccda4..4c9a565daf 100644 --- a/src/bin/bfs_tools/bfsinfo.cpp +++ b/src/bin/bfs_tools/bfsinfo.cpp @@ -37,10 +37,10 @@ dump_bplustree(Disk &disk, BPositionIO *file, off_t size, bool hexDump) dump_bplustree_header(header); bplustree_node *node = (bplustree_node *)(buffer + nodeSize); - while ((int32)node < (int32)buffer + size) { + while ((addr_t)node < (addr_t)buffer + size) { printf("\n\n-------------------\n" - "** node at offset: %ld\n** used: %ld bytes\n", - int32(node) - int32(buffer), node->Used()); + "** node at offset: %" B_PRIuADDR "\n** used: %" B_PRId32 " bytes" + "\n", (addr_t)node - (addr_t)buffer, node->Used()); dump_bplustree_node(node, header, &disk); if (hexDump) { @@ -48,7 +48,7 @@ dump_bplustree(Disk &disk, BPositionIO *file, off_t size, bool hexDump) dump_block((char *)node, header->node_size, 0); } - node = (bplustree_node *)(int32(node) + nodeSize); + node = (bplustree_node *)((addr_t)node + nodeSize); } } @@ -79,11 +79,11 @@ dump_indirect_stream(Disk &disk, bfs_inode *node, bool showOffsets) if (runs[i].IsZero()) return; - printf(" indirect[%02ld] = ", i); + printf(" indirect[%02" B_PRId32 "] = ", i); char buffer[256]; if (showOffsets) - snprintf(buffer, sizeof(buffer), " %16lld", offset); + snprintf(buffer, sizeof(buffer), " %16" B_PRIdOFF, offset); else buffer[0] = '\0'; @@ -184,25 +184,27 @@ main(int argc, char **argv) printf(" Name:\t\t\t\"%s\"\n", disk.SuperBlock()->name); printf(" (disk is %s)\n\n", disk.ValidateSuperBlock() == B_OK ? "valid" : "invalid!!"); - printf(" Block Size:\t\t%ld bytes\n", disk.BlockSize()); - printf(" Number of Blocks:\t%12Lu\t%10g MB\n", disk.NumBlocks(), - disk.NumBlocks() * disk.BlockSize() / (1024.0*1024)); + printf(" Block Size:\t\t%" B_PRIu32 " bytes\n", disk.BlockSize()); + printf(" Number of Blocks:\t%12" B_PRIdOFF "\t%10g MB\n", + disk.NumBlocks(), disk.NumBlocks() * disk.BlockSize() + / (1024.0*1024)); if (disk.BlockBitmap() != NULL) { - printf(" Used Blocks:\t\t%12Lu\t%10g MB\n", + printf(" Used Blocks:\t\t%12" B_PRIdOFF "\t%10g MB\n", disk.BlockBitmap()->UsedBlocks(), disk.BlockBitmap()->UsedBlocks() * disk.BlockSize() / (1024.0*1024)); - printf(" Free Blocks:\t\t%12Lu\t%10g MB\n", + printf(" Free Blocks:\t\t%12" B_PRIdOFF "\t%10g MB\n", disk.BlockBitmap()->FreeBlocks(), disk.BlockBitmap()->FreeBlocks() * disk.BlockSize() / (1024.0*1024)); } int32 size = (disk.AllocationGroups() * disk.SuperBlock()->blocks_per_ag); - printf(" Bitmap Size:\t\t%ld bytes (%ld blocks, %ld per allocation " - "group)\n", disk.BlockSize() * size, size, + printf(" Bitmap Size:\t\t%" B_PRIu32 " bytes (%" B_PRId32 " blocks, %" + B_PRId32 " per allocation group)\n", disk.BlockSize() * size, size, disk.SuperBlock()->blocks_per_ag); - printf(" Allocation Groups:\t%lu\n\n", disk.AllocationGroups()); + printf(" Allocation Groups:\t%" B_PRIu32 "\n\n", + disk.AllocationGroups()); dump_block_run(" Log:\t\t\t", disk.Log()); printf(" (was %s)\n\n", disk.SuperBlock()->flags == SUPER_BLOCK_CLEAN ? "cleanly unmounted" : "not unmounted cleanly!"); @@ -260,8 +262,8 @@ main(int argc, char **argv) } if (dumpInode) { - printf("Inode at block %Ld:\n-----------------------------------------" - "\n", disk.ToBlock(run)); + printf("Inode at block %" B_PRIdOFF ":\n------------------------------" + "-----------\n", disk.ToBlock(run)); dump_inode(inode, (bfs_inode *)buffer, showOffsets); dump_indirect_stream(disk, (bfs_inode *)buffer, showOffsets); dump_small_data(inode); @@ -269,8 +271,8 @@ main(int argc, char **argv) } if (dumpBTree && inode) { - printf("B+Tree at block %Ld:\n----------------------------------------" - "-\n", disk.ToBlock(run)); + printf("B+Tree at block %" B_PRIdOFF ":\n-----------------------------" + "------------\n", disk.ToBlock(run)); if (inode->IsDirectory() || inode->IsAttributeDirectory()) { dump_bplustree(disk, (Directory *)inode, inode->Size(), dumpHex); putchar('\n'); @@ -279,8 +281,8 @@ main(int argc, char **argv) } if (validateBTree && inode) { - printf("Validating B+Tree at block %Ld:\n-----------------------------" - "------------\n", disk.ToBlock(run)); + printf("Validating B+Tree at block %" B_PRIdOFF ":\n------------------" + "-----------------------\n", disk.ToBlock(run)); if (inode->IsDirectory() || inode->IsAttributeDirectory()) { BPlusTree *tree; if (((Directory *)inode)->GetTree(&tree) == B_OK) { @@ -294,8 +296,8 @@ main(int argc, char **argv) } if (dumpHex) { - printf("Hexdump from inode at block %Ld:\n-----------------------------" - "------------\n", disk.ToBlock(run)); + printf("Hexdump from inode at block %" B_PRIdOFF ":\n-----------------" + "------------------------\n", disk.ToBlock(run)); dump_block(buffer, disk.BlockSize()); putchar('\n'); } diff --git a/src/bin/bfs_tools/lib/BPlusTree.cpp b/src/bin/bfs_tools/lib/BPlusTree.cpp index 9493593332..60255ebd4f 100644 --- a/src/bin/bfs_tools/lib/BPlusTree.cpp +++ b/src/bin/bfs_tools/lib/BPlusTree.cpp @@ -250,14 +250,14 @@ BPlusTree::Validate(bool verbose) while (true) { if (!stack.Pop(&info)) { if (verbose) { - printf(" %ld B+tree node(s) processed (%ld free node(s)).\n", - count, freeCount); + printf(" %" B_PRId32 " B+tree node(s) processed (%" B_PRId32 + " free node(s)).\n", count, freeCount); } return B_OK; } if (!info.free && verbose && ++count % 10 == 0) - printf(" %ld%s1A\n", count, escape); + printf(" %" B_PRId32 "%s1A\n", count, escape); else if (info.free) freeCount++; @@ -265,7 +265,9 @@ BPlusTree::Validate(bool verbose) if ((node = fCache.Get(info.offset)) == NULL || !info.free && !CheckNode(node)) { if (verbose) { - fprintf(stderr," B+Tree: Could not get data at position %Ld (referenced by node at %Ld)\n",info.offset,info.from); + fprintf(stderr," B+Tree: Could not get data at position %" + B_PRIdOFF " (referenced by node at %" B_PRIdOFF ")\n", + info.offset, info.from); if ((node = fCache.Get(info.from)) != NULL) dump_bplustree_node(node,fHeader); } @@ -350,7 +352,8 @@ status_t BPlusTree::Goto(int8 to) else { if (node->all_key_length > fNodeSize - || (uint32)node->Values() > (uint32)node + fNodeSize - 8 * node->all_key_count) + || (addr_t)node->Values() > (addr_t)node + fNodeSize + - 8 * node->all_key_count) return B_ERROR; pos = *node->Values(); diff --git a/src/bin/bfs_tools/lib/Bitmap.cpp b/src/bin/bfs_tools/lib/Bitmap.cpp index 53567dadca..8fbe8c439c 100644 --- a/src/bin/bfs_tools/lib/Bitmap.cpp +++ b/src/bin/bfs_tools/lib/Bitmap.cpp @@ -138,8 +138,8 @@ Bitmap::BackupSetAt(off_t block, bool used) { uint32 index = block / 32; if (index > fByteSize / 4) { - fprintf(stderr, "Bitmap::BackupSetAt(): Block %Ld outside bitmap!\n", - block); + fprintf(stderr, "Bitmap::BackupSetAt(): Block %" B_PRIdOFF " outside " + "bitmap!\n", block); return false; } @@ -251,7 +251,9 @@ Bitmap::CompareWithBackup() { for (int32 i = fByteSize / 4;i-- > 0;) { if (fBitmap[i] != fBackupBitmap[i]) { - printf("differ at %ld (block %ld) -> bitmap = %08lx, backup = %08lx\n",i,i*32,fBitmap[i],fBackupBitmap[i]); + printf("differ at %" B_PRId32 " (block %" B_PRId32 ") -> bitmap = " + "%08" B_PRIx32 ", backup = %08" B_PRIx32 "\n", i, i * 32, + fBitmap[i], fBackupBitmap[i]); } } return B_OK; diff --git a/src/bin/bfs_tools/lib/Disk.cpp b/src/bin/bfs_tools/lib/Disk.cpp index 5d0fd07f73..b082938ea6 100644 --- a/src/bin/bfs_tools/lib/Disk.cpp +++ b/src/bin/bfs_tools/lib/Disk.cpp @@ -147,8 +147,10 @@ Disk::Disk(const char *deviceName, bool rawMode, off_t start, off_t stop) } close(device); - if (fSize == 0LL) - fprintf(stderr,"Disk: Invalid file size (%Ld bytes)!\n",fSize); + if (fSize == 0LL) { + fprintf(stderr,"Disk: Invalid file size (%" B_PRIdOFF " bytes)!\n", + fSize); + } if (rawMode && ScanForSuperBlock(start, stop) < B_OK) { fFile.Unset(); @@ -240,7 +242,8 @@ Disk::DumpBootBlockToFile() status_t Disk::ScanForSuperBlock(off_t start, off_t stop) { - printf("Disk size %Ld bytes, %.2f GB\n", fSize, 1.0 * fSize / (1024*1024*1024)); + printf("Disk size %" B_PRIdOFF " bytes, %.2f GB\n", fSize, 1.0 * fSize + / (1024*1024*1024)); uint32 blockSize = 4096; char buffer[blockSize + 1024]; @@ -252,12 +255,15 @@ Disk::ScanForSuperBlock(off_t start, off_t stop) BList superBlocks; - printf("Scanning Disk from %Ld to %Ld\n", start, stop); + printf("Scanning Disk from %" B_PRIdOFF " to %" B_PRIdOFF "\n", start, + stop); for (off_t offset = start; offset < stop; offset += blockSize) { - if (((offset-start) % (blockSize * 100)) == 0) - printf(" %12Ld, %.2f GB %s1A\n",offset,1.0 * offset / (1024*1024*1024),escape); + if (((offset-start) % (blockSize * 100)) == 0) { + printf(" %12" B_PRIdOFF ", %.2f GB %s1A\n", offset, + 1.0 * offset / (1024*1024*1024),escape); + } ssize_t bytes = fBufferedFile->ReadAt(offset, buffer, blockSize + 1024); if (bytes < B_OK) @@ -274,7 +280,8 @@ Disk::ScanForSuperBlock(off_t start, off_t stop) && super->magic2 == (int32)SUPER_BLOCK_MAGIC2 && super->magic3 == (int32)SUPER_BLOCK_MAGIC3) { - printf("\n(%ld) *** BFS superblock found at: %Ld\n",superBlocks.CountItems() + 1,offset); + printf("\n(%" B_PRId32 ") *** BFS superblock found at: %" + B_PRIdOFF "\n", superBlocks.CountItems() + 1, offset); dump_super_block(super); // add a copy of the superblock to the list @@ -302,9 +309,10 @@ Disk::ScanForSuperBlock(off_t start, off_t stop) for (int32 i = 0; i < superBlocks.CountItems(); i++) { bfs_disk_info *info = (bfs_disk_info *)superBlocks.ItemAt(i); - printf("%ld) %s, offset %Ld, size %g GB (%svalid)\n", i + 1, - info->super_block.name, info->offset, - 1.0 * info->super_block.num_blocks * info->super_block.block_size / (1024*1024*1024), + printf("%" B_PRId32 ") %s, offset %" B_PRIdOFF ", size %g GB (%svalid)" + "\n", i + 1, info->super_block.name, info->offset, + 1.0 * info->super_block.num_blocks * info->super_block.block_size + / (1024*1024*1024), ValidateSuperBlock(info->super_block) < B_OK ? "in" : ""); } @@ -375,7 +383,7 @@ Disk::ValidateSuperBlock() status_t Disk::RecreateSuperBlock() { - memset(&fSuperBlock,0,sizeof(disk_super_block)); + memset(&fSuperBlock, 0, sizeof(disk_super_block)); puts("\n*** Determine block size"); @@ -383,7 +391,7 @@ Disk::RecreateSuperBlock() if (status < B_OK) return status; - printf("\tblock size = %ld\n",BlockSize()); + printf("\tblock size = %" B_PRId32 "\n", BlockSize()); strcpy(fSuperBlock.name,"recovered"); fSuperBlock.magic1 = SUPER_BLOCK_MAGIC1; @@ -450,7 +458,7 @@ Disk::RecreateSuperBlock() if (fLogStart != ((indexDir.inode_num.allocation_group << fSuperBlock.ag_shift) + indexDir.inode_num.start - LogSize())) { fprintf(stderr,"ERROR: start of logging area doesn't fit assumed value " - "(%Ld blocks before indices)!\n", LogSize()); + "(%" B_PRIdOFF " blocks before indices)!\n", LogSize()); //gErrors++; } @@ -492,8 +500,8 @@ Disk::DetermineBlockSize() // read a quarter of the drive at maximum for (; offset < (fSize >> 2); offset += 1024) { if (fBufferedFile->ReadAt(offset, buffer, sizeof(buffer)) < B_OK) { - fprintf(stderr, "could not read from device (offset = %Ld, " - "size = %ld)!\n", offset, sizeof(buffer)); + fprintf(stderr, "could not read from device (offset = %" B_PRIdOFF + ", size = %ld)!\n", offset, sizeof(buffer)); status = B_IO_ERROR; break; } @@ -551,7 +559,8 @@ Disk::GetNextSpecialInode(char *buffer, off_t *_offset, off_t end, for (; offset < end; offset += BlockSize()) { if (fBufferedFile->ReadAt(offset, buffer, 1024) < B_OK) { - fprintf(stderr,"could not read from device (offset = %Ld, size = %d)!\n",offset,1024); + fprintf(stderr,"could not read from device (offset = %" B_PRIdOFF + ", size = %d)!\n", offset, 1024); *_offset = offset; return B_IO_ERROR; } @@ -576,7 +585,7 @@ Disk::GetNextSpecialInode(char *buffer, off_t *_offset, off_t end, // is the inode a special root inode (parent == self)? if (!memcmp(&inode->parent, &inode->inode_num, sizeof(inode_addr))) { - printf("\t special inode found at %Ld\n", offset); + printf("\t special inode found at %" B_PRIdOFF "\n", offset); *_offset = offset; return B_OK; @@ -596,10 +605,12 @@ Disk::SaveInode(bfs_inode *inode, bool *indices, bfs_inode *indexDir, printf("\troot node found!\n"); if (inode->inode_num.allocation_group != 8 || inode->inode_num.start != 0 - || inode->inode_num.length != 1) - printf("WARNING: root node has unexpected position: (ag = %ld, " - "start = %d, length = %d)\n", inode->inode_num.allocation_group, + || inode->inode_num.length != 1) { + printf("WARNING: root node has unexpected position: (ag = %" + B_PRId32 ", start = %d, length = %d)\n", + inode->inode_num.allocation_group, inode->inode_num.start, inode->inode_num.length); + } if (rootDir) memcpy(rootDir, inode, sizeof(bfs_inode)); } else if (inode->mode & S_INDEX_DIR) { @@ -662,7 +673,8 @@ Disk::ScanForIndexAndRoot(bfs_inode *indexDir,bfs_inode *rootDir) { SaveInode(inode,&indices,indexDir,&root,rootDir); - printf("root node at: 0x%Lx (DiskProbe)\n",logOffset / 512); + printf("root node at: 0x%" B_PRIxOFF " (DiskProbe)\n", + logOffset / 512); //fBufferedFile->ReadAt(logOffset + BlockSize(),buffer,1024); //if (*(uint32 *)buffer == BPLUSTREE_MAGIC) //{ diff --git a/src/bin/bfs_tools/lib/Inode.cpp b/src/bin/bfs_tools/lib/Inode.cpp index 4fab2fd07b..f13b615cc9 100644 --- a/src/bin/bfs_tools/lib/Inode.cpp +++ b/src/bin/bfs_tools/lib/Inode.cpp @@ -276,17 +276,18 @@ Inode::SetName(const char *name) int32 oldLength = nameData == NULL ? 0 : nameData->data_size; int32 newLength = strlen(name) + (nameData == NULL ? sizeof(small_data) + 5 : 0); - if (int32(data) + newLength - oldLength >= (int32)(fInode + fDisk->BlockSize())) + if ((addr_t)data + newLength - oldLength >= (addr_t)(fInode + + fDisk->BlockSize())) return B_NO_MEMORY; if (nameData == NULL) { memmove(newLength + (uint8 *)fInode->small_data_start, fInode->small_data_start, - int32(data) - int32(fInode->small_data_start)); + (addr_t)data - (addr_t)fInode->small_data_start); nameData = fInode->small_data_start; } else { memmove(newLength + (uint8 *)nameData, nameData, - int32(data) - int32(fInode->small_data_start)); + (addr_t)data - (addr_t)fInode->small_data_start); } memset(nameData, 0, sizeof(small_data) + 5 + strlen(name)); @@ -766,7 +767,7 @@ DataStream::ReadAt(off_t pos, void *buffer, size_t size) //printf("DataStream::ReadAt(pos = %Ld,buffer = %p,size = %ld);\n",pos,buffer,size); // truncate size to read - if (pos + size > fInode->data.size) { + if (pos + (off_t)size > fInode->data.size) { if (pos > fInode->data.size) // reading outside the file return B_ERROR; @@ -782,14 +783,14 @@ DataStream::ReadAt(off_t pos, void *buffer, size_t size) if (status < B_OK) return status; - ssize_t bytes = min_c(size, fRunBlockEnd - pos); + ssize_t bytes = min_c((off_t)size, fRunBlockEnd - pos); //printf("### read %ld bytes from %Ld\n### --\n",bytes,fDisk->ToOffset(fRun) + pos - fRunFileOffset); bytes = fDisk->ReadAt(fDisk->ToOffset(fRun) + pos - fRunFileOffset, buffer, bytes); if (bytes <= 0) { if (bytes == 0) { - printf("could not read bytes at: %ld,%d\n", + printf("could not read bytes at: %" B_PRId32 ",%d\n", fRun.allocation_group, fRun.start); } return bytes < 0 ? bytes : B_BAD_DATA; @@ -813,7 +814,7 @@ DataStream::WriteAt(off_t pos, const void *buffer, size_t size) NodeGetter _(this); // FIXME: truncate size -> should enlargen the file - if (pos + size > fInode->data.size) { + if (pos + (off_t)size > fInode->data.size) { if (pos > fInode->data.size) // writing outside the file return B_ERROR; @@ -829,7 +830,7 @@ DataStream::WriteAt(off_t pos, const void *buffer, size_t size) if (status < B_OK) return status; - ssize_t bytes = min_c(size,fRunBlockEnd - pos); + ssize_t bytes = min_c((off_t)size, fRunBlockEnd - pos); //printf("### write %ld bytes to %Ld\n### --\n",bytes,fDisk->ToOffset(fRun) + pos - fRunFileOffset); bytes = fDisk->WriteAt(fDisk->ToOffset(fRun) + pos - fRunFileOffset,buffer,bytes); @@ -959,8 +960,8 @@ File::CopyTo(const char *root, bool fullPath, Inode::Source *source) << (int32)BlockRun().start; path.Append(sub.String()); } - printf("%ld,%d -> %s\n", BlockRun().allocation_group, BlockRun().start, - path.Path()); + printf("%" B_PRId32 ",%d -> %s\n", BlockRun().allocation_group, + BlockRun().start, path.Path()); BFile file; status = file.SetTo(path.Path(), diff --git a/src/bin/bfs_tools/lib/bfs.h b/src/bin/bfs_tools/lib/bfs.h index f2ac852b4b..224e3a0ef3 100644 --- a/src/bin/bfs_tools/lib/bfs.h +++ b/src/bin/bfs_tools/lib/bfs.h @@ -251,7 +251,7 @@ inline small_data *small_data::Next() inline bool small_data::IsLast(bfs_inode *inode) { - return (uint32)this > (uint32)inode + inode->inode_size - sizeof(small_data) + return (addr_t)this > (addr_t)inode + inode->inode_size - sizeof(small_data) || name_size == 0; } diff --git a/src/bin/bfs_tools/lib/dump.cpp b/src/bin/bfs_tools/lib/dump.cpp index 651eeda5fa..caaf851562 100644 --- a/src/bin/bfs_tools/lib/dump.cpp +++ b/src/bin/bfs_tools/lib/dump.cpp @@ -38,7 +38,7 @@ get_tupel(uint32 id) void dump_block_run(const char *prefix, const block_run &run, const char *postfix) { - Print("%s(%ld, %d, %d)%s\n", prefix, run.allocation_group, + Print("%s(%" B_PRId32 ", %d, %d)%s\n", prefix, run.allocation_group, run.start, run.length, postfix); } @@ -48,29 +48,29 @@ dump_super_block(const disk_super_block *superBlock) { Print("disk_super_block:\n"); Print(" name = %s\n", superBlock->name); - Print(" magic1 = %#08lx (%s) %s\n", superBlock->magic1, + Print(" magic1 = %#08" B_PRIx32 " (%s) %s\n", superBlock->magic1, get_tupel(superBlock->magic1), superBlock->magic1 == SUPER_BLOCK_MAGIC1 ? "valid" : "INVALID"); - Print(" fs_byte_order = %#08lx (%s, %s endian)\n", + Print(" fs_byte_order = %#08" B_PRIx32 " (%s, %s endian)\n", superBlock->fs_byte_order, get_tupel(superBlock->fs_byte_order), superBlock->fs_byte_order == SUPER_BLOCK_FS_LENDIAN ? "little" : "big"); - Print(" block_size = %lu\n", superBlock->block_size); - Print(" block_shift = %lu\n", superBlock->block_shift); - Print(" num_blocks = %Lu\n", superBlock->num_blocks); - Print(" used_blocks = %Lu\n", superBlock->used_blocks); - Print(" inode_size = %lu\n", superBlock->inode_size); - Print(" magic2 = %#08lx (%s) %s\n", superBlock->magic2, + Print(" block_size = %" B_PRIu32 "\n", superBlock->block_size); + Print(" block_shift = %" B_PRIu32 "\n", superBlock->block_shift); + Print(" num_blocks = %" B_PRIdOFF "\n", superBlock->num_blocks); + Print(" used_blocks = %" B_PRIdOFF "\n", superBlock->used_blocks); + Print(" inode_size = %" B_PRId32 "\n", superBlock->inode_size); + Print(" magic2 = %#08" B_PRIx32 " (%s) %s\n", superBlock->magic2, get_tupel(superBlock->magic2), superBlock->magic2 == (int)SUPER_BLOCK_MAGIC2 ? "valid" : "INVALID"); - Print(" blocks_per_ag = %lu\n", superBlock->blocks_per_ag); - Print(" ag_shift = %lu\n", superBlock->ag_shift); - Print(" num_ags = %lu\n", superBlock->num_ags); - Print(" flags = %#08lx (%s)\n", superBlock->flags, + Print(" blocks_per_ag = %" B_PRId32 "\n", superBlock->blocks_per_ag); + Print(" ag_shift = %" B_PRId32 "\n", superBlock->ag_shift); + Print(" num_ags = %" B_PRId32 "\n", superBlock->num_ags); + Print(" flags = %#08" B_PRIx32 " (%s)\n", superBlock->flags, get_tupel(superBlock->flags)); dump_block_run(" log_blocks = ", superBlock->log_blocks); - Print(" log_start = %Lu\n", superBlock->log_start); - Print(" log_end = %Lu\n", superBlock->log_end); - Print(" magic3 = %#08lx (%s) %s\n", superBlock->magic3, + Print(" log_start = %" B_PRIdOFF "\n", superBlock->log_start); + Print(" log_end = %" B_PRIdOFF "\n", superBlock->log_end); + Print(" magic3 = %#08" B_PRIx32 " (%s) %s\n", superBlock->magic3, get_tupel(superBlock->magic3), superBlock->magic3 == SUPER_BLOCK_MAGIC3 ? "valid" : "INVALID"); dump_block_run(" root_dir = ", superBlock->root_dir); @@ -91,7 +91,7 @@ dump_data_stream(const bfs_inode *inode, const data_stream *stream, bool showOff char buffer[256]; if (showOffsets) - snprintf(buffer, sizeof(buffer), " %16lld", offset); + snprintf(buffer, sizeof(buffer), " %16" B_PRIdOFF, offset); else buffer[0] = '\0'; @@ -100,21 +100,23 @@ dump_data_stream(const bfs_inode *inode, const data_stream *stream, bool showOff offset += stream->direct[i].length * inode->inode_size; } } - Print(" max_direct_range = %Lu\n", stream->max_direct_range); + Print(" max_direct_range = %" B_PRIdOFF "\n", + stream->max_direct_range); if (!stream->indirect.IsZero()) dump_block_run(" indirect = ", stream->indirect); - Print(" max_indirect_range = %Lu\n", stream->max_indirect_range); + Print(" max_indirect_range = %" B_PRIdOFF "\n", + stream->max_indirect_range); if (!stream->double_indirect.IsZero()) { dump_block_run(" double_indirect = ", stream->double_indirect); } - Print(" max_double_indirect_range = %Lu\n", + Print(" max_double_indirect_range = %" B_PRIdOFF "\n", stream->max_double_indirect_range); - Print(" size = %Lu\n", stream->size); + Print(" size = %" B_PRIdOFF "\n", stream->size); } @@ -126,13 +128,14 @@ dump_inode(const Inode *nameNode, const bfs_inode *inode, bool showOffsets) else Print("inode:\n"); - Print(" magic1 = %08lx (%s) %s\n",inode->magic1, - get_tupel(inode->magic1), (inode->magic1 == INODE_MAGIC1 ? "valid" : "INVALID")); + Print(" magic1 = %08" B_PRIx32 " (%s) %s\n",inode->magic1, + get_tupel(inode->magic1), + (inode->magic1 == INODE_MAGIC1 ? "valid" : "INVALID")); dump_block_run( " inode_num = ",inode->inode_num); - Print(" uid = %lu\n",inode->uid); - Print(" gid = %lu\n",inode->gid); - Print(" mode = %10lo (octal)\n",inode->mode); - Print(" flags = %08lx\n",inode->flags); + Print(" uid = %" B_PRIu32 "\n",inode->uid); + Print(" gid = %" B_PRIu32 "\n",inode->gid); + Print(" mode = %10" B_PRIo32 " (octal)\n",inode->mode); + Print(" flags = %08" B_PRIx32 "\n",inode->flags); time_t time; time = (time_t)(inode->create_time >> 16); @@ -142,9 +145,9 @@ dump_inode(const Inode *nameNode, const bfs_inode *inode, bool showOffsets) dump_block_run( " parent = ",inode->parent); dump_block_run( " attributes = ",inode->attributes); - Print(" type = %lu\n",inode->type); - Print(" inode_size = %lu\n",inode->inode_size); - Print(" etc = %#08lx\n",inode->etc); + Print(" type = %" B_PRIu32 "\n",inode->type); + Print(" inode_size = %" B_PRId32 "\n",inode->inode_size); + Print(" etc = %#08" B_PRIx32 "\n",inode->etc); Print(" short_symlink = %s\n", S_ISLNK(inode->mode) && (inode->flags & INODE_LONG_SYMLINK) == 0 ? inode->short_symlink : "-"); @@ -172,7 +175,8 @@ dump_small_data(Inode *inode) inode->InodeBuffer()->inode_size - sizeof(struct bfs_inode)); while (inode->GetNextSmallData(&item) == B_OK) { - printf("%#08lx (%s), name = \"%s\", ", item->type, get_tupel(item->type), item->Name()); + printf("%#08" B_PRIx32 " (%s), name = \"%s\", ", item->type, + get_tupel(item->type), item->Name()); if (item->type == FILE_NAME_TYPE || item->type == B_STRING_TYPE || item->type == B_MIME_STRING_TYPE) @@ -187,15 +191,19 @@ void dump_bplustree_header(const bplustree_header* header) { printf("bplustree_header:\n"); - printf(" magic = %#08lx (%s) %s\n", header->magic, - get_tupel(header->magic), + printf(" magic = %#08" B_PRIx32 " (%s) %s\n", + header->magic, get_tupel(header->magic), header->magic == BPLUSTREE_MAGIC ? "valid" : "INVALID"); - printf(" node_size = %lu\n", header->node_size); - printf(" max_number_of_levels = %lu\n", header->max_number_of_levels); - printf(" data_type = %lu\n", header->data_type); - printf(" root_node_pointer = %Ld\n", header->root_node_pointer); - printf(" free_node_pointer = %Ld\n", header->free_node_pointer); - printf(" maximum_size = %Lu\n", header->maximum_size); + printf(" node_size = %" B_PRIu32 "\n", header->node_size); + printf(" max_number_of_levels = %" B_PRIu32 "\n", + header->max_number_of_levels); + printf(" data_type = %" B_PRIu32 "\n", header->data_type); + printf(" root_node_pointer = %" B_PRIdOFF "\n", + header->root_node_pointer); + printf(" free_node_pointer = %" B_PRIdOFF "\n", + header->free_node_pointer); + printf(" maximum_size = %" B_PRIdOFF "\n", + header->maximum_size); } @@ -205,9 +213,9 @@ dump_bplustree_node(const bplustree_node* node, const bplustree_header* header, { Print("bplustree_node (%s node):\n", node->overflow_link == BPLUSTREE_NULL ? "leaf" : "index"); - Print(" left_link = %Ld\n", node->left_link); - Print(" right_link = %Ld\n", node->right_link); - Print(" overflow_link = %Ld\n", node->overflow_link); + Print(" left_link = %" B_PRIdOFF "\n", node->left_link); + Print(" right_link = %" B_PRIdOFF "\n", node->right_link); + Print(" overflow_link = %" B_PRIdOFF "\n", node->overflow_link); Print(" all_key_count = %u\n", node->all_key_count); Print(" all_key_length = %u\n", node->all_key_length); @@ -226,7 +234,7 @@ dump_bplustree_node(const bplustree_node* node, const bplustree_header* header, uint16 length; char* key = (char *)node->KeyAt(i, &length); if (length > 255) { - Print(" %2ld. Invalid length (%u)!!\n", i, length); + Print(" %2" B_PRId32 ". Invalid length (%u)!!\n", i, length); dump_block((char *)node, header->node_size, sizeof(off_t)); break; } @@ -236,33 +244,35 @@ dump_bplustree_node(const bplustree_node* node, const bplustree_header* header, buffer[length] = '\0'; off_t *value = node->Values() + i; - if ((uint32)value < (uint32)node || (uint32)value > (uint32)node + header->node_size) - Print(" %2ld. Invalid Offset!!\n",i); - else { - Print(" %2ld. ",i); + if ((addr_t)value < (addr_t)node + || (addr_t)value > (addr_t)node + header->node_size) { + Print(" %2" B_PRId32 ". Invalid Offset!!\n", i); + } else { + Print(" %2" B_PRId32 ". ",i); if (header->data_type == BPLUSTREE_STRING_TYPE) Print("\"%s\"",buffer); else if (header->data_type == BPLUSTREE_INT32_TYPE) { - Print("int32 = %ld (0x%lx)", *(int32 *)&buffer, - *(int32 *)&buffer); + Print("int32 = %" B_PRId32 " (0x%" B_PRIx32 ")", + *(int32 *)&buffer, *(int32 *)&buffer); } else if (header->data_type == BPLUSTREE_UINT32_TYPE) { - Print("uint32 = %lu (0x%lx)", *(uint32 *)&buffer, - *(uint32 *)&buffer); + Print("uint32 = %" B_PRIu32 " (0x%" B_PRIx32 ")", + *(uint32 *)&buffer, *(uint32 *)&buffer); } else if (header->data_type == BPLUSTREE_INT64_TYPE) { - Print("int64 = %Ld (0x%Lx)", *(int64 *)&buffer, - *(int64 *)&buffer); + Print("int64 = %" B_PRId64 " (0x%" B_PRIx64 ")", + *(int64 *)&buffer, *(int64 *)&buffer); } else Print("???"); off_t offset = *value & 0x3fffffffffffffffLL; - Print(" (%d bytes) -> %Ld",length,offset); + Print(" (%d bytes) -> %" B_PRIdOFF,length,offset); if (disk != NULL) { block_run run = disk->ToBlockRun(offset); - Print(" (%ld, %d)", run.allocation_group, run.start); + Print(" (%" B_PRId32 ", %d)", run.allocation_group, run.start); } if (bplustree_node::LinkType(*value) == BPLUSTREE_DUPLICATE_FRAGMENT) { - Print(" (duplicate fragment %Ld)\n", *value & 0x3ff); + Print(" (duplicate fragment %" B_PRIdOFF ")\n", + *value & 0x3ff); } else if (bplustree_node::LinkType(*value) == BPLUSTREE_DUPLICATE_NODE) { Print(" (duplicate node)\n"); @@ -310,7 +320,7 @@ dump_block(const char *buffer, uint32 size, int8 valueSize) for (uint32 offset = start; offset < start + kBlockSize; offset += valueSize) { if (valueSize == sizeof(off_t)) - Print("%s%Ld", offset == start ? "" : ", ", + Print("%s%" B_PRIdOFF, offset == start ? "" : ", ", *(off_t *)(buffer + offset)); } Print(")"); diff --git a/src/bin/debug/profile/BasicProfileResult.cpp b/src/bin/debug/profile/BasicProfileResult.cpp index 15e8fa3f85..52f707fbd2 100644 --- a/src/bin/debug/profile/BasicProfileResult.cpp +++ b/src/bin/debug/profile/BasicProfileResult.cpp @@ -6,6 +6,9 @@ #include "BasicProfileResult.h" +#if __GNUC__ > 2 +#include +#endif #include #include @@ -210,10 +213,23 @@ BasicProfileResult::PrintResults(ImageProfileResultContainer* container) for (int32 i = 0; i < hitSymbolCount; i++) { const HitSymbol& hitSymbol = hitSymbols[i]; const Symbol* symbol = hitSymbol.symbol; +#if __GNUC__ > 2 + int status; + const char* symbolName = __cxxabiv1::__cxa_demangle(symbol->Name(), + NULL, NULL, &status); + if (symbolName == NULL) + symbolName = symbol->Name(); +#else + const char* symbolName = symbol->Name(); +#endif fprintf(gOptions.output, " %10lld %10lld %6.2f %6ld %s\n", hitSymbol.hits, hitSymbol.hits * fInterval, 100.0 * hitSymbol.hits / totalTicks, hitSymbol.imageID, - symbol->Name()); + symbolName); +#if __GNUC__ > 2 + if (status == 0) + free(const_cast(symbolName)); +#endif } } else fprintf(gOptions.output, " no functions were hit\n"); diff --git a/src/bin/debug/profile/profile.cpp b/src/bin/debug/profile/profile.cpp index dbe0d8f20a..dd50dcd81e 100644 --- a/src/bin/debug/profile/profile.cpp +++ b/src/bin/debug/profile/profile.cpp @@ -467,7 +467,9 @@ private: error = sharedImage->Init(name.String()); } - } else + } else if (strcmp(imageInfo.name, "commpage") == 0) + error = sharedImage->Init(teamID, imageInfo.id); + else error = sharedImage->Init(imageInfo.name); if (error != B_OK) return error; diff --git a/src/bin/hey.cpp b/src/bin/hey.cpp index b311ea353b..ac464bef00 100644 --- a/src/bin/hey.cpp +++ b/src/bin/hey.cpp @@ -164,11 +164,16 @@ parse(BMessenger& the_application, int argc, char *argv[], int32 argapp) } else { if (the_reply.what == (uint32)B_MESSAGE_NOT_UNDERSTOOD || the_reply.what==(uint32)B_ERROR){ // I do it myself if (the_reply.HasString("message")){ - if (!silent) - printf("%s (error 0x%8lX)\n", the_reply.FindString("message"), the_reply.FindInt32("error")); + if (!silent) { + printf("%s (error 0x%8" B_PRIx32 ")\n", + the_reply.FindString("message"), + the_reply.FindInt32("error")); + } } else { - if (!silent) - printf("error 0x%8lX\n", the_reply.FindInt32("error")); + if (!silent) { + printf("error 0x%8" B_PRIx32 "\n", + the_reply.FindInt32("error")); + } } return 1; } else { @@ -187,7 +192,7 @@ parse(BMessenger& the_application, int argc, char *argv[], int32 argapp) } else if(tc==B_INT32_TYPE){ int32 v; the_reply.FindInt32("result", &v); - printf("%ld\n", v); + printf("%" B_PRId32 "\n", v); } else if(tc==B_UINT8_TYPE){ uint8 v; the_reply.FindInt8("result", (int8*)&v); @@ -199,7 +204,7 @@ parse(BMessenger& the_application, int argc, char *argv[], int32 argapp) } else if(tc==B_UINT32_TYPE){ uint32 v; the_reply.FindInt32("result", (int32*)&v); - printf("%lu\n", v); + printf("%" B_PRIu32 "\n", v); } else if(tc==B_STRING_TYPE){ const char* v; the_reply.FindString("result", &v); @@ -288,8 +293,8 @@ main(int argc, char *argv[]) be_roster->GetAppList(&team_list); - for (int32 i=0; iGetRunningAppInfo(teamid, &appinfo); if (strcmp(appinfo.signature, argv[argapp])==0){ the_application=BMessenger(appinfo.signature); @@ -479,7 +484,7 @@ Hey(BMessenger* target, char* argv[], int32* argx, int32 argc, BMessage* reply) // if all goes well, rply contains all kinds of property infos int32 j=0; void *voidptr; - int32 sizefound; + ssize_t sizefound; BPropertyInfo propinfo; const value_info *vinfo; int32 vinfo_index, vinfo_count; @@ -958,8 +963,9 @@ void add_message_contents(BList *textlist, BMessage *msg, int32 level) { int32 count; - int32 i, sizefound, j; - ulong typefound; + int32 i, j; + type_code typefound; + ssize_t sizefound; #ifdef HAIKU_TARGET_PLATFORM_DANO const char *namefound; #else @@ -1178,14 +1184,15 @@ format_data(int32 type, char *ptr, long size) case B_INT64_TYPE: str = new char[64]; i64 = *(int64*)ptr; - sprintf(str, "%Ld (0x%LX)", i64, i64); + sprintf(str, "%" B_PRId64 " (0x%" B_PRIx64 ")", i64, i64); break; case B_SIZE_T_TYPE: case B_INT32_TYPE: str = new char[64]; i32 = *(int32*)ptr; - sprintf(str, "%ld (0x%08lX)", i32, i32); + sprintf(str, "%" B_PRId32 " (0x%08" B_PRId32 ")", i32, + i32); break; case B_INT16_TYPE: @@ -1204,13 +1211,15 @@ format_data(int32 type, char *ptr, long size) case B_UINT64_TYPE: str = new char[64]; ui64 = *(uint64*)ptr; - sprintf(str, "%Lu (0x%LX)", ui64, ui64); + sprintf(str, "%" B_PRIu64 " (0x%" B_PRIx64 ")", ui64, + ui64); break; case B_UINT32_TYPE: str = new char[64]; ui32 = *(uint32*)ptr; - sprintf(str, "%lu (0x%08lX)", ui32, ui32); + sprintf(str, "%" B_PRIu32 " (0x%08" B_PRIx32 ")", ui32, + ui32); break; case B_UINT16_TYPE: @@ -1394,7 +1403,8 @@ format_data(int32 type, char *ptr, long size) strcat(str, vinfo[vinfo_index].name); strcat(str, " "); - sprintf(str+strlen(str), "0x%8lX (", vinfo[vinfo_index].value); + sprintf(str+strlen(str), "0x%8" B_PRIx32 " (", + vinfo[vinfo_index].value); id_to_string(vinfo[vinfo_index].value, str+strlen(str)); strcat(str, ")"); diff --git a/src/bin/reindex.cpp b/src/bin/reindex.cpp index 090fa74f4e..319e605fa3 100644 --- a/src/bin/reindex.cpp +++ b/src/bin/reindex.cpp @@ -247,7 +247,7 @@ handleFile(BEntry *entry, BNode *node) } // rewrite attrs and empty the list - while ((attr = static_cast(list.RemoveItem(0L))) != NULL) { + while ((attr = static_cast(list.RemoveItem((int32)0))) != NULL) { // write attribute back to file status = attr->WriteToFile(node); if (status != B_OK) { @@ -294,8 +294,8 @@ copyIndicesFromVolume(const char *path, BEntry &to) if (fs_create_index(targetDevice, index->d_name, indexInfo.type, 0) == -1 && errno != B_FILE_EXISTS && errno != B_BAD_VALUE) { - fprintf(stderr, "Could not create index '%s' (type = %lu): %s\n", - index->d_name, indexInfo.type, strerror(errno)); + fprintf(stderr, "Could not create index '%s' (type = %" B_PRIu32 + "): %s\n", index->d_name, indexInfo.type, strerror(errno)); } else gAttrList.AddItem(strdup(index->d_name)); } diff --git a/src/bin/roster.cpp b/src/bin/roster.cpp index ae611b3e84..9eca23be26 100644 --- a/src/bin/roster.cpp +++ b/src/bin/roster.cpp @@ -79,7 +79,7 @@ output_team(team_id id, int32 mode) if ((mode & kNoTruncateMode) == 0) truncate_string(name, kNameFieldWidth); - printf("%6ld %*s %5ld %5lx (%s)\n", + printf("%6" B_PRId32 " %*s %5" B_PRId32 " %5" B_PRIx32 " (%s)\n", id, (int)kNameFieldWidth, name.String(), info.port, info.flags, info.signature); } @@ -141,7 +141,7 @@ main(int argc, char **argv) // Iterate through the list. for (int32 i = 0; i < applicationList.CountItems(); i++) - output_team((team_id)applicationList.ItemAt(i), mode); + output_team((team_id)(addr_t)applicationList.ItemAt(i), mode); return 0; } diff --git a/src/bin/translate.cpp b/src/bin/translate.cpp index 27969917c8..48de3954ad 100644 --- a/src/bin/translate.cpp +++ b/src/bin/translate.cpp @@ -131,21 +131,21 @@ print_translation_format(const translation_format &format) void TypeList::Add(uint32 type) { - fList.AddItem((void *)type, 0); + fList.AddItem((void *)(addr_t)type, 0); } bool TypeList::Remove(uint32 type) { - return fList.RemoveItem((void *)type); + return fList.RemoveItem((void *)(addr_t)type); } bool TypeList::FindType(uint32 type) { - return fList.IndexOf((void *)type) >= 0; + return fList.IndexOf((void *)(addr_t)type) >= 0; } @@ -155,7 +155,7 @@ TypeList::SetTo(TypeList &types) fList.MakeEmpty(); for (int32 i = 0; i < types.Count(); i++) - fList.AddItem((void *)types.TypeAt(i)); + fList.AddItem((void *)(addr_t)types.TypeAt(i)); } @@ -169,7 +169,7 @@ TypeList::Count() uint32 TypeList::TypeAt(int32 index) { - return (uint32)fList.ItemAt(index); + return (uint32)(addr_t)fList.ItemAt(index); } @@ -612,7 +612,8 @@ TranslateApp::ListTranslators(uint32 type) continue; } - printf("name: %s\ninfo: %s\nversion: %ld.%ld.%ld\n", name, info, + printf("name: %s\ninfo: %s\nversion: %" B_PRId32 ".%" B_PRId32 ".%" + B_PRId32 "\n", name, info, B_TRANSLATION_MAJOR_VERSION(version), B_TRANSLATION_MINOR_VERSION(version), B_TRANSLATION_REVISION_VERSION(version)); diff --git a/src/kits/interface/BMCPrivate.cpp b/src/kits/interface/BMCPrivate.cpp index 56c4efaf57..f1dde0267d 100644 --- a/src/kits/interface/BMCPrivate.cpp +++ b/src/kits/interface/BMCPrivate.cpp @@ -1,27 +1,29 @@ /* - * Copyright 2001-2009 Haiku, Inc. All rights reserved. + * Copyright 2001-2013 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: - * Marc Flerackers (mflerackers@androme.be) - * Stephan Aßmus + * Stephan Aßmus, superstippi@gmx.de + * Marc Flerackers, mflerackers@androme.be + * John Scipione, jcipione@gmail.com */ #include -#include - #include #include #include #include #include #include -#include #include +static const float kPopUpIndicatorWidth = 10.0f; +static const float kMarginWidth = 3.0f; + + _BMCFilter_::_BMCFilter_(BMenuField* menuField, uint32 what) : BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE, what), @@ -68,11 +70,11 @@ _BMCMenuBar_::_BMCMenuBar_(BRect frame, bool fixedSize, BMenuField* menuField) } -_BMCMenuBar_::_BMCMenuBar_(bool fixedSize, BMenuField* menuField) +_BMCMenuBar_::_BMCMenuBar_(BMenuField* menuField) : - BMenuBar("_mc_mb_", B_ITEMS_IN_ROW, !fixedSize), + BMenuBar("_mc_mb_", B_ITEMS_IN_ROW), fMenuField(menuField), - fFixedSize(fixedSize), + fFixedSize(true), fRunner(NULL), fShowPopUpMarker(true) { @@ -81,7 +83,8 @@ _BMCMenuBar_::_BMCMenuBar_(bool fixedSize, BMenuField* menuField) _BMCMenuBar_::_BMCMenuBar_(BMessage* data) - : BMenuBar(data), + : + BMenuBar(data), fMenuField(NULL), fFixedSize(true), fRunner(NULL), @@ -134,119 +137,23 @@ _BMCMenuBar_::AttachedToWindow() void _BMCMenuBar_::Draw(BRect updateRect) { - if (be_control_look != NULL) { - BRect rect(Bounds()); - rgb_color base = ui_color(B_MENU_BACKGROUND_COLOR); - uint32 flags = 0; - if (!IsEnabled()) - flags |= BControlLook::B_DISABLED; - if (IsFocus()) - flags |= BControlLook::B_FOCUSED; - be_control_look->DrawMenuFieldBackground(this, rect, - updateRect, base, fShowPopUpMarker, flags); - - _DrawItems(updateRect); - - return; + if (fFixedSize || Bounds().Width() > fMenuField->_MenuBarWidth()) { + // Set the width of the menu bar because the menu bar bounds have + // been expanded by the selected menu item. + ResizeTo(fMenuField->_MenuBarWidth(), Bounds().Height()); } + BRect rect(Bounds()); + rgb_color base = ui_color(B_MENU_BACKGROUND_COLOR); + uint32 flags = 0; + if (!IsEnabled()) + flags |= BControlLook::B_DISABLED; + if (IsFocus()) + flags |= BControlLook::B_FOCUSED; - if (!fShowPopUpMarker) { - BMenuBar::Draw(updateRect); - return; - } + be_control_look->DrawMenuFieldBackground(this, rect, + updateRect, base, fShowPopUpMarker, flags); - // draw the right side with the popup marker - - // prevent the original BMenuBar's Draw from - // drawing in those parts - BRect bounds(Bounds()); - bounds.right -= 10.0; - bounds.bottom -= 1.0; - - BRegion clipping(bounds); - ConstrainClippingRegion(&clipping); - - BMenuBar::Draw(updateRect); - - // restore clipping - ConstrainClippingRegion(NULL); - bounds.right += 10.0; - bounds.bottom += 1.0; - - // prepare some colors - rgb_color normalNoTint = LowColor(); - rgb_color noTint = tint_color(normalNoTint, 0.74); - rgb_color darken4; - rgb_color normalDarken4; - rgb_color darken1; - rgb_color lighten1; - rgb_color lighten2; - - if (IsEnabled()) { - darken4 = tint_color(noTint, B_DARKEN_4_TINT); - normalDarken4 = tint_color(normalNoTint, B_DARKEN_4_TINT); - darken1 = tint_color(noTint, B_DARKEN_1_TINT); - lighten1 = tint_color(noTint, B_LIGHTEN_1_TINT); - lighten2 = tint_color(noTint, B_LIGHTEN_2_TINT); - } else { - darken4 = tint_color(noTint, B_DARKEN_2_TINT); - normalDarken4 = tint_color(normalNoTint, B_DARKEN_2_TINT); - darken1 = tint_color(noTint, (B_NO_TINT + B_DARKEN_1_TINT) / 2.0); - lighten1 = tint_color(noTint, (B_NO_TINT + B_LIGHTEN_1_TINT) / 2.0); - lighten2 = tint_color(noTint, B_LIGHTEN_1_TINT); - } - - BRect r(bounds); - r.left = r.right - 10.0; - - BeginLineArray(6); - // bottom below item text, darker then BMenuBar - // would normaly draw it - AddLine(BPoint(bounds.left, r.bottom), - BPoint(r.left - 1.0, r.bottom), normalDarken4); - - // bottom below popup marker - AddLine(BPoint(r.left, r.bottom), - BPoint(r.right, r.bottom), darken4); - // right of popup marker - AddLine(BPoint(r.right, r.bottom - 1), - BPoint(r.right, r.top), darken4); - // top above popup marker - AddLine(BPoint(r.left, r.top), - BPoint(r.right - 2, r.top), lighten2); - - r.top += 1; - r.bottom -= 1; - r.right -= 1; - - // bottom below popup marker - AddLine(BPoint(r.left, r.bottom), - BPoint(r.right, r.bottom), darken1); - // right of popup marker - AddLine(BPoint(r.right, r.bottom - 1), - BPoint(r.right, r.top), darken1); - EndLineArray(); - - r.bottom -= 1; - r.right -= 1; - SetHighColor(noTint); - FillRect(r); - - // popup marker - BPoint center(roundf((r.left + r.right) / 2.0), - roundf((r.top + r.bottom) / 2.0)); - BPoint triangle[3]; - triangle[0] = center + BPoint(-2.5, -0.5); - triangle[1] = center + BPoint(2.5, -0.5); - triangle[2] = center + BPoint(0.0, 2.0); - - uint32 flags = Flags(); - SetFlags(flags | B_SUBPIXEL_PRECISE); - - SetHighColor(normalDarken4); - FillTriangle(triangle[0], triangle[1], triangle[2]); - - SetFlags(flags); + _DrawItems(updateRect); } @@ -271,7 +178,6 @@ _BMCMenuBar_::FrameResized(float width, float height) dirty = Bounds(); dirty.left = dirty.right - diff - 12; Invalidate(dirty); - } else if (diff < 0) { // clean up the dirty right line of // the menu field when shrinking @@ -287,14 +193,6 @@ _BMCMenuBar_::FrameResized(float width, float height) } } - if (!fFixedSize && ResizingMode() == (B_FOLLOW_LEFT | B_FOLLOW_TOP)) { - // we have been shrinked or enlarged and need to take care - // of the size of the parent menu field as well - // NOTE: no worries about follow mode, we follow left and top - // in autosize mode - diff = Frame().right + 2 - fMenuField->Bounds().right; - fMenuField->ResizeBy(diff, 0.0); - } BMenuBar::FrameResized(width, height); } @@ -364,7 +262,7 @@ _BMCMenuBar_::MinSize() if (fShowPopUpMarker) { // account for popup indicator + a few pixels margin - size.width += 13.0; + size.width += kPopUpIndicatorWidth + kMarginWidth; } return BLayoutUtils::ComposeSize(ExplicitMinSize(), size); @@ -410,11 +308,12 @@ _BMCMenuBar_::_Init(bool setMaxContentWidth) if (be_control_look != NULL) left = right = be_control_look->DefaultLabelSpacing(); - SetItemMargins(left, top, right + fShowPopUpMarker ? 10 : 0, bottom); + SetItemMargins(left, top, + right + fShowPopUpMarker ? kPopUpIndicatorWidth + kMarginWidth : 0, + bottom); fPreviousWidth = Bounds().Width(); if (setMaxContentWidth) SetMaxContentWidth(fPreviousWidth - (left + right)); } - diff --git a/src/kits/interface/ColumnTypes.cpp b/src/kits/interface/ColumnTypes.cpp index 432476f23e..65ffb99746 100644 --- a/src/kits/interface/ColumnTypes.cpp +++ b/src/kits/interface/ColumnTypes.cpp @@ -159,6 +159,13 @@ BStringField::SetClippedString(const char* val) } +bool +BStringField::HasClippedString() const +{ + return !fClippedString.IsEmpty(); +} + + const char* BStringField::ClippedString() { @@ -182,17 +189,22 @@ BStringColumn::DrawField(BField* _field, BRect rect, BView* parent) { float width = rect.Width() - (2 * kTEXT_MARGIN); BStringField* field = static_cast(_field); - bool clipNeeded = width < field->Width(); + float fieldWidth = field->Width(); + bool updateNeeded = width != fieldWidth; - if (clipNeeded) { + if (updateNeeded) { BString out_string(field->String()); - - parent->TruncateString(&out_string, fTruncate, width + 2); - field->SetClippedString(out_string.String()); + float preferredWidth = parent->StringWidth(out_string.String()); + if (width < preferredWidth) { + parent->TruncateString(&out_string, fTruncate, width + 2); + field->SetClippedString(out_string.String()); + } else + field->SetClippedString(""); field->SetWidth(width); } - DrawString(clipNeeded ? field->ClippedString() : field->String(), parent, rect); + DrawString(field->HasClippedString() ? field->ClippedString() + : field->String(), parent, rect); } diff --git a/src/kits/interface/Menu.cpp b/src/kits/interface/Menu.cpp index e7049cf962..3b7bb02108 100644 --- a/src/kits/interface/Menu.cpp +++ b/src/kits/interface/Menu.cpp @@ -1,12 +1,13 @@ /* - * Copyright 2001-2011, Haiku Inc. All rights reserved. + * Copyright 2001-2013 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT license. * * Authors: - * Marc Flerackers (mflerackers@androme.be) - * Stefano Ceccherini (stefano.ceccherini@gmail.com) - * Rene Gollent (anevilyak@gmail.com) - * Stephan Aßmus + * Stephan Aßmus, superstippi@gmx.de + * Stefano Ceccherini, stefano.ceccherini@gmail.com + * Marc Flerackers, mflerackers@androme.be + * Rene Gollent, anevilyak@gmail.com + * John Scipione, jscipione@gmail.com */ @@ -733,7 +734,7 @@ BMenu::AddItem(BMenuItem* item, BRect frame) "be called if the menu layout is B_ITEMS_IN_MATRIX"); } - if (!item) + if (item == NULL) return false; item->fBounds = frame; @@ -758,7 +759,7 @@ bool BMenu::AddItem(BMenu* submenu) { BMenuItem* item = new (nothrow) BMenuItem(submenu); - if (!item) + if (item == NULL) return false; if (!AddItem(item, CountItems())) { @@ -780,7 +781,7 @@ BMenu::AddItem(BMenu* submenu, int32 index) } BMenuItem* item = new (nothrow) BMenuItem(submenu); - if (!item) + if (item == NULL) return false; if (!AddItem(item, index)) { @@ -802,7 +803,7 @@ BMenu::AddItem(BMenu* submenu, BRect frame) } BMenuItem* item = new (nothrow) BMenuItem(submenu); - if (!item) + if (item == NULL) return false; if (!AddItem(item, frame)) { @@ -2848,7 +2849,8 @@ BMenu::_UpdateWindowViewSize(const bool &move) return; bool scroll = false; - const BPoint screenLocation = move ? ScreenLocation() : window->Frame().LeftTop(); + const BPoint screenLocation = move ? ScreenLocation() + : window->Frame().LeftTop(); BRect frame = _CalcFrame(screenLocation, &scroll); ResizeTo(frame.Width(), frame.Height()); @@ -3024,4 +3026,3 @@ B_IF_GCC_2(InvalidateLayout__5BMenub,_ZN5BMenu16InvalidateLayoutEb)( { menu->InvalidateLayout(); } - diff --git a/src/kits/interface/MenuBar.cpp b/src/kits/interface/MenuBar.cpp index b582d87087..987f355404 100644 --- a/src/kits/interface/MenuBar.cpp +++ b/src/kits/interface/MenuBar.cpp @@ -279,44 +279,14 @@ BMenuBar::Draw(BRect updateRect) return; } - if (be_control_look != NULL) { - BRect rect(Bounds()); - rgb_color base = LowColor(); - uint32 flags = 0; + BRect rect(Bounds()); + rgb_color base = LowColor(); + uint32 flags = 0; - be_control_look->DrawBorder(this, rect, updateRect, base, - B_PLAIN_BORDER, flags, BControlLook::B_BOTTOM_BORDER); + be_control_look->DrawBorder(this, rect, updateRect, base, + B_PLAIN_BORDER, flags, BControlLook::B_BOTTOM_BORDER); - be_control_look->DrawMenuBarBackground(this, rect, updateRect, base); - - _DrawItems(updateRect); - return; - } - - // TODO: implement additional border styles - rgb_color color = HighColor(); - - BRect bounds(Bounds()); - // Restore the background of the previously selected menuitem - DrawBackground(bounds & updateRect); - - rgb_color noTint = LowColor(); - - SetHighColor(tint_color(noTint, B_LIGHTEN_2_TINT)); - StrokeLine(BPoint(0.0f, bounds.bottom - 2.0f), BPoint(0.0f, 0.0f)); - StrokeLine(BPoint(bounds.right, 0.0f)); - - SetHighColor(tint_color(noTint, B_DARKEN_1_TINT)); - StrokeLine(BPoint(1.0f, bounds.bottom - 1.0f), - BPoint(bounds.right, bounds.bottom - 1.0f)); - - SetHighColor(tint_color(noTint, B_DARKEN_2_TINT)); - StrokeLine(BPoint(0.0f, bounds.bottom), - BPoint(bounds.right, bounds.bottom)); - StrokeLine(BPoint(bounds.right, 0.0f), BPoint(bounds.right, bounds.bottom)); - - SetHighColor(color); - // revert to previous used color (cheap PushState()/PopState()) + be_control_look->DrawMenuBarBackground(this, rect, updateRect, base); _DrawItems(updateRect); } diff --git a/src/kits/interface/MenuField.cpp b/src/kits/interface/MenuField.cpp index 31aacbdb4f..cdfe7477f7 100644 --- a/src/kits/interface/MenuField.cpp +++ b/src/kits/interface/MenuField.cpp @@ -11,6 +11,7 @@ #include +#include #include #include @@ -134,9 +135,9 @@ static float kVMargin = 2.0f; BMenuField::BMenuField(BRect frame, const char* name, const char* label, - BMenu* menu, uint32 resize, uint32 flags) + BMenu* menu, uint32 resizingMode, uint32 flags) : - BView(frame, name, resize, flags) + BView(frame, name, resizingMode, flags) { CALLED(); @@ -152,9 +153,9 @@ BMenuField::BMenuField(BRect frame, const char* name, const char* label, BMenuField::BMenuField(BRect frame, const char* name, const char* label, - BMenu* menu, bool fixedSize, uint32 resize, uint32 flags) + BMenu* menu, bool fixedSize, uint32 resizingMode, uint32 flags) : - BView(frame, name, resize, flags) + BView(frame, name, resizingMode, flags) { InitObject(label); @@ -168,7 +169,7 @@ BMenuField::BMenuField(BRect frame, const char* name, const char* label, BMenuField::BMenuField(const char* name, const char* label, BMenu* menu, - uint32 flags) + uint32 flags) : BView(name, flags | B_FRAME_EVENTS) { @@ -353,24 +354,21 @@ BMenuField::AllUnarchived(const BMessage* from) void -BMenuField::Draw(BRect update) +BMenuField::Draw(BRect updateRect) { - BRect bounds(Bounds()); - bool active = IsFocus() && Window()->IsActive(); + DrawLabel(updateRect); - DrawLabel(bounds, update); - - BRect frame(fMenuBar->Frame()); - - frame.InsetBy(-kVMargin, -kVMargin); + BRect rect(fMenuBar->Frame()); + rect.InsetBy(-kVMargin, -kVMargin); rgb_color base = fMenuBar->LowColor(); rgb_color background = LowColor(); uint32 flags = 0; if (!fMenuBar->IsEnabled()) flags |= BControlLook::B_DISABLED; - if (active) + if (IsFocus() && Window()->IsActive()) flags |= BControlLook::B_FOCUSED; - be_control_look->DrawMenuFieldFrame(this, frame, update, base, + + be_control_look->DrawMenuFieldFrame(this, rect, updateRect, base, background, flags); } @@ -423,7 +421,7 @@ BMenuField::MouseDown(BPoint where) fMenuBar->StartMenuBar(-1, false, true, &bounds); fMenuTaskID = spawn_thread((thread_func)_thread_entry, - "_m_task_", B_NORMAL_PRIORITY, this); + "_m_task_", B_NORMAL_PRIORITY, this); if (fMenuTaskID >= 0) resume_thread(fMenuTaskID); } @@ -473,9 +471,9 @@ BMenuField::MakeFocus(bool state) void -BMenuField::MessageReceived(BMessage* msg) +BMenuField::MessageReceived(BMessage* message) { - BView::MessageReceived(msg); + BView::MessageReceived(message); } @@ -625,18 +623,18 @@ BMenuField::Alignment() const void -BMenuField::SetDivider(float divider) +BMenuField::SetDivider(float position) { - divider = floorf(divider + 0.5); + position = floorf(position + 0.5); - float dx = fDivider - divider; + float delta = fDivider - position; - if (dx == 0.0f) + if (delta == 0.0f) return; - fDivider = divider; + fDivider = position; - if (Flags() & B_SUPPORTS_LAYOUT) { + if ((Flags() & B_SUPPORTS_LAYOUT) != 0) { // We should never get here, since layout support means, we also // layout the divider, and don't use this method at all. Relayout(); @@ -881,7 +879,7 @@ void BMenuField::DoLayout() { // Bail out, if we shan't do layout. - if (!(Flags() & B_SUPPORTS_LAYOUT)) + if ((Flags() & B_SUPPORTS_LAYOUT) == 0) return; CALLED(); @@ -955,7 +953,7 @@ BMenuField::InitObject(const char* label) SetLabel(label); if (label) - fDivider = (float)floor(Frame().Width() / 2.0f); + fDivider = floorf(Frame().Width() / 2.0f); else fDivider = 0; } @@ -980,42 +978,44 @@ BMenuField::InitObject2() void -BMenuField::DrawLabel(BRect bounds, BRect update) +BMenuField::DrawLabel(BRect updateRect) { CALLED(); _ValidateLayoutData(); font_height& fh = fLayoutData->font_info; - if (Label()) { - SetLowColor(ViewColor()); + const char* label = Label(); + if (label == NULL) + return; - // horizontal alignment - float x; - switch (fAlign) { - case B_ALIGN_RIGHT: - x = fDivider - fLayoutData->label_width - 3.0; - break; + SetLowColor(ViewColor()); - case B_ALIGN_CENTER: - x = fDivider - fLayoutData->label_width / 2.0; - break; + // horizontal alignment + float x; + switch (fAlign) { + case B_ALIGN_RIGHT: + x = fDivider - fLayoutData->label_width - 3.0; + break; - default: - x = 0.0; - break; - } + case B_ALIGN_CENTER: + x = fDivider - fLayoutData->label_width / 2.0; + break; - // vertical alignment - float y = Bounds().top - + (Bounds().Height() + 1 - fh.ascent - fh.descent) / 2 - + fh.ascent; - y = floor(y + 0.5); - - SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), - IsEnabled() ? B_DARKEN_MAX_TINT : B_DISABLED_LABEL_TINT)); - DrawString(Label(), BPoint(x, y)); + default: + x = 0.0; + break; } + + // vertical alignment + float y = Bounds().top + + (Bounds().Height() + 1 - fh.ascent - fh.descent) / 2 + + fh.ascent; + y = floor(y + 0.5); + + SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), + IsEnabled() ? B_DARKEN_MAX_TINT : B_DISABLED_LABEL_TINT)); + DrawString(label, BPoint(x, y)); } @@ -1107,8 +1107,8 @@ BMenuField::_InitMenuBar(BMenu* menu, BRect frame, bool fixedSize) fMenu = menu; InitMenu(menu); - if ((Flags() & B_SUPPORTS_LAYOUT)) { - fMenuBar = new _BMCMenuBar_(fixedSize, this); + if ((Flags() & B_SUPPORTS_LAYOUT) != 0) { + fMenuBar = new _BMCMenuBar_(this); } else { frame.left = _MenuBarOffset(); frame.top = kVMargin; @@ -1134,7 +1134,6 @@ BMenuField::_InitMenuBar(BMenu* menu, BRect frame, bool fixedSize) AddChild(fMenuBar); fMenuBar->AddItem(menu); - fMenuBar->SetFont(be_plain_font); } @@ -1147,7 +1146,7 @@ BMenuField::_InitMenuBar(const BMessage* archive) fFixedSizeMB = fixed; fMenuBar = (BMenuBar*)FindView("_mc_mb_"); - if (!fMenuBar) { + if (fMenuBar == NULL) { _InitMenuBar(new BMenu(""), BRect(0, 0, 100, 15), fFixedSizeMB); InitObject2(); } else { @@ -1194,8 +1193,8 @@ BMenuField::_ValidateLayoutData() divider = fLayoutData->label_width + 5; // If we shan't do real layout, we let the current divider take influence. - if (!(Flags() & B_SUPPORTS_LAYOUT)) - divider = max_c(divider, fDivider); + if ((Flags() & B_SUPPORTS_LAYOUT) == 0) + divider = std::max(divider, fDivider); // get the minimal (== preferred) menu bar size // TODO: BMenu::MinSize() is using the ResizeMode() to decide the @@ -1228,7 +1227,7 @@ BMenuField::_ValidateLayoutData() float BMenuField::_MenuBarOffset() const { - return max_c(kVMargin, fDivider + kVMargin); + return std::max(fDivider + kVMargin, kVMargin); } diff --git a/src/kits/interface/MenuItem.cpp b/src/kits/interface/MenuItem.cpp index 98f5e005f2..4e5691b2ab 100644 --- a/src/kits/interface/MenuItem.cpp +++ b/src/kits/interface/MenuItem.cpp @@ -1,12 +1,13 @@ /* - * Copyright 2001-2008, Haiku, Inc. + * Copyright 2001-2013 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: - * Marc Flerackers (mflerackers@androme.be) - * Bill Hayden (haydentech@users.sourceforge.net) - * Stefano Ceccherini (stefano.ceccherini@gmail.com) + * Stefano Ceccherini, stefano.ceccherini@gmail.com + * Marc Flerackers, mflerackers@androme.be + * Bill Hayden, haydentech@users.sourceforge.net * Olivier Milla + * John Scipione, jscipione@gmail.com */ //! Display item for BMenu class @@ -55,8 +56,8 @@ const char *kUTF8ControlMap[] = { using BPrivate::MenuPrivate; -BMenuItem::BMenuItem(const char *label, BMessage *message, char shortcut, - uint32 modifiers) +BMenuItem::BMenuItem(const char* label, BMessage* message, char shortcut, + uint32 modifiers) { _InitData(); if (label != NULL) @@ -73,7 +74,7 @@ BMenuItem::BMenuItem(const char *label, BMessage *message, char shortcut, } -BMenuItem::BMenuItem(BMenu *menu, BMessage *message) +BMenuItem::BMenuItem(BMenu* menu, BMessage* message) { _InitData(); SetMessage(message); @@ -81,7 +82,7 @@ BMenuItem::BMenuItem(BMenu *menu, BMessage *message) } -BMenuItem::BMenuItem(BMessage *data) +BMenuItem::BMenuItem(BMessage* data) { _InitData(); @@ -121,9 +122,9 @@ BMenuItem::BMenuItem(BMessage *data) BMessage subMessage; if (data->FindMessage("_submenu", &subMessage) == B_OK) { - BArchivable *object = instantiate_object(&subMessage); + BArchivable* object = instantiate_object(&subMessage); if (object != NULL) { - BMenu *menu = dynamic_cast(object); + BMenu* menu = dynamic_cast(object); if (menu != NULL) _InitMenuData(menu); } @@ -131,8 +132,8 @@ BMenuItem::BMenuItem(BMessage *data) } -BArchivable * -BMenuItem::Instantiate(BMessage *data) +BArchivable* +BMenuItem::Instantiate(BMessage* data) { if (validate_instantiation(data, "BMenuItem")) return new BMenuItem(data); @@ -142,7 +143,7 @@ BMenuItem::Instantiate(BMessage *data) status_t -BMenuItem::Archive(BMessage *data, bool deep) const +BMenuItem::Archive(BMessage* data, bool deep) const { status_t ret = BArchivable::Archive(data, deep); @@ -217,7 +218,7 @@ BMenuItem::SetEnabled(bool state) if (fSubmenu != NULL) fSubmenu->SetEnabled(state); - BMenu *menu = Menu(); + BMenu* menu = fSuper; if (menu != NULL && menu->LockLooper()) { menu->Invalidate(fBounds); menu->UnlockLooper(); @@ -230,8 +231,8 @@ BMenuItem::SetMarked(bool state) { fMark = state; - if (state && Menu() != NULL) { - MenuPrivate priv(Menu()); + if (state && fSuper != NULL) { + MenuPrivate priv(fSuper); priv.ItemMarked(this); } } @@ -292,7 +293,7 @@ BMenuItem::SetShortcut(char ch, uint32 modifiers) } -const char * +const char* BMenuItem::Label() const { return fLabel; @@ -308,7 +309,7 @@ BMenuItem::IsEnabled() const if (!fEnabled) return false; - return fSuper ? fSuper->IsEnabled() : true; + return fSuper != NULL ? fSuper->IsEnabled() : true; } @@ -327,7 +328,7 @@ BMenuItem::Trigger() const char -BMenuItem::Shortcut(uint32 *modifiers) const +BMenuItem::Shortcut(uint32* modifiers) const { if (modifiers) *modifiers = fModifiers; @@ -336,14 +337,14 @@ BMenuItem::Shortcut(uint32 *modifiers) const } -BMenu * +BMenu* BMenuItem::Submenu() const { return fSubmenu; } -BMenu * +BMenu* BMenuItem::Menu() const { return fSuper; @@ -358,7 +359,7 @@ BMenuItem::Frame() const void -BMenuItem::GetContentSize(float *width, float *height) +BMenuItem::GetContentSize(float* width, float* height) { // TODO: Get rid of this. BMenu should handle this // automatically. Maybe it's not even needed, since our @@ -369,14 +370,13 @@ BMenuItem::GetContentSize(float *width, float *height) if (width) *width = (float)ceil(fCachedWidth); - if (height) { + if (height) *height = MenuPrivate(fSuper).FontHeight(); - } } void -BMenuItem::TruncateLabel(float maxWidth, char *newLabel) +BMenuItem::TruncateLabel(float maxWidth, char* newLabel) { BFont font; fSuper->GetFont(&font); @@ -399,23 +399,20 @@ BMenuItem::DrawContent() fSuper->MovePenBy(0, menuPrivate.Ascent()); BPoint lineStart = fSuper->PenLocation(); - float labelWidth, labelHeight; - GetContentSize(&labelWidth, &labelHeight); - fSuper->SetDrawingMode(B_OP_OVER); - float frameWidth = fBounds.Width(); - if (menuPrivate.State() == MENU_STATE_CLOSED) { - float rightMargin, leftMargin; - menuPrivate.GetItemMargins(&leftMargin, NULL, &rightMargin, NULL); - frameWidth = fSuper->Frame().Width() - (rightMargin + leftMargin); - } + float labelWidth; + float labelHeight; + GetContentSize(&labelWidth, &labelHeight); - // truncate if needed - if (frameWidth >= labelWidth) + const BRect& padding = menuPrivate.Padding(); + float frameWidth = fSuper->Frame().Width() - padding.left - padding.right; + + if (roundf(frameWidth) >= roundf(labelWidth)) fSuper->DrawString(fLabel); else { - char *truncatedLabel = new char[strlen(fLabel) + 4]; + // truncate label to fit + char* truncatedLabel = new char[strlen(fLabel) + 4]; TruncateLabel(frameWidth, truncatedLabel); fSuper->DrawString(truncatedLabel); delete[] truncatedLabel; @@ -451,18 +448,12 @@ BMenuItem::Draw() bool selected = IsSelected(); // set low color and fill background if selected - bool activated = selected && (enabled || Submenu()) - /*&& fSuper->fRedrawAfterSticky*/; + bool activated = selected && (enabled || Submenu()); if (activated) { - if (be_control_look != NULL) { - BRect rect = Frame(); - be_control_look->DrawMenuItemBackground(fSuper, rect, rect, - ui_color(B_MENU_SELECTED_BACKGROUND_COLOR), - BControlLook::B_ACTIVATED); - } else { - fSuper->SetLowColor(ui_color(B_MENU_SELECTED_BACKGROUND_COLOR)); - fSuper->FillRect(Frame(), B_SOLID_LOW); - } + BRect rect = Frame(); + be_control_look->DrawMenuItemBackground(fSuper, rect, rect, + ui_color(B_MENU_SELECTED_BACKGROUND_COLOR), + BControlLook::B_ACTIVATED); } // set high color @@ -499,7 +490,7 @@ BMenuItem::Draw() void BMenuItem::Highlight(bool flag) { - Menu()->Invalidate(Frame()); + fSuper->Invalidate(Frame()); } @@ -513,10 +504,9 @@ BMenuItem::IsSelected() const BPoint BMenuItem::ContentLocation() const { - const BRect &padding = MenuPrivate(fSuper).Padding(); + const BRect& padding = MenuPrivate(fSuper).Padding(); - return BPoint(fBounds.left + padding.left, - fBounds.top + padding.top); + return BPoint(fBounds.left + padding.left, fBounds.top + padding.top); } @@ -531,7 +521,7 @@ BMenuItem::BMenuItem(const BMenuItem &) } -BMenuItem & +BMenuItem& BMenuItem::operator=(const BMenuItem &) { return *this; @@ -558,13 +548,13 @@ BMenuItem::_InitData() void -BMenuItem::_InitMenuData(BMenu *menu) +BMenuItem::_InitMenuData(BMenu* menu) { fSubmenu = menu; MenuPrivate(fSubmenu).SetSuperItem(this); - BMenuItem *item = menu->FindMarked(); + BMenuItem* item = menu->FindMarked(); if (menu->IsRadioMode() && menu->IsLabelFromMarked() && item != NULL) SetLabel(item->Label()); @@ -574,11 +564,10 @@ BMenuItem::_InitMenuData(BMenu *menu) void -BMenuItem::Install(BWindow *window) +BMenuItem::Install(BWindow* window) { - if (fSubmenu) { + if (fSubmenu != NULL) MenuPrivate(fSubmenu).Install(window); - } fWindow = window; @@ -591,7 +580,7 @@ BMenuItem::Install(BWindow *window) status_t -BMenuItem::Invoke(BMessage *message) +BMenuItem::Invoke(BMessage* message) { if (!IsEnabled()) return B_ERROR; @@ -605,21 +594,21 @@ BMenuItem::Invoke(BMessage *message) BMessage clone(kind); status_t err = B_BAD_VALUE; - if (!message && !notify) + if (message == NULL && !notify) message = Message(); - if (!message) { + if (message == NULL) { if (!fSuper->IsWatched()) return err; } else clone = *message; - clone.AddInt32("index", Menu()->IndexOf(this)); + clone.AddInt32("index", fSuper->IndexOf(this)); clone.AddInt64("when", (int64)system_time()); clone.AddPointer("source", this); clone.AddMessenger("be:sender", BMessenger(fSuper)); - if (message) + if (message != NULL) err = BInvoker::Invoke(&clone); // TODO: assynchronous messaging @@ -632,31 +621,32 @@ BMenuItem::Invoke(BMessage *message) void BMenuItem::Uninstall() { - if (fSubmenu != NULL) { + if (fSubmenu != NULL) MenuPrivate(fSubmenu).Uninstall(); - } if (Target() == fWindow) SetTarget(BMessenger()); if (fShortcutChar != 0 && (fModifiers & B_COMMAND_KEY) != 0 - && fWindow != NULL) + && fWindow != NULL) { fWindow->RemoveShortcut(fShortcutChar, fModifiers); + } fWindow = NULL; } void -BMenuItem::SetSuper(BMenu *super) +BMenuItem::SetSuper(BMenu* super) { - if (fSuper != NULL && super != NULL) - debugger("Error - can't add menu or menu item to more than 1 container (either menu or menubar)."); - - if (fSubmenu != NULL) { - MenuPrivate(fSubmenu).SetSuper(super); + if (fSuper != NULL && super != NULL) { + debugger("Error - can't add menu or menu item to more than 1 container" + " (either menu or menubar)."); } + if (fSubmenu != NULL) + MenuPrivate(fSubmenu).SetSuper(super); + fSuper = super; } @@ -667,7 +657,7 @@ BMenuItem::Select(bool selected) if (fSelected == selected) return; - if (Submenu() || IsEnabled()) { + if (Submenu() != NULL || IsEnabled()) { fSelected = selected; Highlight(selected); } @@ -716,7 +706,7 @@ BMenuItem::_DrawMarkSymbol() void BMenuItem::_DrawShortcutSymbol() { - BMenu *menu = Menu(); + BMenu* menu = fSuper; BFont font; menu->GetFont(&font); BPoint where = ContentLocation(); diff --git a/src/kits/interface/MenuPrivate.cpp b/src/kits/interface/MenuPrivate.cpp index 41303e6277..7e2d80f53d 100644 --- a/src/kits/interface/MenuPrivate.cpp +++ b/src/kits/interface/MenuPrivate.cpp @@ -97,7 +97,7 @@ BBitmap* MenuPrivate::sMenuItemAlt; BBitmap* MenuPrivate::sMenuItemMenu; -MenuPrivate::MenuPrivate(BMenu *menu) +MenuPrivate::MenuPrivate(BMenu* menu) : fMenu(menu) { @@ -147,22 +147,22 @@ MenuPrivate::Padding() const void -MenuPrivate::GetItemMargins(float *left, float *top, - float *right, float *bottom) const +MenuPrivate::GetItemMargins(float* left, float* top, float* right, + float* bottom) const { fMenu->GetItemMargins(left, top, right, bottom); } int -MenuPrivate::State(BMenuItem **item) const +MenuPrivate::State(BMenuItem** item) const { return fMenu->_State(item); } void -MenuPrivate::Install(BWindow *window) +MenuPrivate::Install(BWindow* window) { fMenu->_Install(window); } @@ -176,21 +176,21 @@ MenuPrivate::Uninstall() void -MenuPrivate::SetSuper(BMenu *menu) +MenuPrivate::SetSuper(BMenu* menu) { fMenu->fSuper = menu; } void -MenuPrivate::SetSuperItem(BMenuItem *item) +MenuPrivate::SetSuperItem(BMenuItem* item) { fMenu->fSuperitem = item; } void -MenuPrivate::InvokeItem(BMenuItem *item, bool now) +MenuPrivate::InvokeItem(BMenuItem* item, bool now) { fMenu->_InvokeItem(item, now); } diff --git a/src/kits/mail/MailAttachment.cpp b/src/kits/mail/MailAttachment.cpp index 057427e2cc..be734bfb56 100644 --- a/src/kits/mail/MailAttachment.cpp +++ b/src/kits/mail/MailAttachment.cpp @@ -320,7 +320,7 @@ BSimpleMailAttachment::SetToRFC822(BPositionIO *data, size_t length, BMailComponent::SetToRFC822(data, length, parseNow); // this actually happens... - if (data->Position() - position > length) + if (data->Position() - position > (off_t)length) return B_ERROR; length -= (data->Position() - position); @@ -519,8 +519,8 @@ BAttributedMailAttachment::SetTo(BFile *file, bool deleteFileWhenDone) // Also, we have the make up the boundary out of whole cloth // This is likely to give a completely random string BString boundary; - boundary << "BFile--" << (int32(file) ^ time(NULL)) << "-" - << ~((int32)file ^ (int32)&fStatus ^ (int32)&_attributes) << "--"; + boundary << "BFile--" << ((long)file ^ time(NULL)) << "-" + << ~((long)file ^ (long)&fStatus ^ (long)&_attributes) << "--"; fContainer->SetBoundary(boundary.String()); return fStatus = B_OK; @@ -558,8 +558,8 @@ BAttributedMailAttachment::SetTo(entry_ref *ref) buffer[i] = '_'; } buffer[32] = '\0'; - boundary << "BFile-" << buffer << "--" << ((int32)_data ^ time(NULL)) - << "-" << ~((int32)_data ^ (int32)&buffer ^ (int32)&_attributes) + boundary << "BFile-" << buffer << "--" << ((long)_data ^ time(NULL)) + << "-" << ~((long)_data ^ (long)&buffer ^ (long)&_attributes) << "--"; fContainer->SetBoundary(boundary.String()); diff --git a/src/kits/mail/MailContainer.cpp b/src/kits/mail/MailContainer.cpp index a348b41769..97f07ebadb 100644 --- a/src/kits/mail/MailContainer.cpp +++ b/src/kits/mail/MailContainer.cpp @@ -425,8 +425,10 @@ status_t BMIMEMultipartMailContainer::RenderToRFC822(BPositionIO *render_to) { ssize_t amountWritten, length; message_part *part = (message_part *)_components_in_raw.ItemAt(i); - for (off_t begin = part->start; begin < part->end; begin += sizeof(buffer)) { - length = ((part->end - begin) >= sizeof(buffer)) ? sizeof(buffer) : (part->end - begin); + for (off_t begin = part->start; begin < part->end; + begin += sizeof(buffer)) { + length = (((off_t)part->end - begin) >= (off_t)sizeof(buffer)) + ? sizeof(buffer) : (part->end - begin); _io_data->ReadAt(begin,buffer,length); amountWritten = render_to->Write(buffer,length); diff --git a/src/kits/mail/MailMessage.cpp b/src/kits/mail/MailMessage.cpp index e91139f5b7..abf7de28b1 100644 --- a/src/kits/mail/MailMessage.cpp +++ b/src/kits/mail/MailMessage.cpp @@ -122,7 +122,7 @@ BEmailMessage::ReplyMessage(mail_reply_to_mode replyTo, bool accountFromMail, BString cc; for (int32 i = list.CountItems(); i-- > 0;) { - char *address = (char *)list.RemoveItem(0L); + char *address = (char *)list.RemoveItem((int32)0); // add everything which is not the sender and not already in the list if (sender.ICompare(address) && cc.FindFirst(address) < 0) { @@ -731,7 +731,7 @@ BEmailMessage::RenderToRFC822(BPositionIO *file) BString recipients; for (int32 i = recipientList.CountItems(); i-- > 0;) { - char *address = (char *)recipientList.RemoveItem(0L); + char *address = (char *)recipientList.RemoveItem((int32)0); recipients << '<' << address << '>'; if (i) diff --git a/src/kits/mail/mail_util.cpp b/src/kits/mail/mail_util.cpp index 8d8c86e0a2..e7ea0a6cd6 100644 --- a/src/kits/mail/mail_util.cpp +++ b/src/kits/mail/mail_util.cpp @@ -681,7 +681,7 @@ utf8_to_rfc2047 (char **bufp, ssize_t length, uint32 charset, char encoding) } } - while ((currentWord = (struct word *)words.RemoveItem(0L)) != NULL) { + while ((currentWord = (struct word *)words.RemoveItem((int32)0)) != NULL) { if ((encoding != quoted_printable && encoding != base64) || !currentWord->needsEncoding) { rfc2047.Append (currentWord->convertedWord); diff --git a/src/kits/media/MediaNode.cpp b/src/kits/media/MediaNode.cpp index beb41e24fb..c4c67fc96a 100644 --- a/src/kits/media/MediaNode.cpp +++ b/src/kits/media/MediaNode.cpp @@ -364,13 +364,23 @@ BMediaNode::WaitForMessage(bigtime_t waitUntil, char data[B_MEDIA_MESSAGE_SIZE]; // about 16 KByte stack used int32 message; - ssize_t size = read_port_etc(ControlPort(), &message, data, sizeof(data), - B_ABSOLUTE_TIMEOUT, waitUntil); - if (size < 0) { + ssize_t size; + while (true) { + size = read_port_etc(ControlPort(), &message, data, + sizeof(data), B_ABSOLUTE_TIMEOUT, waitUntil); + + if (size >= 0) + break; + status_t error = (status_t)size; - if (error != B_TIMED_OUT && error != B_BAD_PORT_ID) + if (error == B_INTERRUPTED) + continue; + + if (error != B_TIMED_OUT && error != B_BAD_PORT_ID) { ERROR("BMediaNode::WaitForMessage: read_port_etc error: %s\n", strerror(error)); + } + return error; } diff --git a/src/kits/midi/MidiText.cpp b/src/kits/midi/MidiText.cpp index 2ce838f779..c3f5037aaa 100644 --- a/src/kits/midi/MidiText.cpp +++ b/src/kits/midi/MidiText.cpp @@ -164,6 +164,6 @@ BMidiText::_WaitAndPrint(uint32 time) SnoozeUntil(time); - printf("%lu: ", time - fStartTime); + printf("%" B_PRIu32 ": ", time - fStartTime); } diff --git a/src/kits/shared/AboutWindow.cpp b/src/kits/shared/AboutWindow.cpp index 0b81b02dce..2d66bfcebf 100644 --- a/src/kits/shared/AboutWindow.cpp +++ b/src/kits/shared/AboutWindow.cpp @@ -176,6 +176,7 @@ AboutView::AboutView(const char* appName, const char* signature) fInfoView->SetInsets(5.0, 5.0, 5.0, 5.0); fInfoView->SetViewColor(ui_color(B_DOCUMENT_BACKGROUND_COLOR)); fInfoView->SetHighColor(ui_color(B_DOCUMENT_TEXT_COLOR)); + fInfoView->SetStylable(true); BScrollView* infoViewScroller = new BScrollView( "infoViewScroller", fInfoView, B_WILL_DRAW | B_FRAME_EVENTS, @@ -435,16 +436,7 @@ BAboutWindow::AddDescription(const char* description) if (description == NULL) return; - const char* appDesc = B_TRANSLATE_MARK(description); - appDesc = gSystemCatalog.GetString(appDesc, "AboutWindow"); - - BString desc(""); - if (fAboutView->InfoView()->TextLength() > 0) - desc << "\n\n"; - - desc << appDesc; - - fAboutView->InfoView()->Insert(desc.String()); + AddText(description); } @@ -501,16 +493,7 @@ BAboutWindow::AddAuthors(const char** authors) const char* writtenBy = B_TRANSLATE_MARK("Written by:"); writtenBy = gSystemCatalog.GetString(writtenBy, "AboutWindow"); - BString text(""); - if (fAboutView->InfoView()->TextLength() > 0) - text << "\n\n"; - - text << writtenBy; - text << "\n"; - for (int32 i = 0; authors[i]; i++) - text << " " << authors[i] << "\n"; - - fAboutView->InfoView()->Insert(text.String()); + AddText(writtenBy, authors); } @@ -523,15 +506,7 @@ BAboutWindow::AddSpecialThanks(const char** thanks) const char* specialThanks = B_TRANSLATE_MARK("Special Thanks:"); specialThanks = gSystemCatalog.GetString(specialThanks, "AboutWindow"); - BString text(""); - if (fAboutView->InfoView()->TextLength() > 0) - text << "\n\n"; - - text << specialThanks << "\n"; - for (int32 i = 0; thanks[i]; i++) - text << " " << thanks[i] << "\n"; - - fAboutView->InfoView()->Insert(text.String()); + AddText(specialThanks, thanks); } @@ -544,15 +519,7 @@ BAboutWindow::AddVersionHistory(const char** history) const char* versionHistory = B_TRANSLATE_MARK("Version history:"); versionHistory = gSystemCatalog.GetString(versionHistory, "AboutWindow"); - BString text(""); - if (fAboutView->InfoView()->TextLength() > 0) - text << "\n\n"; - - text << versionHistory << "\n"; - for (int32 i = 0; history[i]; i++) - text << " " << history[i] << "\n"; - - fAboutView->InfoView()->Insert(text.String()); + AddText(versionHistory, history); } @@ -575,6 +542,39 @@ BAboutWindow::AddExtraInfo(const char* extraInfo) } +void +BAboutWindow::AddText(const char* header, const char** contents) +{ + BTextView* infoView = fAboutView->InfoView(); + int32 textLength = infoView->TextLength(); + BString text(""); + + if (textLength > 0) { + text << "\n\n"; + textLength += 2; + } + + const char* indent = ""; + if (header != NULL) { + indent = " "; + text << header; + } + + if (contents != NULL) { + text << "\n"; + for (int32 i = 0; contents[i]; i++) + text << indent << contents[i] << "\n"; + } + + infoView->Insert(text.String()); + + if (contents != NULL && header != NULL) { + infoView->SetFontAndColor(textLength, textLength + strlen(header), + be_bold_font); + } +} + + const char* BAboutWindow::Name() { diff --git a/src/kits/shared/PromptWindow.cpp b/src/kits/shared/PromptWindow.cpp index 53ce2f0956..7e7715b810 100644 --- a/src/kits/shared/PromptWindow.cpp +++ b/src/kits/shared/PromptWindow.cpp @@ -30,21 +30,26 @@ PromptWindow::PromptWindow(const char* title, const char* label, BButton* acceptButton = new BButton("Accept", new BMessage(kAcceptInput)); BLayoutBuilder::Group<>(this, B_VERTICAL) + .SetInsets(B_USE_DEFAULT_SPACING) .Add(fInfoView) .Add(fTextControl) .AddGroup(B_HORIZONTAL) + .AddGlue() + .Add(cancelButton) .Add(acceptButton) - .Add(cancelButton); + .End() + .End(); if (info == NULL) fInfoView->Hide(); - fTextControl->TextView()->SetExplicitMinSize(BSize( - fTextControl->TextView()->StringWidth("1234567890"), B_SIZE_UNSET)); + fTextControl->TextView()->SetExplicitMinSize(BSize(200.0, B_SIZE_UNSET)); fTextControl->SetTarget(this); acceptButton->SetTarget(this); cancelButton->SetTarget(this); fTextControl->MakeFocus(true); + + SetDefaultButton(acceptButton); } diff --git a/src/kits/support/Url.cpp b/src/kits/support/Url.cpp index eb54f8900a..dd59207b99 100644 --- a/src/kits/support/Url.cpp +++ b/src/kits/support/Url.cpp @@ -77,7 +77,9 @@ BUrl::OpenWithPreferredApplication(bool onProblemAskUser) const // TODO: BAlert // if (onProblemAskUser) // BAlert ... Too long URL! +#if DEBUG fprintf(stderr, "URL too long"); +#endif return B_NAME_TOO_LONG; } @@ -96,7 +98,9 @@ BUrl::OpenWithPreferredApplication(bool onProblemAskUser) const status = be_roster->Launch(_UrlMimeType().String(), 1, argv+1); if (status != B_OK) { +#if DEBUG fprintf(stderr, "Opening URL failed: %s\n", strerror(status)); +#endif } return status; diff --git a/src/kits/tracker/FindPanel.cpp b/src/kits/tracker/FindPanel.cpp index f42c7ddc64..51790537eb 100644 --- a/src/kits/tracker/FindPanel.cpp +++ b/src/kits/tracker/FindPanel.cpp @@ -862,9 +862,7 @@ FindPanel::FindPanel(BFile* node, FindWindow* parent, bool fromTemplate, else AddByAttributeItems(node); - fMimeTypeField->SetExplicitSize( - BSize(be_control_look->DefaultItemSpacing() * 20, B_SIZE_UNSET)); - // ResizeMenuField() makes fMimeTypeField too wide. + ResizeMenuField(fMimeTypeField); ResizeMenuField(searchModeField); ResizeMenuField(volumeField); } @@ -972,7 +970,8 @@ FindPanel::ResizeMenuField(BMenuField* menuField) } } - size.width = width + padding; + float maxWidth = be_control_look->DefaultItemSpacing() * 20; + size.width = std::min(width + padding, maxWidth); menuField->SetExplicitSize(size); } diff --git a/src/kits/tracker/Tracker.cpp b/src/kits/tracker/Tracker.cpp index 021fff7aea..26e99b6aba 100644 --- a/src/kits/tracker/Tracker.cpp +++ b/src/kits/tracker/Tracker.cpp @@ -830,11 +830,39 @@ TTracker::RefsReceived(BMessage* message) // copy over "Poses" messenger so that refs received // recipients know where the open came from BMessage* bundleThis = NULL; + BMessage stackBundleThis; BMessenger messenger; if (message->FindMessenger("TrackerViewToken", &messenger) == B_OK) { - bundleThis = new BMessage(); + bundleThis = &stackBundleThis; bundleThis->AddMessenger("TrackerViewToken", messenger); + } else { + // copy over any "be:*" fields -- e.g. /bin/open may include + // "be:line" and "be:column" + for (int32 i = 0;; i++) { + char* name; + type_code type; + int32 count; + status_t error = message->GetInfo(B_ANY_TYPE, i, &name, + &type, &count); + if (error != B_OK) + break; + if (strncmp(name, "be:", 3) != 0) + continue; + for (int32 k = 0; k < count; k++) { + const void* data; + ssize_t size; + if (message->FindData(name, type, k, &data, &size) + != B_OK) { + break; + } + if (stackBundleThis.AddData(name, type, data, size) + != B_OK) { + break; + } + bundleThis = &stackBundleThis; + } + } } for (int32 index = 0; index < count; index++) { @@ -854,7 +882,6 @@ TTracker::RefsReceived(BMessage* message) bundleThis); } - delete bundleThis; break; } } diff --git a/src/libs/gnu/xattr.cpp b/src/libs/gnu/xattr.cpp index fadb573112..9873018ac6 100644 --- a/src/libs/gnu/xattr.cpp +++ b/src/libs/gnu/xattr.cpp @@ -43,7 +43,9 @@ struct AttributeName { // printable, just use them as the type string, otherwise convert // to hex char typeString[9]; - uint8 typeBytes[4] = { type >> 24, type >> 16, type >> 8, type }; + uint8 typeBytes[4] = { (uint8)((type >> 24) & 0xff), + (uint8)((type >> 16) & 0xff), (uint8)((type >> 8) & 0xff), + (uint8)(type & 0xff) }; if (isprint(typeBytes[0]) && isprint(typeBytes[1]) && isprint(typeBytes[2]) && isprint(typeBytes[3])) { typeString[0] = typeBytes[0]; diff --git a/src/preferences/keymap/KeyboardLayoutView.cpp b/src/preferences/keymap/KeyboardLayoutView.cpp index 82f3a31dfa..5a8fa79bc8 100644 --- a/src/preferences/keymap/KeyboardLayoutView.cpp +++ b/src/preferences/keymap/KeyboardLayoutView.cpp @@ -56,6 +56,7 @@ void KeyboardLayoutView::SetKeyboardLayout(KeyboardLayout* layout) { fLayout = layout; + _InitOffscreen(); _LayoutKeyboard(); Invalidate(); } diff --git a/src/preferences/mail/ConfigWindow.cpp b/src/preferences/mail/ConfigWindow.cpp index 8007d45bff..36d43126a9 100644 --- a/src/preferences/mail/ConfigWindow.cpp +++ b/src/preferences/mail/ConfigWindow.cpp @@ -815,15 +815,15 @@ ConfigWindow::_SetToGeneralSettings(BMailSettings *settings) int timeIndex = 0; if (interval >= 60) { timeIndex = 1; - sprintf(text, "%ld", interval / (60)); + sprintf(text, "%" B_PRIdTIME, interval / (60)); } if (interval >= (60*60)) { timeIndex = 2; - sprintf(text, "%ld", interval / (60*60)); + sprintf(text, "%" B_PRIdTIME, interval / (60*60)); } if (interval >= (60*60*24)) { timeIndex = 3; - sprintf(text, "%ld", interval / (60*60*24)); + sprintf(text, "%" B_PRIdTIME, interval / (60*60*24)); } fIntervalControl->SetText(text); diff --git a/src/preferences/mail/DNSQuery.cpp b/src/preferences/mail/DNSQuery.cpp index ee31cfd13e..4b638ea548 100644 --- a/src/preferences/mail/DNSQuery.cpp +++ b/src/preferences/mail/DNSQuery.cpp @@ -106,7 +106,7 @@ BRawNetBuffer::ReadString(BString& string) status_t BRawNetBuffer::SkipReading(off_t skip) { - if (fReadPosition + skip > fBuffer.BufferLength()) + if (fReadPosition + skip > (off_t)fBuffer.BufferLength()) return B_ERROR; fReadPosition += skip; return B_OK; @@ -125,7 +125,7 @@ BRawNetBuffer::_Init(const void* buf, size_t size) ssize_t BRawNetBuffer::_ReadStringAt(BString& string, off_t pos) { - if (pos >= fBuffer.BufferLength()) + if (pos >= (off_t)fBuffer.BufferLength()) return -1; ssize_t bytesRead = 0; @@ -133,7 +133,7 @@ BRawNetBuffer::_ReadStringAt(BString& string, off_t pos) buffer = &buffer[pos]; // if the string is compressed we have to follow the links to the // sub strings - while (pos < fBuffer.BufferLength() && *buffer != 0) { + while (pos < (off_t)fBuffer.BufferLength() && *buffer != 0) { if (uint8(*buffer) == 192) { // found a pointer mark buffer++; diff --git a/src/preferences/shortcuts/ShortcutsSpec.cpp b/src/preferences/shortcuts/ShortcutsSpec.cpp index 2fbb513b2e..d7f5ca51bc 100644 --- a/src/preferences/shortcuts/ShortcutsSpec.cpp +++ b/src/preferences/shortcuts/ShortcutsSpec.cpp @@ -488,7 +488,7 @@ ShortcutsSpec::GetCellText(int whichColumn) const if (temp == NULL) temp = ""; } else if (fKey > 0xFF) { - sprintf(fScratch, "#%lx", fKey); + sprintf(fScratch, "#%" B_PRIx32, fKey); return fScratch; } break; diff --git a/src/preferences/shortcuts/ShortcutsWindow.cpp b/src/preferences/shortcuts/ShortcutsWindow.cpp index 5a5c6785e6..dd2803937c 100644 --- a/src/preferences/shortcuts/ShortcutsWindow.cpp +++ b/src/preferences/shortcuts/ShortcutsWindow.cpp @@ -569,7 +569,8 @@ ShortcutsWindow::MessageReceived(BMessage* msg) if (fLastOpenWasAppend == false) { // Clear the menu... while (ShortcutsSpec* item - = ((ShortcutsSpec*)fColumnListView->RemoveItem(0L))) { + = ((ShortcutsSpec*) + fColumnListView->RemoveItem((int32)0))) { delete item; } } diff --git a/src/preferences/shortcuts/clv/ColumnListView.cpp b/src/preferences/shortcuts/clv/ColumnListView.cpp index b9c78192fc..bc7f496ab9 100644 --- a/src/preferences/shortcuts/clv/ColumnListView.cpp +++ b/src/preferences/shortcuts/clv/ColumnListView.cpp @@ -1255,7 +1255,7 @@ bool ColumnListView::RemoveItems(int32 fullListIndex, int32 count) CLVListItem* TheItem; if(fHierarchical) { - uint32 LastSuperItemLevel = ULONG_MAX; + uint32 LastSuperItemLevel = UINT32_MAX; int32 Counter; int32 DisplayItemsToRemove = 0; int32 FirstDisplayItemToRemove = -1; diff --git a/src/servers/app/Desktop.cpp b/src/servers/app/Desktop.cpp index 4663c0b9e3..f9e8d4553c 100644 --- a/src/servers/app/Desktop.cpp +++ b/src/servers/app/Desktop.cpp @@ -1903,12 +1903,15 @@ Desktop::SetFocusWindow(Window* nextFocus) return; } - uint32 list = fCurrentWorkspace; - if (!fSettings->NormalMouse()) - list = kFocusList; + uint32 listIndex = fCurrentWorkspace; + WindowList* list = &_Windows(fCurrentWorkspace); + if (!fSettings->NormalMouse()) { + listIndex = kFocusList; + list = &fFocusList; + } if (nextFocus == NULL || hasModal || hasWindowScreen) { - nextFocus = _Windows(list).LastWindow(); + nextFocus = list->LastWindow(); if (fSettings->NormalMouse()) { // If the last window having focus is a window that cannot make it @@ -1923,7 +1926,7 @@ Desktop::SetFocusWindow(Window* nextFocus) // make sure no window is chosen that doesn't want focus or cannot have it while (nextFocus != NULL && !_WindowCanHaveFocus(nextFocus)) { - nextFocus = nextFocus->PreviousWindow(list); + nextFocus = nextFocus->PreviousWindow(listIndex); } if (fFocus == nextFocus) { diff --git a/src/servers/bluetooth/BluetoothServer.cpp b/src/servers/bluetooth/BluetoothServer.cpp index 40da9daf1d..d5ea861934 100644 --- a/src/servers/bluetooth/BluetoothServer.cpp +++ b/src/servers/bluetooth/BluetoothServer.cpp @@ -344,7 +344,8 @@ BluetoothServer::HandleAcquireLocalDevice(BMessage* message, BMessage* reply) for (int index = lastIndex + 1; index < fLocalDevicesList.CountItems(); index++) { lDeviceImpl= fLocalDevicesList.ItemAt(index); - printf("Requesting local device %ld\n", lDeviceImpl->GetID()); + printf("Requesting local device %" B_PRId32 "\n", + lDeviceImpl->GetID()); if (lDeviceImpl != NULL && lDeviceImpl->Available()) { Output::Instance()->Postf(BLACKBOARD_KIT, "Device available: %lx\n", lDeviceImpl->GetID()); @@ -357,7 +358,8 @@ BluetoothServer::HandleAcquireLocalDevice(BMessage* message, BMessage* reply) if (lDeviceImpl == NULL) { for (int index = 0; index <= lastIndex ; index ++) { lDeviceImpl = fLocalDevicesList.ItemAt(index); - printf("Requesting local device %ld\n", lDeviceImpl->GetID()); + printf("Requesting local device %" B_PRId32 "\n", + lDeviceImpl->GetID()); if (lDeviceImpl != NULL && lDeviceImpl->Available()) { Output::Instance()->Postf(BLACKBOARD_KIT, "Device available: %lx\n", lDeviceImpl->GetID()); @@ -600,7 +602,7 @@ BluetoothServer::_InstallDeskbarIcon() status_t res = deskbar.AddItem(&appInfo.ref); if (res != B_OK) { - printf("Failed adding deskbar icon: %ld\n", res); + printf("Failed adding deskbar icon: %" B_PRId32 "\n", res); } } @@ -611,7 +613,7 @@ BluetoothServer::_RemoveDeskbarIcon() BDeskbar deskbar; status_t res = deskbar.RemoveItem(kDeskbarItemName); if (res != B_OK) { - printf("Failed removing Deskbar icon: %ld: \n", res); + printf("Failed removing Deskbar icon: %" B_PRId32 ": \n", res); } } diff --git a/src/servers/bluetooth/HCITransportAccessor.cpp b/src/servers/bluetooth/HCITransportAccessor.cpp index 2c070d6697..8e64949323 100644 --- a/src/servers/bluetooth/HCITransportAccessor.cpp +++ b/src/servers/bluetooth/HCITransportAccessor.cpp @@ -20,11 +20,11 @@ HCITransportAccessor::HCITransportAccessor(BPath* path) : HCIDelegate(path) if (fDescriptor > 0) { // find out which ID was assigned status = ioctl(fDescriptor, GET_HCI_ID, &fIdentifier, 0); - printf("%s: hid retrieved %lx status=%ld\n", __FUNCTION__, - fIdentifier, status); + printf("%s: hid retrieved %" B_PRIx32 " status=%" B_PRId32 "\n", + __FUNCTION__, fIdentifier, status); } else { - printf("%s: Device driver %s could not be opened %ld\n", __FUNCTION__, - path->Path(), fIdentifier); + printf("%s: Device driver %s could not be opened %" B_PRId32 "\n", + __FUNCTION__, path->Path(), fIdentifier); fIdentifier = B_ERROR; } diff --git a/src/servers/bluetooth/LocalDeviceHandler.cpp b/src/servers/bluetooth/LocalDeviceHandler.cpp index 8a0e7ff738..7d3936a6fe 100644 --- a/src/servers/bluetooth/LocalDeviceHandler.cpp +++ b/src/servers/bluetooth/LocalDeviceHandler.cpp @@ -93,11 +93,12 @@ LocalDeviceHandler::ClearWantedEvent(BMessage* msg, uint16 event, uint16 opcode) // for each Event while (msg->FindInt16("eventExpected", eventIndex, &eventFound) == B_OK) { - printf("%s:Event expected %d@%ld...\n", __FUNCTION__, event, eventIndex); + printf("%s:Event expected %d@%" B_PRId32 "...\n", __FUNCTION__, event, + eventIndex); if (eventFound == event) { - printf("%s:Event matches@%ld", __FUNCTION__, eventIndex); + printf("%s:Event matches@%" B_PRId32 "\n", __FUNCTION__, eventIndex); // there is an opcode specified if (opcode != 0) { diff --git a/src/servers/mail/ErrorLogWindow.cpp b/src/servers/mail/ErrorLogWindow.cpp index 0cdeddba9e..f4ddea9755 100644 --- a/src/servers/mail/ErrorLogWindow.cpp +++ b/src/servers/mail/ErrorLogWindow.cpp @@ -208,7 +208,7 @@ Error::GetPreferredSize(float *width, float *height) BTextView *view = static_cast(FindView("error_display")); *width = view->Frame().Width() + 20; - *height = view->TextHeight(0, LONG_MAX) + 3; + *height = view->TextHeight(0, INT32_MAX) + 3; } diff --git a/src/servers/media/AddOnManager.cpp b/src/servers/media/AddOnManager.cpp index 19a814e92c..28e706c256 100644 --- a/src/servers/media/AddOnManager.cpp +++ b/src/servers/media/AddOnManager.cpp @@ -119,7 +119,7 @@ AddOnManager::GetDecoderForFormat(xfer_entry_ref* _decoderRef, BAutolock locker(fLock); printf("AddOnManager::GetDecoderForFormat: searching decoder for encoding " - "%ld\n", format.Encoding()); + "%" B_PRIu32 "\n", format.Encoding()); // Since the list of decoders is unsorted, we need to search for // a decoder by add-on directory, in order to maintain the shadowing @@ -177,7 +177,7 @@ AddOnManager::GetEncoder(xfer_entry_ref* _encoderRef, int32 id) // check if the encoder matches the supplied format if (info->internalID == (uint32)id) { printf("AddOnManager::GetEncoderForFormat: found encoder %s for " - "id %ld\n", info->ref.name, id); + "id %" B_PRId32 "\n", info->ref.name, id); *_encoderRef = info->ref; return B_OK; @@ -185,7 +185,7 @@ AddOnManager::GetEncoder(xfer_entry_ref* _encoderRef, int32 id) } printf("AddOnManager::GetEncoderForFormat: failed to find encoder for id " - "%ld\n", id); + "%" B_PRId32 "\n", id); return B_ENTRY_NOT_FOUND; } @@ -200,7 +200,7 @@ AddOnManager::GetWriter(xfer_entry_ref* _ref, uint32 internalID) for (fWriterList.Rewind(); fWriterList.GetNext(&info);) { if (info->internalID == internalID) { printf("AddOnManager::GetWriter: found writer %s for " - "internal_id %lu\n", info->ref.name, internalID); + "internal_id %" B_PRId32 "\n", info->ref.name, internalID); *_ref = info->ref; return B_OK; @@ -427,7 +427,7 @@ printf("removing writer '%s'\n", writerInfo->ref.name); encoder_info* encoderInfo; for (fEncoderList.Rewind(); fEncoderList.GetNext(&encoderInfo);) { if (encoderInfo->ref == ref) { -printf("removing encoder '%s', id %lu\n", encoderInfo->ref.name, +printf("removing encoder '%s', id %" B_PRIu32 "\n", encoderInfo->ref.name, encoderInfo->internalID); fEncoderList.RemoveCurrent(); // Keep going, since we add multiple encoder infos per add-on. @@ -602,7 +602,7 @@ AddOnManager::_FindDecoder(const media_format& format, const BPath& path, continue; printf("AddOnManager::GetDecoderForFormat: found decoder %s/%s " - "for encoding %ld\n", path.Path(), info->ref.name, + "for encoding %" B_PRIu32 "\n", path.Path(), info->ref.name, decoderFormat->Encoding()); *_decoderRef = info->ref; diff --git a/src/servers/media/AppManager.cpp b/src/servers/media/AppManager.cpp index 083a871f42..589dabd0ba 100644 --- a/src/servers/media/AppManager.cpp +++ b/src/servers/media/AppManager.cpp @@ -77,9 +77,10 @@ AppManager::RegisterTeam(team_id team, const BMessenger& messenger) { BAutolock lock(this); - TRACE("AppManager::RegisterTeam %ld\n", team); + TRACE("AppManager::RegisterTeam %" B_PRId32 "\n", team); if (HasTeam(team)) { - ERROR("AppManager::RegisterTeam: team %ld already registered\n", team); + ERROR("AppManager::RegisterTeam: team %" B_PRId32 " already" + " registered\n", team); return B_ERROR; } @@ -96,7 +97,7 @@ AppManager::RegisterTeam(team_id team, const BMessenger& messenger) status_t AppManager::UnregisterTeam(team_id team) { - TRACE("AppManager::UnregisterTeam %ld\n", team); + TRACE("AppManager::UnregisterTeam %" B_PRId32 "\n", team); Lock(); bool isRemoved = fMap.erase(team) != 0; @@ -146,8 +147,9 @@ AppManager::Dump() for (; iterator != fMap.end(); iterator++) { app_info info; be_roster->GetRunningAppInfo(iterator->first, &info); - printf(" team %ld \"%s\", messenger %svalid\n", iterator->first, - info.ref.name, iterator->second.IsValid() ? "" : "NOT "); + printf(" team %" B_PRId32 " \"%s\", messenger %svalid\n", + iterator->first, info.ref.name, + iterator->second.IsValid() ? "" : "NOT "); } printf("AppManager: list end\n"); @@ -159,7 +161,7 @@ AppManager::_CleanupTeam(team_id team) { ASSERT(!IsLocked()); - TRACE("AppManager: cleaning up team %ld\n", team); + TRACE("AppManager: cleaning up team %" B_PRId32 "\n", team); gNodeManager->CleanupTeam(team); gBufferManager->CleanupTeam(team); diff --git a/src/servers/media/BufferManager.cpp b/src/servers/media/BufferManager.cpp index 2f821c30bc..2db9a55116 100644 --- a/src/servers/media/BufferManager.cpp +++ b/src/servers/media/BufferManager.cpp @@ -44,12 +44,13 @@ BufferManager::RegisterBuffer(team_id team, media_buffer_id bufferID, { BAutolock lock(fLocker); - TRACE("RegisterBuffer team = %ld, bufferid = %ld\n", team, bufferID); + TRACE("RegisterBuffer team = %" B_PRId32 ", bufferid = %" B_PRId32 "\n", + team, bufferID); buffer_info* info; if (!fBufferInfoMap.Get(bufferID, info)) { - ERROR("failed to register buffer! team = %ld, bufferid = %ld\n", team, - bufferID); + ERROR("failed to register buffer! team = %" B_PRId32 ", bufferid = %" + B_PRId32 "\n", team, bufferID); return B_ERROR; } @@ -74,8 +75,9 @@ BufferManager::RegisterBuffer(team_id team, size_t size, int32 flags, area_id clonedArea = _CloneArea(area); if (clonedArea < 0) { - ERROR("RegisterBuffer: failed to clone buffer! error = %#lx, team = " - "%ld, area = %ld, offset = %ld, size = %ld\n", clonedArea, team, + ERROR("RegisterBuffer: failed to clone buffer! error = %#" B_PRIx32 + ", team = %" B_PRId32 ", area = %" B_PRId32 ", offset = %" + B_PRIuSIZE ", size = %" B_PRIuSIZE "\n", clonedArea, team, area, offset, size); return clonedArea; } @@ -107,31 +109,32 @@ status_t BufferManager::UnregisterBuffer(team_id team, media_buffer_id bufferID) { BAutolock lock(fLocker); - TRACE("UnregisterBuffer: team = %ld, bufferID = %ld\n", team, bufferID); + TRACE("UnregisterBuffer: team = %" B_PRId32 ", bufferID = %" B_PRId32 "\n", + team, bufferID); buffer_info* info; if (!fBufferInfoMap.Get(bufferID, info)) { - ERROR("UnregisterBuffer: failed to unregister buffer! team = %ld, " - "bufferID = %ld\n", team, bufferID); + ERROR("UnregisterBuffer: failed to unregister buffer! team = %" + B_PRId32 ", bufferID = %" B_PRId32 "\n", team, bufferID); return B_ERROR; } if (info->teams.find(team) == info->teams.end()) { - ERROR("UnregisterBuffer: failed to find team = %ld belonging to " - "bufferID = %ld\n", team, bufferID); + ERROR("UnregisterBuffer: failed to find team = %" B_PRId32 " belonging" + " to bufferID = %" B_PRId32 "\n", team, bufferID); return B_ERROR; } info->teams.erase(team); - TRACE("UnregisterBuffer: team = %ld removed from bufferID = %ld\n", team, - bufferID); + TRACE("UnregisterBuffer: team = %" B_PRId32 " removed from bufferID = %" + B_PRId32 "\n", team, bufferID); if (info->teams.empty()) { _ReleaseClonedArea(info->area); fBufferInfoMap.Remove(bufferID); - TRACE("UnregisterBuffer: bufferID = %ld removed\n", bufferID); + TRACE("UnregisterBuffer: bufferID = %" B_PRId32 " removed\n", bufferID); } return B_OK; @@ -143,7 +146,7 @@ BufferManager::CleanupTeam(team_id team) { BAutolock lock(fLocker); - TRACE("BufferManager::CleanupTeam: team %ld\n", team); + TRACE("BufferManager::CleanupTeam: team %" B_PRId32 "\n", team); BufferInfoMap::Iterator iterator = fBufferInfoMap.GetIterator(); while (iterator.HasNext()) { @@ -152,8 +155,8 @@ BufferManager::CleanupTeam(team_id team) entry.value.teams.erase(team); if (entry.value.teams.empty()) { - PRINT(1, "BufferManager::CleanupTeam: removing buffer id %ld that " - "has no teams\n", entry.key.GetHashCode()); + PRINT(1, "BufferManager::CleanupTeam: removing buffer id %" + B_PRId32 " that has no teams\n", entry.key.GetHashCode()); _ReleaseClonedArea(entry.value.area); iterator.Remove(); } @@ -172,13 +175,14 @@ BufferManager::Dump() BufferInfoMap::Iterator iterator = fBufferInfoMap.GetIterator(); while (iterator.HasNext()) { buffer_info& info = *iterator.NextValue(); - printf(" buffer-id %ld, area-id %ld, offset %ld, size %ld, flags " - "%#08lx\n", info.id, info.area, info.offset, info.size, info.flags); + printf(" buffer-id %" B_PRId32 ", area-id %" B_PRId32 ", offset %ld, " + "size %ld, flags %#08" B_PRIx32 "\n", info.id, info.area, + info.offset, info.size, info.flags); printf(" assigned teams: "); std::set::iterator teamIterator = info.teams.begin(); for (; teamIterator != info.teams.end(); teamIterator++) { - printf("%ld, ", *teamIterator); + printf("%" B_PRId32 ", ", *teamIterator); } printf("\n"); } @@ -193,8 +197,8 @@ BufferManager::_CloneArea(area_id area) clone_info* info; if (fCloneInfoMap.Get(area, info)) { // we have already cloned this particular area - TRACE("BufferManager::_CloneArea() area %ld has already been " - "cloned (id %ld)\n", area, info->clone); + TRACE("BufferManager::_CloneArea() area %" B_PRId32 " has already" + " been cloned (id %" B_PRId32 ")\n", area, info->clone); info->ref_count++; return info->clone; @@ -205,8 +209,8 @@ BufferManager::_CloneArea(area_id area) area_id clonedArea = clone_area("media_server cloned buffer", &address, B_ANY_ADDRESS, B_READ_AREA | B_WRITE_AREA, area); - TRACE("BufferManager::_CloneArea() cloned area %ld, clone id %ld\n", - area, clonedArea); + TRACE("BufferManager::_CloneArea() cloned area %" B_PRId32 ", clone id %" + B_PRId32 "\n", area, clonedArea); if (clonedArea < 0) return clonedArea; @@ -235,19 +239,19 @@ BufferManager::_ReleaseClonedArea(area_id clone) clone_info* info; if (!fCloneInfoMap.Get(source, info)) { ERROR("BufferManager::_ReleaseClonedArea(): could not find clone info " - "for id %ld (clone %ld)\n", source, clone); + "for id %" B_PRId32 " (clone %" B_PRId32 ")\n", source, clone); return; } if (--info->ref_count == 0) { - TRACE("BufferManager::_ReleaseClonedArea(): delete cloned area %ld " - "(source %ld)\n", clone, source); + TRACE("BufferManager::_ReleaseClonedArea(): delete cloned area %" + B_PRId32 " (source %" B_PRId32 ")\n", clone, source); fSourceInfoMap.Remove(clone); fCloneInfoMap.Remove(source); delete_area(clone); } else { - TRACE("BufferManager::_ReleaseClonedArea(): released cloned area %ld " - "(source %ld)\n", clone, source); + TRACE("BufferManager::_ReleaseClonedArea(): released cloned area %" + B_PRId32 " (source %" B_PRId32 ")\n", clone, source); } } diff --git a/src/servers/media/FormatManager.cpp b/src/servers/media/FormatManager.cpp index fd3e48e5c8..6d0e3b3641 100644 --- a/src/servers/media/FormatManager.cpp +++ b/src/servers/media/FormatManager.cpp @@ -173,8 +173,8 @@ FormatManager::GetFormats(BMessage& message) reply.AddInt64("timestamp", system_time()); int32 count = fList.CountItems(); - printf("FormatManager::GetFormats(): put %ld formats into message\n", - count); + printf("FormatManager::GetFormats(): put %" B_PRId32 " formats into " + "message\n", count); for (int32 i = 0; i < count; i++) { meta_format* format = fList.ItemAt(i); reply.AddData("formats", MEDIA_META_FORMAT_TYPE, format, @@ -289,7 +289,7 @@ FormatManager::RemoveFormat(const media_format& format) if (metaFormat->format == format) { if (foundIndex != -1) { printf("FormatManager::RemoveFormat() - format already " - "present at previous index: %ld\n", foundIndex); + "present at previous index: %" B_PRId32 "\n", foundIndex); } foundIndex = i; } diff --git a/src/servers/media/NodeManager.cpp b/src/servers/media/NodeManager.cpp index b0f585bb2a..69e72c693d 100644 --- a/src/servers/media/NodeManager.cpp +++ b/src/servers/media/NodeManager.cpp @@ -168,9 +168,10 @@ NodeManager::RegisterNode(media_addon_id addOnID, int32 flavorID, *_nodeID = fNextNodeID++; - TRACE("NodeManager::RegisterNode: node %ld, addon_id %ld, flavor_id %ld, " - "name \"%s\", kinds %#Lx, port %ld, team %ld\n", *_nodeID, addOnID, - flavorID, name, kinds, port, team); + TRACE("NodeManager::RegisterNode: node %" B_PRId32 ", addon_id %" B_PRId32 + ", flavor_id %" B_PRId32 ", name \"%s\", kinds %#Lx, port %" B_PRId32 + ", team %" B_PRId32 "\n", *_nodeID, addOnID, flavorID, name, kinds, + port, team); return B_OK; } @@ -179,28 +180,30 @@ status_t NodeManager::UnregisterNode(media_node_id id, team_id team, media_addon_id* _addOnID, int32* _flavorID) { - TRACE("NodeManager::UnregisterNode enter: node %ld, team %ld\n", id, team); + TRACE("NodeManager::UnregisterNode enter: node %" B_PRId32 ", team %" + B_PRId32 "\n", id, team); BAutolock _(this); NodeMap::iterator found = fNodeMap.find(id); if (found == fNodeMap.end()) { - ERROR("NodeManager::UnregisterNode: couldn't find node %ld (team " - "%ld)\n", id, team); + ERROR("NodeManager::UnregisterNode: couldn't find node %" B_PRId32 + " (team %" B_PRId32 ")\n", id, team); return B_ERROR; } registered_node& node = found->second; if (node.containing_team != team) { - ERROR("NodeManager::UnregisterNode: team %ld tried to unregister " - "node %ld, but it was instantiated by team %ld\n", team, id, - node.containing_team); + ERROR("NodeManager::UnregisterNode: team %" B_PRId32 " tried to " + "unregister node %" B_PRId32 ", but it was instantiated by team %" + B_PRId32 "\n", team, id, node.containing_team); return B_ERROR; } if (node.ref_count != 1) { - ERROR("NodeManager::UnregisterNode: node %ld, team %ld has ref count " - "%ld (should be 1)\n", id, team, node.ref_count); + ERROR("NodeManager::UnregisterNode: node %" B_PRId32 ", team %" + B_PRId32 " has ref count %" B_PRId32 " (should be 1)\n", id, team, + node.ref_count); //return B_ERROR; } @@ -209,8 +212,9 @@ NodeManager::UnregisterNode(media_node_id id, team_id team, fNodeMap.erase(found); - TRACE("NodeManager::UnregisterNode leave: node %ld, addon_id %ld, " - "flavor_id %ld team %ld\n", id, *_addOnID, *_flavorID, team); + TRACE("NodeManager::UnregisterNode leave: node %" B_PRId32 ", addon_id %" + B_PRId32 ", flavor_id %" B_PRId32 " team %" B_PRId32 "\n", id, + *_addOnID, *_flavorID, team); return B_OK; } @@ -218,14 +222,15 @@ NodeManager::UnregisterNode(media_node_id id, team_id team, status_t NodeManager::ReleaseNodeReference(media_node_id id, team_id team) { - TRACE("NodeManager::ReleaseNodeReference enter: node %ld, team %ld\n", id, - team); + TRACE("NodeManager::ReleaseNodeReference enter: node %" B_PRId32 ", team %" + B_PRId32 "\n", id, team); BAutolock _(this); NodeMap::iterator found = fNodeMap.find(id); if (found == fNodeMap.end()) { - ERROR("NodeManager::ReleaseNodeReference: node %ld not found\n", id); + ERROR("NodeManager::ReleaseNodeReference: node %" B_PRId32 " not " + "found\n", id); return B_ERROR; } @@ -246,8 +251,8 @@ NodeManager::ReleaseNodeReference(media_node_id id, team_id team) node.creator = -1; // invalidate! team = addOnServer; } else { - ERROR("NodeManager::ReleaseNodeReference: node %ld has no team " - "%ld references\n", id, team); + ERROR("NodeManager::ReleaseNodeReference: node %" B_PRId32 " has " + "no team %" B_PRId32 " references\n", id, team); return B_ERROR; } } @@ -261,8 +266,8 @@ NodeManager::ReleaseNodeReference(media_node_id id, team_id team) node.team_ref_count.erase(teamRef); if (--node.ref_count == 0) { - PRINT(1, "NodeManager::ReleaseNodeReference: detected released node is " - "now unused, node %ld\n", id); + PRINT(1, "NodeManager::ReleaseNodeReference: detected released node is" + " now unused, node %" B_PRId32 "\n", id); // TODO: remove! node_final_release_command command; @@ -270,13 +275,14 @@ NodeManager::ReleaseNodeReference(media_node_id id, team_id team) sizeof(command)); if (status != B_OK) { ERROR("NodeManager::ReleaseNodeReference: can't send command to " - "node %ld\n", id); + "node %" B_PRId32 "\n", id); // ignore error } } - TRACE("NodeManager::ReleaseNodeReference leave: node %ld, team %ld, " - "ref %ld, team ref %ld\n", id, team, node.ref_count, teamCount); + TRACE("NodeManager::ReleaseNodeReference leave: node %" B_PRId32 ", team %" + B_PRId32 ", ref %" B_PRId32 ", team ref %" B_PRId32 "\n", id, team, + node.ref_count, teamCount); return B_OK; } @@ -284,13 +290,14 @@ NodeManager::ReleaseNodeReference(media_node_id id, team_id team) status_t NodeManager::ReleaseNodeAll(media_node_id id) { - TRACE("NodeManager::ReleaseNodeAll enter: node %ld\n", id); + TRACE("NodeManager::ReleaseNodeAll enter: node %" B_PRId32 "\n", id); BAutolock _(this); NodeMap::iterator found = fNodeMap.find(id); if (found == fNodeMap.end()) { - ERROR("NodeManager::ReleaseNodeAll: node %ld not found\n", id); + ERROR("NodeManager::ReleaseNodeAll: node %" B_PRId32 " not found\n", + id); return B_ERROR; } @@ -303,11 +310,11 @@ NodeManager::ReleaseNodeAll(media_node_id id) sizeof(command)); if (status != B_OK) { ERROR("NodeManager::ReleaseNodeAll: can't send command to " - "node %ld\n", id); + "node %" B_PRId32 "\n", id); // ignore error } - TRACE("NodeManager::ReleaseNodeAll leave: node %ld\n", id); + TRACE("NodeManager::ReleaseNodeAll leave: node %" B_PRId32 "\n", id); return B_OK; } @@ -315,21 +322,23 @@ NodeManager::ReleaseNodeAll(media_node_id id) status_t NodeManager::SetNodeCreator(media_node_id id, team_id creator) { - TRACE("NodeManager::SetNodeCreator node %ld, creator %ld\n", id, creator); + TRACE("NodeManager::SetNodeCreator node %" B_PRId32 ", creator %" B_PRId32 + "\n", id, creator); BAutolock _(this); NodeMap::iterator found = fNodeMap.find(id); if (found == fNodeMap.end()) { - ERROR("NodeManager::SetNodeCreator: node %ld not found\n", id); + ERROR("NodeManager::SetNodeCreator: node %" B_PRId32 " not found\n", + id); return B_ERROR; } registered_node& node = found->second; if (node.creator != -1) { - ERROR("NodeManager::SetNodeCreator: node %ld is already assigned " - "creator %ld\n", id, node.creator); + ERROR("NodeManager::SetNodeCreator: node %" B_PRId32 " is already" + " assigned creator %" B_PRId32 "\n", id, node.creator); return B_ERROR; } @@ -341,20 +350,22 @@ NodeManager::SetNodeCreator(media_node_id id, team_id creator) status_t NodeManager::GetCloneForID(media_node_id id, team_id team, media_node* node) { - TRACE("NodeManager::GetCloneForID enter: node %ld team %ld\n", id, team); + TRACE("NodeManager::GetCloneForID enter: node %" B_PRId32 " team %" + B_PRId32 "\n", id, team); BAutolock _(this); status_t status = _AcquireNodeReference(id, team); if (status != B_OK) { ERROR("NodeManager::GetCloneForID: couldn't increment ref count, " - "node %ld team %ld\n", id, team); + "node %" B_PRId32 " team %" B_PRId32 "\n", id, team); return status; } NodeMap::iterator found = fNodeMap.find(id); if (found == fNodeMap.end()) { - ERROR("NodeManager::GetCloneForID: node %ld not found\n", id); + ERROR("NodeManager::GetCloneForID: node %" B_PRId32 " not found\n", + id); return B_ERROR; } @@ -364,7 +375,8 @@ NodeManager::GetCloneForID(media_node_id id, team_id team, media_node* node) node->port = registeredNode.port; node->kind = registeredNode.kinds; - TRACE("NodeManager::GetCloneForID leave: node %ld team %ld\n", id, team); + TRACE("NodeManager::GetCloneForID leave: node %" B_PRId32 " team %" + B_PRId32 "\n", id, team); return B_OK; } @@ -382,13 +394,14 @@ NodeManager::GetClone(node_type type, team_id team, media_node* node, { BAutolock _(this); - TRACE("NodeManager::GetClone enter: team %ld, type %d (%s)\n", team, type, get_node_type(type)); + TRACE("NodeManager::GetClone enter: team %" B_PRId32 ", type %d (%s)\n", + team, type, get_node_type(type)); media_node_id id; status_t status = GetDefaultNode(type, &id, inputName, _inputID); if (status != B_OK) { - ERROR("NodeManager::GetClone: couldn't GetDefaultNode, team %ld, " - "type %d (%s)\n", team, type, get_node_type(type)); + ERROR("NodeManager::GetClone: couldn't GetDefaultNode, team %" B_PRId32 + ", type %d (%s)\n", team, type, get_node_type(type)); *node = media_node::null; return status; } @@ -396,15 +409,16 @@ NodeManager::GetClone(node_type type, team_id team, media_node* node, status = GetCloneForID(id, team, node); if (status != B_OK) { - ERROR("NodeManager::GetClone: couldn't GetCloneForID, id %ld, team " - "%ld, type %d (%s)\n", id, team, type, get_node_type(type)); + ERROR("NodeManager::GetClone: couldn't GetCloneForID, id %" B_PRId32 + ", team %" B_PRId32 ", type %d (%s)\n", id, team, type, + get_node_type(type)); *node = media_node::null; return status; } ASSERT(id == node->node); - TRACE("NodeManager::GetClone leave: node id %ld, node port %ld, node " - "kind %#lx\n", node->node, node->port, node->kind); + TRACE("NodeManager::GetClone leave: node id %" B_PRId32 ", node port %" + B_PRId32 ", node kind %#lx\n", node->node, node->port, node->kind); return B_OK; } @@ -412,12 +426,12 @@ NodeManager::GetClone(node_type type, team_id team, media_node* node, status_t NodeManager::ReleaseNode(const media_node& node, team_id team) { - TRACE("NodeManager::ReleaseNode enter: node %ld team %ld\n", node.node, - team); + TRACE("NodeManager::ReleaseNode enter: node %" B_PRId32 " team %" B_PRId32 + "\n", node.node, team); if (ReleaseNodeReference(node.node, team) != B_OK) { - ERROR("NodeManager::ReleaseNode: couldn't decrement node %ld team %ld " - "ref count\n", node.node, team); + ERROR("NodeManager::ReleaseNode: couldn't decrement node %" B_PRId32 + " team %" B_PRId32 " ref count\n", node.node, team); } return B_OK; @@ -432,7 +446,8 @@ NodeManager::PublishInputs(const media_node& node, const media_input* inputs, NodeMap::iterator found = fNodeMap.find(node.node); if (found == fNodeMap.end()) { - ERROR("NodeManager::PublishInputs: node %ld not found\n", node.node); + ERROR("NodeManager::PublishInputs: node %" B_PRId32 " not found\n", + node.node); return B_ERROR; } @@ -459,7 +474,8 @@ NodeManager::PublishOutputs(const media_node &node, const media_output* outputs, NodeMap::iterator found = fNodeMap.find(node.node); if (found == fNodeMap.end()) { - ERROR("NodeManager::PublishOutputs: node %ld not found\n", node.node); + ERROR("NodeManager::PublishOutputs: node %" B_PRId32 " not found\n", + node.node); return B_ERROR; } @@ -489,8 +505,8 @@ NodeManager::FindNodeID(port_id port, media_node_id* _id) if (node.port == port) { *_id = node.node_id; - TRACE("NodeManager::FindNodeID found port %ld, node %ld\n", port, - node.node_id); + TRACE("NodeManager::FindNodeID found port %" B_PRId32 ", node %" + B_PRId32 "\n", port, node.node_id); return B_OK; } @@ -498,8 +514,8 @@ NodeManager::FindNodeID(port_id port, media_node_id* _id) for (; outIterator != node.output_list.end(); outIterator++) { if (outIterator->source.port == port) { *_id = node.node_id; - TRACE("NodeManager::FindNodeID found output port %ld, node " - "%ld\n", port, node.node_id); + TRACE("NodeManager::FindNodeID found output port %" B_PRId32 + ", node %" B_PRId32 "\n", port, node.node_id); return B_OK; } } @@ -508,14 +524,14 @@ NodeManager::FindNodeID(port_id port, media_node_id* _id) for (; inIterator != node.input_list.end(); inIterator++) { if (inIterator->destination.port == port) { *_id = node.node_id; - TRACE("NodeManager::FindNodeID found input port %ld, node " - "%ld\n", port, node.node_id); + TRACE("NodeManager::FindNodeID found input port %" B_PRId32 + ", node %" B_PRId32 "\n", port, node.node_id); return B_OK; } } } - ERROR("NodeManager::FindNodeID failed, port %ld\n", port); + ERROR("NodeManager::FindNodeID failed, port %" B_PRId32 "\n", port); return B_ERROR; } @@ -529,8 +545,8 @@ NodeManager::GetDormantNodeInfo(const media_node& node, NodeMap::iterator found = fNodeMap.find(node.node); if (found == fNodeMap.end()) { - ERROR("NodeManager::GetDormantNodeInfo: node %ld not found\n", - node.node); + ERROR("NodeManager::GetDormantNodeInfo: node %" B_PRId32 " not found" + "\n", node.node); return B_ERROR; } @@ -540,9 +556,9 @@ NodeManager::GetDormantNodeInfo(const media_node& node, && node.node != NODE_SYSTEM_TIMESOURCE_ID) { // This function must return an error if the node is application owned TRACE("NodeManager::GetDormantNodeInfo NODE IS APPLICATION OWNED! " - "node %ld, add_on_id %ld, flavor_id %ld, name \"%s\"\n", node.node, - registeredNode.add_on_id, registeredNode.flavor_id, - registeredNode.name); + "node %" B_PRId32 ", add_on_id %" B_PRId32 ", flavor_id %" B_PRId32 + ", name \"%s\"\n", node.node, registeredNode.add_on_id, + registeredNode.flavor_id, registeredNode.name); return B_ERROR; } @@ -554,9 +570,10 @@ NodeManager::GetDormantNodeInfo(const media_node& node, nodeInfo->flavor_id = registeredNode.flavor_id; strlcpy(nodeInfo->name, registeredNode.name, sizeof(nodeInfo->name)); - TRACE("NodeManager::GetDormantNodeInfo node %ld, add_on_id %ld, " - "flavor_id %ld, name \"%s\"\n", node.node, registeredNode.add_on_id, - registeredNode.flavor_id, registeredNode.name); + TRACE("NodeManager::GetDormantNodeInfo node %" B_PRId32 ", add_on_id %" + B_PRId32 ", flavor_id %" B_PRId32 ", name \"%s\"\n", node.node, + registeredNode.add_on_id, registeredNode.flavor_id, + registeredNode.name); return B_OK; } @@ -568,7 +585,7 @@ NodeManager::GetLiveNodeInfo(const media_node& node, live_node_info* liveInfo) NodeMap::iterator found = fNodeMap.find(node.node); if (found == fNodeMap.end()) { - ERROR("NodeManager::GetLiveNodeInfo: node %ld not found\n", + ERROR("NodeManager::GetLiveNodeInfo: node %" B_PRId32 " not found\n", node.node); return B_ERROR; } @@ -583,8 +600,8 @@ NodeManager::GetLiveNodeInfo(const media_node& node, live_node_info* liveInfo) liveInfo->hint_point = BPoint(0, 0); strlcpy(liveInfo->name, registeredNode.name, sizeof(liveInfo->name)); - TRACE("NodeManager::GetLiveNodeInfo node %ld, name = \"%s\"\n", node.node, - registeredNode.name); + TRACE("NodeManager::GetLiveNodeInfo node %" B_PRId32 ", name = \"%s\"\n", + node.node, registeredNode.name); return B_OK; } @@ -604,8 +621,9 @@ NodeManager::GetInstances(media_addon_id addOnID, int32 flavorID, ids[count++] = node.node_id; } - TRACE("NodeManager::GetInstances found %ld instances for addon_id %ld, " - "flavor_id %ld\n", count, addOnID, flavorID); + TRACE("NodeManager::GetInstances found %" B_PRId32 " instances for " + "addon_id %" B_PRId32 ", flavor_id %" B_PRId32 "\n", count, addOnID, + flavorID); *_count = count; return B_OK; } @@ -616,9 +634,9 @@ NodeManager::GetLiveNodes(LiveNodeList& liveNodes, int32 maxCount, const media_format* inputFormat, const media_format* outputFormat, const char* name, uint64 requireKinds) { - TRACE("NodeManager::GetLiveNodes: maxCount %ld, in-format %p, out-format " - "%p, name %s, require kinds 0x%Lx\n", maxCount, inputFormat, - outputFormat, name != NULL ? name : "NULL", requireKinds); + TRACE("NodeManager::GetLiveNodes: maxCount %" B_PRId32 ", in-format %p, " + "out-format %p, name %s, require kinds 0x%" B_PRIx64 "\n", maxCount, + inputFormat, outputFormat, name != NULL ? name : "NULL", requireKinds); BAutolock _(this); @@ -694,7 +712,7 @@ NodeManager::GetLiveNodes(LiveNodeList& liveNodes, int32 maxCount, count++; } - TRACE("NodeManager::GetLiveNodes found %ld\n", count); + TRACE("NodeManager::GetLiveNodes found %" B_PRId32 "\n", count); return B_OK; } @@ -729,8 +747,8 @@ NodeManager::RegisterAddOn(const entry_ref& ref, media_addon_id* _newID) media_addon_id id = fNextAddOnID++; -// printf("NodeManager::RegisterAddOn: ref-name \"%s\", assigning id %ld\n", -// ref.name, id); +// printf("NodeManager::RegisterAddOn: ref-name \"%s\", assigning id %" +// B_PRId32 "\n", ref.name, id); try { fPathMap.insert(std::make_pair(id, ref)); @@ -744,7 +762,7 @@ NodeManager::RegisterAddOn(const entry_ref& ref, media_addon_id* _newID) void NodeManager::UnregisterAddOn(media_addon_id addOnID) { - PRINT(1, "NodeManager::UnregisterAddOn: id %ld\n", addOnID); + PRINT(1, "NodeManager::UnregisterAddOn: id %" B_PRId32 "\n", addOnID); BAutolock _(this); @@ -774,10 +792,11 @@ NodeManager::GetAddOnRef(media_addon_id addOnID, entry_ref* ref) status_t NodeManager::AddDormantFlavorInfo(const dormant_flavor_info& flavorInfo) { - PRINT(1, "NodeManager::AddDormantFlavorInfo, addon-id %ld, flavor-id %ld, " - "name \"%s\", flavor-name \"%s\", flavor-info \"%s\"\n", - flavorInfo.node_info.addon, flavorInfo.node_info.flavor_id, - flavorInfo.node_info.name, flavorInfo.name, flavorInfo.info); + PRINT(1, "NodeManager::AddDormantFlavorInfo, addon-id %" B_PRId32 ", " + "flavor-id %" B_PRId32 ", name \"%s\", flavor-name \"%s\", flavor-info" + " \"%s\"\n", flavorInfo.node_info.addon, + flavorInfo.node_info.flavor_id, flavorInfo.node_info.name, + flavorInfo.name, flavorInfo.info); BAutolock _(this); @@ -794,13 +813,13 @@ NodeManager::AddDormantFlavorInfo(const dormant_flavor_info& flavorInfo) continue; if (info.info_valid) { - ERROR("NodeManager::AddDormantFlavorInfo, addon-id %ld, " - "flavor-id %ld does already exist\n", info.info.node_info.addon, - info.info.node_info.flavor_id); + ERROR("NodeManager::AddDormantFlavorInfo, addon-id %" B_PRId32 ", " + "flavor-id %" B_PRId32 " does already exist\n", + info.info.node_info.addon, info.info.node_info.flavor_id); } - TRACE("NodeManager::AddDormantFlavorInfo, updating addon-id %ld, " - "flavor-id %ld\n", info.info.node_info.addon, + TRACE("NodeManager::AddDormantFlavorInfo, updating addon-id %" B_PRId32 + ", flavor-id %" B_PRId32 "\n", info.info.node_info.addon, info.info.node_info.flavor_id); info.max_instances_count = flavorInfo.possible_count > 0 @@ -842,9 +861,9 @@ NodeManager::InvalidateDormantFlavorInfo(media_addon_id addOnID) dormant_add_on_flavor_info& info = *iterator; if (info.add_on_id == addOnID && info.info_valid) { - PRINT(1, "NodeManager::InvalidateDormantFlavorInfo, addon-id %ld, " - "flavor-id %ld, name \"%s\", flavor-name \"%s\", flavor-info " - "\"%s\"\n", info.info.node_info.addon, + PRINT(1, "NodeManager::InvalidateDormantFlavorInfo, addon-id %" + B_PRId32 ", flavor-id %" B_PRId32 ", name \"%s\", flavor-name " + "\"%s\", flavor-info \"%s\"\n", info.info.node_info.addon, info.info.node_info.flavor_id, info.info.node_info.name, info.info.name, info.info.info); @@ -864,9 +883,9 @@ NodeManager::RemoveDormantFlavorInfo(media_addon_id addOnID) dormant_add_on_flavor_info& info = fDormantFlavors[index]; if (info.add_on_id == addOnID) { - PRINT(1, "NodeManager::RemoveDormantFlavorInfo, addon-id %ld, " - "flavor-id %ld, name \"%s\", flavor-name \"%s\", flavor-info " - "\"%s\"\n", info.info.node_info.addon, + PRINT(1, "NodeManager::RemoveDormantFlavorInfo, addon-id %" + B_PRId32 ", flavor-id %" B_PRId32 ", name \"%s\", flavor-name " + "\"%s\", flavor-info \"%s\"\n", info.info.node_info.addon, info.info.node_info.flavor_id, info.info.node_info.name, info.info.name, info.info.info); fDormantFlavors.erase(fDormantFlavors.begin() + index--); @@ -890,9 +909,9 @@ NodeManager::IncrementFlavorInstancesCount(media_addon_id addOnID, if (info.instances_count >= info.max_instances_count) { // maximum (or more) instances already exist - ERROR("NodeManager::IncrementFlavorInstancesCount addon-id %ld, " - "flavor-id %ld maximum (or more) instances already exist\n", - addOnID, flavorID); + ERROR("NodeManager::IncrementFlavorInstancesCount addon-id %" + B_PRId32 ", flavor-id %" B_PRId32 " maximum (or more) " + "instances already exist\n", addOnID, flavorID); return B_ERROR; } @@ -914,8 +933,8 @@ NodeManager::IncrementFlavorInstancesCount(media_addon_id addOnID, return B_OK; } - ERROR("NodeManager::IncrementFlavorInstancesCount addon-id %ld, " - "flavor-id %ld not found\n", addOnID, flavorID); + ERROR("NodeManager::IncrementFlavorInstancesCount addon-id %" B_PRId32 ", " + "flavor-id %" B_PRId32 " not found\n", addOnID, flavorID); return B_ERROR; } @@ -936,9 +955,9 @@ NodeManager::DecrementFlavorInstancesCount(media_addon_id addOnID, TeamCountMap::iterator teamInstance = info.team_instances_count.find(team); if (teamInstance == info.team_instances_count.end()) { - ERROR("NodeManager::DecrementFlavorInstancesCount addon-id %ld, " - "flavor-id %ld team %ld has no references\n", addOnID, flavorID, - team); + ERROR("NodeManager::DecrementFlavorInstancesCount addon-id %" + B_PRId32 ", flavor-id %" B_PRId32 " team %" B_PRId32 " has no " + "references\n", addOnID, flavorID, team); return B_ERROR; } if (--teamInstance->second == 0) @@ -948,8 +967,8 @@ NodeManager::DecrementFlavorInstancesCount(media_addon_id addOnID, return B_OK; } - ERROR("NodeManager::DecrementFlavorInstancesCount addon-id %ld, " - "flavor-id %ld not found\n", addOnID, flavorID); + ERROR("NodeManager::DecrementFlavorInstancesCount addon-id %" B_PRId32 ", " + "flavor-id %" B_PRId32 " not found\n", addOnID, flavorID); return B_ERROR; } @@ -1070,7 +1089,7 @@ NodeManager::CleanupTeam(team_id team) fDefaultManager->CleanupTeam(team); - PRINT(1, "NodeManager::CleanupTeam: team %ld\n", team); + PRINT(1, "NodeManager::CleanupTeam: team %" B_PRId32 "\n", team); // TODO: send notifications after removing nodes @@ -1091,8 +1110,8 @@ NodeManager::CleanupTeam(team_id team) // If the team hosting this node is gone, remove node from database if (node.containing_team == team) { - PRINT(1, "NodeManager::CleanupTeam: removing node id %ld, team " - "%ld\n", node.node_id, team); + PRINT(1, "NodeManager::CleanupTeam: removing node id %" B_PRId32 + ", team %" B_PRId32 "\n", node.node_id, team); fNodeMap.erase(remove); continue; } @@ -1101,12 +1120,13 @@ NodeManager::CleanupTeam(team_id team) // remove the team TeamCountMap::iterator teamRef = node.team_ref_count.find(team); if (teamRef != node.team_ref_count.end()) { - PRINT(1, "NodeManager::CleanupTeam: removing %ld refs from node " - "id %ld, team %ld\n", teamRef->second, node.node_id, team); + PRINT(1, "NodeManager::CleanupTeam: removing %" B_PRId32 " refs " + "from node id %" B_PRId32 ", team %" B_PRId32 "\n", + teamRef->second, node.node_id, team); node.ref_count -= teamRef->second; if (node.ref_count == 0) { - PRINT(1, "NodeManager::CleanupTeam: removing node id %ld that " - "has no teams\n", node.node_id); + PRINT(1, "NodeManager::CleanupTeam: removing node id %" + B_PRId32 " that has no teams\n", node.node_id); fNodeMap.erase(remove); } else @@ -1122,9 +1142,10 @@ NodeManager::CleanupTeam(team_id team) TeamCountMap::iterator instanceCount = flavorInfo.team_instances_count.find(team); if (instanceCount != flavorInfo.team_instances_count.end()) { - PRINT(1, "NodeManager::CleanupTeam: removing %ld instances from " - "addon %ld, flavor %ld\n", instanceCount->second, - flavorInfo.add_on_id, flavorInfo.flavor_id); + PRINT(1, "NodeManager::CleanupTeam: removing %" B_PRId32 " " + "instances from addon %" B_PRId32 ", flavor %" B_PRId32 "\n", + instanceCount->second, flavorInfo.add_on_id, + flavorInfo.flavor_id); flavorInfo.instances_count -= instanceCount->second; if (flavorInfo.instances_count <= 0) @@ -1163,7 +1184,7 @@ NodeManager::Dump() for (PathMap::iterator iterator = fPathMap.begin(); iterator != fPathMap.end(); iterator++) { BPath path(&iterator->second); - printf(" addon-id %ld, path \"%s\"\n", iterator->first, + printf(" addon-id %" B_PRId32 ", path \"%s\"\n", iterator->first, path.InitCheck() == B_OK ? path.Path() : "INVALID"); } @@ -1177,24 +1198,27 @@ NodeManager::Dump() iterator != fNodeMap.end(); iterator++) { registered_node& node = iterator->second; - printf(" node-id %ld, addon-id %ld, addon-flavor-id %ld, port %ld, " - "creator %ld, team %ld, kinds %#08Lx, name \"%s\", ref_count %ld\n", - node.node_id, node.add_on_id, node.flavor_id, node.port, - node.creator, node.containing_team, node.kinds, node.name, - node.ref_count); + printf(" node-id %" B_PRId32 ", addon-id %" B_PRId32 ", addon-flavor-" + "id %" B_PRId32 ", port %" B_PRId32 ", creator %" B_PRId32 ", " + "team %" B_PRId32 ", kinds %#08" B_PRIx64 ", name \"%s\", " + "ref_count %" B_PRId32 "\n", node.node_id, node.add_on_id, + node.flavor_id, node.port, node.creator, node.containing_team, + node.kinds, node.name, node.ref_count); printf(" teams (refcount): "); for (TeamCountMap::iterator refsIterator = node.team_ref_count.begin(); refsIterator != node.team_ref_count.end(); refsIterator++) { - printf("%ld (%ld), ", refsIterator->first, refsIterator->second); + printf("%" B_PRId32 " (%" B_PRId32 "), ", refsIterator->first, + refsIterator->second); } printf("\n"); for (InputList::iterator inIterator = node.input_list.begin(); inIterator != node.input_list.end(); inIterator++) { media_input& input = *inIterator; - printf(" media_input: node-id %ld, node-port %ld, source-port " - "%ld, source-id %ld, dest-port %ld, dest-id %ld, name " + printf(" media_input: node-id %" B_PRId32 ", node-port %" + B_PRId32 ", source-port %" B_PRId32 ", source-id %" B_PRId32 + ", dest-port %" B_PRId32 ", dest-id %" B_PRId32 ", name " "\"%s\"\n", input.node.node, input.node.port, input.source.port, input.source.id, input.destination.port, input.destination.id, input.name); @@ -1205,8 +1229,9 @@ NodeManager::Dump() for (OutputList::iterator outIterator = node.output_list.begin(); outIterator != node.output_list.end(); outIterator++) { media_output& output = *outIterator; - printf(" media_output: node-id %ld, node-port %ld, source-port " - "%ld, source-id %ld, dest-port %ld, dest-id %ld, name " + printf(" media_output: node-id %" B_PRId32 ", node-port %" + B_PRId32 ", source-port %" B_PRId32 ", source-id %" B_PRId32 + ", dest-port %" B_PRId32 ", dest-id %" B_PRId32 ", name " "\"%s\"\n", output.node.node, output.node.port, output.source.port, output.source.id, output.destination.port, output.destination.id, output.name); @@ -1226,9 +1251,9 @@ NodeManager::Dump() iterator != fDormantFlavors.end(); iterator++) { dormant_add_on_flavor_info& flavorInfo = *iterator; - printf(" addon-id %ld, flavor-id %ld, max instances count %ld, " - "instances count %ld, info valid %s\n", - flavorInfo.add_on_id, flavorInfo.flavor_id, + printf(" addon-id %" B_PRId32 ", flavor-id %" B_PRId32 ", max " + "instances count %" B_PRId32 ", instances count %" B_PRId32 ", " + "info valid %s\n", flavorInfo.add_on_id, flavorInfo.flavor_id, flavorInfo.max_instances_count, flavorInfo.instances_count, flavorInfo.info_valid ? "yes" : "no"); printf(" teams (instances): "); @@ -1236,18 +1261,20 @@ NodeManager::Dump() = flavorInfo.team_instances_count.begin(); countIterator != flavorInfo.team_instances_count.end(); countIterator++) { - printf("%ld (%ld), ", countIterator->first, countIterator->second); + printf("%" B_PRId32 " (%" B_PRId32 "), ", countIterator->first, + countIterator->second); } printf("\n"); if (!flavorInfo.info_valid) continue; - printf(" addon-id %ld, addon-flavor-id %ld, addon-name \"%s\"\n", - flavorInfo.info.node_info.addon, + printf(" addon-id %" B_PRId32 ", addon-flavor-id %" B_PRId32 ", " + "addon-name \"%s\"\n", flavorInfo.info.node_info.addon, flavorInfo.info.node_info.flavor_id, flavorInfo.info.node_info.name); - printf(" flavor-kinds %#08Lx, flavor_flags %#08lx, internal_id %ld, " - "possible_count %ld, in_format_count %ld, out_format_count %ld\n", + printf(" flavor-kinds %#08" B_PRIx64 ", flavor_flags %#08" B_PRIx32 + ", internal_id %" B_PRId32 ", possible_count %" B_PRId32 ", " + "in_format_count %" B_PRId32 ", out_format_count %" B_PRId32 "\n", flavorInfo.info.kinds, flavorInfo.info.flavor_flags, flavorInfo.info.internal_id, flavorInfo.info.possible_count, flavorInfo.info.in_format_count, flavorInfo.info.out_format_count); @@ -1266,14 +1293,15 @@ NodeManager::Dump() status_t NodeManager::_AcquireNodeReference(media_node_id id, team_id team) { - TRACE("NodeManager::_AcquireNodeReference enter: node %ld, team %ld\n", id, - team); + TRACE("NodeManager::_AcquireNodeReference enter: node %" B_PRId32 ", team " + "%" B_PRId32 "\n", id, team); BAutolock _(this); NodeMap::iterator found = fNodeMap.find(id); if (found == fNodeMap.end()) { - ERROR("NodeManager::_AcquireNodeReference: node %ld not found\n", id); + ERROR("NodeManager::_AcquireNodeReference: node %" B_PRId32 " not " + "found\n", id); return B_ERROR; } @@ -1294,8 +1322,8 @@ NodeManager::_AcquireNodeReference(media_node_id id, team_id team) node.ref_count++; - TRACE("NodeManager::_AcquireNodeReference leave: node %ld, team %ld, " - "ref %ld, team ref %ld\n", id, team, node.ref_count, - node.team_ref_count.find(team)->second); + TRACE("NodeManager::_AcquireNodeReference leave: node %" B_PRId32 ", team " + "%" B_PRId32 ", ref %" B_PRId32 ", team ref %" B_PRId32 "\n", id, team, + node.ref_count, node.team_ref_count.find(team)->second); return B_OK; } diff --git a/src/servers/media/NotificationManager.cpp b/src/servers/media/NotificationManager.cpp index 594de04200..de6accb4f5 100644 --- a/src/servers/media/NotificationManager.cpp +++ b/src/servers/media/NotificationManager.cpp @@ -257,7 +257,7 @@ NotificationManager::CleanupTeam(team_id team) if (debugCount != 0) { ERROR("NotificationManager::CleanupTeam: removed %d notifications for " - "team %ld\n", debugCount, team); + "team %" B_PRId32 "\n", debugCount, team); } } @@ -302,9 +302,9 @@ NotificationManager::Dump() printf("NotificationManager: list of subscribers follows:\n"); Notification *n; for (fNotificationList.Rewind(); fNotificationList.GetNext(&n); ) { - printf(" team %ld, what %#08lx, node-id %ld, node-port %ld, messenger " - "%svalid\n", n->team, n->what, n->node.node, n->node.port, - n->messenger.IsValid() ? "" : "NOT "); + printf(" team %" B_PRId32 ", what %#08" B_PRIx32 ", node-id %" B_PRId32 + ", node-port %" B_PRId32 ", messenger %svalid\n", n->team, n->what, + n->node.node, n->node.port, n->messenger.IsValid() ? "" : "NOT "); } printf("NotificationManager: list end\n"); } diff --git a/src/servers/media/media_server.cpp b/src/servers/media/media_server.cpp index f1cc958a97..31a81126b4 100644 --- a/src/servers/media/media_server.cpp +++ b/src/servers/media/media_server.cpp @@ -275,7 +275,7 @@ ServerApp::_QuitAddOnServer() void ServerApp::_HandleMessage(int32 code, const void* data, size_t size) { - TRACE("ServerApp::HandleMessage %#lx enter\n", code); + TRACE("ServerApp::HandleMessage %#" B_PRIx32 " enter\n", code); switch (code) { case SERVER_CHANGE_FLAVOR_INSTANCES_COUNT: { @@ -493,7 +493,7 @@ ServerApp::_HandleMessage(int32 code, const void* data, size_t size) B_ANY_ADDRESS, B_READ_AREA | B_WRITE_AREA, request.area); if (clone < B_OK) { ERROR("SERVER_PUBLISH_INPUTS: failed to clone area, " - "error %#lx\n", clone); + "error %#" B_PRIx32 "\n", clone); status = clone; } else { status = gNodeManager->PublishInputs(request.node, inputs, @@ -522,7 +522,7 @@ ServerApp::_HandleMessage(int32 code, const void* data, size_t size) B_ANY_ADDRESS, B_READ_AREA | B_WRITE_AREA, request.area); if (clone < B_OK) { ERROR("SERVER_PUBLISH_OUTPUTS: failed to clone area, " - "error %#lx\n", clone); + "error %#" B_PRIx32 "\n", clone); status = clone; } else { status = gNodeManager->PublishOutputs(request.node, outputs, @@ -961,10 +961,10 @@ ServerApp::_HandleMessage(int32 code, const void* data, size_t size) } default: - printf("media_server: received unknown message code %#08lx\n", - code); + printf("media_server: received unknown message code %#08" B_PRIx32 + "\n", code); } - TRACE("ServerApp::HandleMessage %#lx leave\n", code); + TRACE("ServerApp::HandleMessage %#" B_PRIx32 " leave\n", code); } diff --git a/src/servers/media_addon/MediaAddonServer.cpp b/src/servers/media_addon/MediaAddonServer.cpp index d2c158ea80..df6742c90e 100644 --- a/src/servers/media_addon/MediaAddonServer.cpp +++ b/src/servers/media_addon/MediaAddonServer.cpp @@ -428,8 +428,8 @@ MediaAddonServer::_HandleMessage(int32 code, const void* data, size_t size) break; default: - ERROR("media_addon_server: received unknown message code %#08lx\n", - code); + ERROR("media_addon_server: received unknown message code %#08" + B_PRIx32 "\n", code); break; } } @@ -607,13 +607,14 @@ MediaAddonServer::_AddOnAdded(const char* path, ino_t fileNode) void MediaAddonServer::_DestroyInstantiatedFlavors(AddOnInfo& info) { - printf("MediaAddonServer::_DestroyInstantiatedFlavors addon %ld\n", info.id); + printf("MediaAddonServer::_DestroyInstantiatedFlavors addon %" B_PRId32 + "\n", info.id); NodeVector::iterator iterator = info.active_flavors.begin(); for (; iterator != info.active_flavors.end(); iterator++) { media_node& node = *iterator; - printf("node %ld\n", node.node); + printf("node %" B_PRId32 "\n", node.node); if ((node.kind & B_TIME_SOURCE) != 0 && (fMediaRoster->StopTimeSource(node, 0, true) != B_OK)) { @@ -711,7 +712,7 @@ MediaAddonServer::_InstantiatePhysicalInputsAndOutputs(AddOnInfo& info) const flavor_info* flavorinfo; if (info.addon->GetFlavorAt(i, &flavorinfo) != B_OK) { ERROR("MediaAddonServer::InstantiatePhysialInputsAndOutputs " - "GetFlavorAt failed for index %ld!\n", i); + "GetFlavorAt failed for index %" B_PRId32 "!\n", i); continue; } if ((flavorinfo->kinds & (B_PHYSICAL_INPUT | B_PHYSICAL_OUTPUT)) != 0) { @@ -728,8 +729,8 @@ MediaAddonServer::_InstantiatePhysicalInputsAndOutputs(AddOnInfo& info) dormantNodeInfo, &node); if (status != B_OK) { ERROR("MediaAddonServer::InstantiatePhysialInputsAndOutputs " - "Couldn't instantiate node flavor, internal_id %ld, " - "name %s\n", flavorinfo->internal_id, flavorinfo->name); + "Couldn't instantiate node flavor, internal_id %" B_PRId32 + ", name %s\n", flavorinfo->internal_id, flavorinfo->name); } else { TRACE("Node created!\n"); info.active_flavors.push_back(node); @@ -758,12 +759,12 @@ MediaAddonServer::_InstantiateAutostartFlavors(AddOnInfo& info) else if (status != B_OK) break; - printf("started node %ld\n", index); + printf("started node %" B_PRId32 "\n", index); status = MediaRosterEx(fMediaRoster)->RegisterNode(node, info.id, internalID); if (status != B_OK) { - ERROR("failed to register node %ld\n", index); + ERROR("failed to register node %" B_PRId32 "\n", index); node->Release(); } else { MediaRosterEx(fMediaRoster)->IncrementAddonFlavorInstancesCount( @@ -784,7 +785,7 @@ MediaAddonServer::_AddOnRemoved(ino_t fileNode) FileMap::iterator foundFile = fFileMap.find(fileNode); if (foundFile == fFileMap.end()) { - ERROR("MediaAddonServer::_AddOnRemoved: inode %Ld removed, but no " + ERROR("MediaAddonServer::_AddOnRemoved: inode %" B_PRIdINO " removed, but no " "media add-on found\n", fileNode); return; } @@ -797,7 +798,7 @@ MediaAddonServer::_AddOnRemoved(ino_t fileNode) if (foundInfo == fInfoMap.end()) { ERROR("MediaAddonServer::_AddOnRemoved: couldn't get addon info for " - "add-on %ld\n", id); + "add-on %" B_PRId32 "\n", id); oldFlavorCount = 1000; } else { AddOnInfo& info = foundInfo->second; @@ -808,7 +809,7 @@ MediaAddonServer::_AddOnRemoved(ino_t fileNode) if (info.addon) { ERROR("MediaAddonServer::_AddOnRemoved: couldn't unload addon " - "%ld since flavors are in use\n", id); + "%" B_PRId32 " since flavors are in use\n", id); } fInfoMap.erase(foundInfo); diff --git a/src/system/boot/loader/RootFileSystem.cpp b/src/system/boot/loader/RootFileSystem.cpp index 955eb4f50b..1153397683 100644 --- a/src/system/boot/loader/RootFileSystem.cpp +++ b/src/system/boot/loader/RootFileSystem.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2003-2006, Axel Dörfler, axeld@pinc-software.de. All rights reserved. + * Copyright 2003-2013, Axel Dörfler, axeld@pinc-software.de. * Distributed under the terms of the MIT License. */ @@ -7,7 +7,6 @@ #include "RootFileSystem.h" #include -#include #include #include diff --git a/src/system/boot/loader/file_systems/amiga_ffs/Directory.cpp b/src/system/boot/loader/file_systems/amiga_ffs/Directory.cpp index bec052fd93..f0325a617d 100644 --- a/src/system/boot/loader/file_systems/amiga_ffs/Directory.cpp +++ b/src/system/boot/loader/file_systems/amiga_ffs/Directory.cpp @@ -1,7 +1,7 @@ /* -** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. -** Distributed under the terms of the OpenBeOS License. -*/ + * Copyright 2003-2013, Axel Dörfler, axeld@pinc-software.de. + * Distributed under the terms of the MIT License. + */ #include "Directory.h" @@ -9,7 +9,6 @@ #include "File.h" #include -#include #include #include @@ -18,6 +17,7 @@ namespace FFS { + Directory::Directory(Volume &volume, int32 block) : fVolume(volume) @@ -165,4 +165,5 @@ Directory::Inode() const return fNode.HeaderKey(); } + } // namespace FFS diff --git a/src/system/boot/loader/file_systems/amiga_ffs/File.cpp b/src/system/boot/loader/file_systems/amiga_ffs/File.cpp index 249d17bf9e..f75be4f8ff 100644 --- a/src/system/boot/loader/file_systems/amiga_ffs/File.cpp +++ b/src/system/boot/loader/file_systems/amiga_ffs/File.cpp @@ -1,7 +1,7 @@ /* -** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. -** Distributed under the terms of the OpenBeOS License. -*/ + * Copyright 2003-2013, Axel Dörfler, axeld@pinc-software.de. + * Distributed under the terms of the MIT License. + */ #include "File.h" @@ -10,11 +10,10 @@ #include #include -#include - namespace FFS { + class Stream { public: Stream(int device, FileBlock &node); @@ -255,4 +254,5 @@ File::Inode() const return fNode.HeaderKey(); } + } // namespace FFS diff --git a/src/system/boot/loader/file_systems/amiga_ffs/Volume.cpp b/src/system/boot/loader/file_systems/amiga_ffs/Volume.cpp index 4d1cd26e31..295ff39f9d 100644 --- a/src/system/boot/loader/file_systems/amiga_ffs/Volume.cpp +++ b/src/system/boot/loader/file_systems/amiga_ffs/Volume.cpp @@ -1,7 +1,7 @@ /* -** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. -** Distributed under the terms of the OpenBeOS License. -*/ + * Copyright 2003-2013, Axel Dörfler, axeld@pinc-software.de. + * Distributed under the terms of the MIT License. + */ #include "Volume.h" @@ -9,7 +9,6 @@ #include #include -#include #include #include @@ -87,7 +86,7 @@ Volume::~Volume() } -status_t +status_t Volume::InitCheck() { if (fRoot != NULL) diff --git a/src/system/boot/loader/file_systems/amiga_ffs/amiga_ffs.cpp b/src/system/boot/loader/file_systems/amiga_ffs/amiga_ffs.cpp index 07fe89981d..28cc48f82e 100644 --- a/src/system/boot/loader/file_systems/amiga_ffs/amiga_ffs.cpp +++ b/src/system/boot/loader/file_systems/amiga_ffs/amiga_ffs.cpp @@ -1,14 +1,13 @@ /* -** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. -** Distributed under the terms of the OpenBeOS License. -*/ + * Copyright 2003-2013, Axel Dörfler, axeld@pinc-software.de. + * Distributed under the terms of the MIT License. + */ #include "amiga_ffs.h" #include #include -#include #include #include @@ -31,7 +30,7 @@ class BCPLString { }; -int32 +int32 BCPLString::CopyTo(char *name, size_t size) { int32 length = size - 1 > Length() ? Length() : size - 1; @@ -56,7 +55,7 @@ BaseBlock::GetNameBackOffset(int32 offset, char *name, size_t size) const } -status_t +status_t BaseBlock::ValidateCheckSum() const { if (fData == NULL) @@ -74,7 +73,7 @@ BaseBlock::ValidateCheckSum() const // #pragma mark - -char +char DirectoryBlock::ToUpperChar(int32 type, char c) const { // Taken from Ralph Babel's "The Amiga Guru Book" (1993), section 15.3.4.3 @@ -87,11 +86,11 @@ DirectoryBlock::ToUpperChar(int32 type, char c) const } -int32 +int32 DirectoryBlock::HashIndexFor(int32 type, const char *name) const { int32 hash = strlen(name); - + while (name[0]) { hash = (hash * 13 + ToUpperChar(type, name[0])) & 0x7ff; name++; @@ -101,7 +100,7 @@ DirectoryBlock::HashIndexFor(int32 type, const char *name) const } -int32 +int32 DirectoryBlock::HashValueAt(int32 index) const { return index >= HashSize() ? -1 : (int32)B_BENDIAN_TO_HOST_INT32(HashTable()[index]); @@ -116,11 +115,11 @@ DirectoryBlock::FirstHashValue(int32 &index) const } -int32 +int32 DirectoryBlock::NextHashValue(int32 &index) const { index++; - + int32 value; while ((value = HashValueAt(index)) == 0) { if (++index >= HashSize()) @@ -152,14 +151,14 @@ HashIterator::~HashIterator() } -status_t +status_t HashIterator::InitCheck() { return fData != NULL ? B_OK : B_NO_MEMORY; } -void +void HashIterator::Goto(int32 index) { fCurrent = index; @@ -197,7 +196,7 @@ HashIterator::GetNext(int32 &block) } -void +void HashIterator::Rewind() { fCurrent = 0; diff --git a/src/system/boot/loader/file_systems/bfs/Directory.cpp b/src/system/boot/loader/file_systems/bfs/Directory.cpp index 705e598c81..dda1c40bc7 100644 --- a/src/system/boot/loader/file_systems/bfs/Directory.cpp +++ b/src/system/boot/loader/file_systems/bfs/Directory.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2003-2010, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2003-2013, Axel Dörfler, axeld@pinc-software.de. * Distributed under the terms of the MIT License. */ @@ -10,7 +10,6 @@ #include #include -#include #include #include diff --git a/src/system/boot/loader/file_systems/bfs/File.cpp b/src/system/boot/loader/file_systems/bfs/File.cpp index 626731d39f..2853ed11b1 100644 --- a/src/system/boot/loader/file_systems/bfs/File.cpp +++ b/src/system/boot/loader/file_systems/bfs/File.cpp @@ -1,16 +1,15 @@ /* -** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. -** Distributed under the terms of the OpenBeOS License. -*/ + * Copyright 2003-2013, Axel Dörfler, axeld@pinc-software.de. + * This file may be used under the terms of the MIT License. + */ #include "File.h" -#include - namespace BFS { + File::File(Volume &volume, block_run run) : fStream(volume, run) @@ -37,14 +36,14 @@ File::~File() } -status_t +status_t File::InitCheck() { return fStream.InitCheck(); } -ssize_t +ssize_t File::ReadAt(void *cookie, off_t pos, void *buffer, size_t bufferSize) { status_t status = fStream.ReadAt(pos, (uint8 *)buffer, &bufferSize); @@ -55,7 +54,7 @@ File::ReadAt(void *cookie, off_t pos, void *buffer, size_t bufferSize) } -ssize_t +ssize_t File::WriteAt(void *cookie, off_t pos, const void *buffer, size_t bufferSize) { return EROFS; @@ -89,4 +88,5 @@ File::Inode() const return fStream.ID(); } + } // namespace BFS diff --git a/src/system/boot/loader/file_systems/bfs/Link.cpp b/src/system/boot/loader/file_systems/bfs/Link.cpp index 381abb9515..c5159a2003 100644 --- a/src/system/boot/loader/file_systems/bfs/Link.cpp +++ b/src/system/boot/loader/file_systems/bfs/Link.cpp @@ -1,16 +1,15 @@ /* -** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. -** Distributed under the terms of the OpenBeOS License. -*/ + * Copyright 2004-2013, Axel Dörfler, axeld@pinc-software.de. + * This file may be used under the terms of the MIT License. + */ #include "Link.h" -#include - namespace BFS { + Link::Link(Volume &volume, block_run run) : File(volume, run) { @@ -63,4 +62,5 @@ Link::Type() const return S_IFLNK; } + } // namespace BFS diff --git a/src/system/boot/loader/file_systems/bfs/Stream.cpp b/src/system/boot/loader/file_systems/bfs/Stream.cpp index 9eb25b7e30..4cdea7dd85 100644 --- a/src/system/boot/loader/file_systems/bfs/Stream.cpp +++ b/src/system/boot/loader/file_systems/bfs/Stream.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2003-2010, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2003-2013, Axel Dörfler, axeld@pinc-software.de. * This file may be used under the terms of the MIT License. */ @@ -12,8 +12,6 @@ #include "File.h" #include "Link.h" -#include - #include #include #include diff --git a/src/system/boot/loader/file_systems/bfs/bfs.cpp b/src/system/boot/loader/file_systems/bfs/bfs.cpp index f6cfd3b36a..3fee5a9dc4 100644 --- a/src/system/boot/loader/file_systems/bfs/bfs.cpp +++ b/src/system/boot/loader/file_systems/bfs/bfs.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2003-2009, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2003-2013, Axel Dörfler, axeld@pinc-software.de. * Distributed under the terms of the MIT License. */ @@ -12,7 +12,6 @@ #include #include #include -#include #include "Volume.h" #include "Directory.h" diff --git a/src/system/boot/loader/file_systems/fat/CachedBlock.h b/src/system/boot/loader/file_systems/fat/CachedBlock.h index f19ca82036..ab6f6f5342 100644 --- a/src/system/boot/loader/file_systems/fat/CachedBlock.h +++ b/src/system/boot/loader/file_systems/fat/CachedBlock.h @@ -9,16 +9,12 @@ #define CACHED_BLOCK_H -#include -#include -#include -#include - #include "Volume.h" namespace FATFS { + class CachedBlock { public: enum { diff --git a/src/system/boot/loader/file_systems/fat/Directory.cpp b/src/system/boot/loader/file_systems/fat/Directory.cpp index ff152d6384..1706473da9 100644 --- a/src/system/boot/loader/file_systems/fat/Directory.cpp +++ b/src/system/boot/loader/file_systems/fat/Directory.cpp @@ -1,7 +1,8 @@ /* -** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. -** Distributed under the terms of the OpenBeOS License. -*/ + * Copyright 2003-2013, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2008, François Revol + * Distributed under the terms of the MIT License. + */ #include "Directory.h" @@ -14,7 +15,6 @@ #include #include -#include #include "CachedBlock.h" #include "File.h" @@ -24,8 +24,10 @@ //#define TRACE(x) dprintf x #define TRACE(x) do {} while (0) + namespace FATFS { + struct dir_entry { void *Buffer() const { return (void *)fName; }; const char *BaseName() const { return fName; }; @@ -328,7 +330,7 @@ Directory::Open(void **_cookie, int mode) TRACE(("FASFS::Directory::%s(, %d)\n", __FUNCTION__, mode)); _inherited::Open(_cookie, mode); - struct dir_cookie *c = new struct dir_cookie; + dir_cookie *c = new(nothrow) dir_cookie; if (c == NULL) return B_NO_MEMORY; diff --git a/src/system/boot/loader/file_systems/fat/File.cpp b/src/system/boot/loader/file_systems/fat/File.cpp index 4a06da1934..60ac2e8fb5 100644 --- a/src/system/boot/loader/file_systems/fat/File.cpp +++ b/src/system/boot/loader/file_systems/fat/File.cpp @@ -1,7 +1,8 @@ /* -** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. -** Distributed under the terms of the OpenBeOS License. -*/ + * Copyright 2003-2013, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2008, François Revol + * Distributed under the terms of the MIT License. + */ #include "File.h" @@ -9,8 +10,6 @@ #include #include -#include - #include "Directory.h" @@ -137,4 +136,5 @@ File::Inode() const return fStream.FirstCluster() << 16; } + } // namespace FATFS diff --git a/src/system/boot/loader/file_systems/fat/Stream.cpp b/src/system/boot/loader/file_systems/fat/Stream.cpp index a8d8754e11..3ed255f656 100644 --- a/src/system/boot/loader/file_systems/fat/Stream.cpp +++ b/src/system/boot/loader/file_systems/fat/Stream.cpp @@ -17,12 +17,12 @@ #include #include -#include #include "CachedBlock.h" #include "Directory.h" #include "File.h" + //#define TRACE(x) dprintf x #define TRACE(x) do {} while (0) diff --git a/src/system/boot/loader/file_systems/fat/Volume.cpp b/src/system/boot/loader/file_systems/fat/Volume.cpp index fae51c9ca9..c2da9568a6 100644 --- a/src/system/boot/loader/file_systems/fat/Volume.cpp +++ b/src/system/boot/loader/file_systems/fat/Volume.cpp @@ -1,7 +1,8 @@ /* -** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. -** Distributed under the terms of the OpenBeOS License. -*/ + * Copyright 2003-2013, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2008, François Revol + * Distributed under the terms of the MIT License. + */ #include "Volume.h" @@ -10,7 +11,6 @@ #include #include -#include #include #include @@ -18,9 +18,11 @@ #include #include + //#define TRACE(x) dprintf x #define TRACE(x) do {} while (0) + using namespace FATFS; @@ -33,7 +35,7 @@ Volume::Volume(boot::Partition *partition) if ((fDevice = open_node(partition, O_RDONLY)) < B_OK) return; - fCachedBlock = new CachedBlock(*this); + fCachedBlock = new(nothrow) CachedBlock(*this); if (fCachedBlock == NULL) return; @@ -135,13 +137,13 @@ Volume::Volume(boot::Partition *partition) fFatBits = 16; goto err1; } - TRACE(("%s: block size %d, sector size %d, sectors/cluster %d\n", __FUNCTION__, - fBlockSize, fBytesPerSector, fSectorsPerCluster)); - TRACE(("%s: block shift %d, sector shift %d, cluster shift %d\n", __FUNCTION__, - fBlockShift, fSectorShift, fClusterShift)); - TRACE(("%s: reserved %d, max root entries %d, media %02x, sectors/fat %d\n", __FUNCTION__, - fReservedSectors, fMaxRootEntries, fMediaDesc, fSectorsPerFat)); - + TRACE(("%s: block size %d, sector size %d, sectors/cluster %d\n", + __FUNCTION__, fBlockSize, fBytesPerSector, fSectorsPerCluster)); + TRACE(("%s: block shift %d, sector shift %d, cluster shift %d\n", + __FUNCTION__, fBlockShift, fSectorShift, fClusterShift)); + TRACE(("%s: reserved %d, max root entries %d, media %02x, sectors/fat %d\n", + __FUNCTION__, fReservedSectors, fMaxRootEntries, fMediaDesc, + fSectorsPerFat)); //if (fTotalSectors > partition->sectors_per_track * partition->cylinder_count * partition->head_count) if ((off_t)fTotalSectors * fBytesPerSector > partition->size) @@ -150,7 +152,7 @@ Volume::Volume(boot::Partition *partition) TRACE(("%s: found fat%d filesystem, root dir at cluster %d\n", __FUNCTION__, fFatBits, fRootDirCluster)); - fRoot = new Directory(*this, 0, fRootDirCluster, "/"); + fRoot = new(nothrow) Directory(*this, 0, fRootDirCluster, "/"); return; err1: @@ -413,7 +415,7 @@ static status_t dosfs_get_file_system(boot::Partition *partition, ::Directory **_root) { TRACE(("%s()\n", __FUNCTION__)); - Volume *volume = new Volume(partition); + Volume *volume = new(nothrow) Volume(partition); if (volume == NULL) return B_NO_MEMORY; diff --git a/src/system/boot/loader/file_systems/fat/fatfs.cpp b/src/system/boot/loader/file_systems/fat/fatfs.cpp index 074476f3e1..2a989109f8 100644 --- a/src/system/boot/loader/file_systems/fat/fatfs.cpp +++ b/src/system/boot/loader/file_systems/fat/fatfs.cpp @@ -1,14 +1,13 @@ /* -** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. -** Distributed under the terms of the OpenBeOS License. -*/ + * Copyright 2008, François Revol + * Distributed under the terms of the MIT License. + */ #include "fatfs.h" #include #include -#include #include #include diff --git a/src/system/boot/loader/file_systems/hfs_plus/hfs_plus.cpp b/src/system/boot/loader/file_systems/hfs_plus/hfs_plus.cpp index c44cc1a227..ea3d0c26d0 100644 --- a/src/system/boot/loader/file_systems/hfs_plus/hfs_plus.cpp +++ b/src/system/boot/loader/file_systems/hfs_plus/hfs_plus.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved. + * Copyright 2005-2013, Axel Dörfler, axeld@pinc-software.de. * Distributed under the terms of the MIT License. */ @@ -8,7 +8,6 @@ #include #include -#include #include #include diff --git a/src/system/boot/loader/file_systems/tarfs/tarfs.cpp b/src/system/boot/loader/file_systems/tarfs/tarfs.cpp index 34062e6e41..fd1d1b4927 100644 --- a/src/system/boot/loader/file_systems/tarfs/tarfs.cpp +++ b/src/system/boot/loader/file_systems/tarfs/tarfs.cpp @@ -1,6 +1,6 @@ /* * Copyright 2005-2007, Ingo Weinhold, bonefish@cs.tu-berlin.de. - * Copyright 2005-2009, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2005-2013, Axel Dörfler, axeld@pinc-software.de. * * Distributed under the terms of the MIT License. */ @@ -21,7 +21,6 @@ #include #include -#include #include @@ -39,6 +38,7 @@ static const size_t kTarRegionSize = 8 * 1024 * 1024; // 8 MB namespace TarFS { + struct RegionDelete { inline void operator()(void* memory) { @@ -817,7 +817,6 @@ TarFS::Volume::_Inflate(boot::Partition* partition, void* cookie, off_t offset, } - // #pragma mark - diff --git a/src/system/boot/loader/heap.cpp b/src/system/boot/loader/heap.cpp index 013280aad6..eecfd934eb 100644 --- a/src/system/boot/loader/heap.cpp +++ b/src/system/boot/loader/heap.cpp @@ -1,12 +1,11 @@ /* - * Copyright 2003-2009, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2003-2013, Axel Dörfler, axeld@pinc-software.de. * Distributed under the terms of the MIT License. */ #include #include -#include #include diff --git a/src/system/boot/loader/main.cpp b/src/system/boot/loader/main.cpp index 01b4826ade..004c576f7b 100644 --- a/src/system/boot/loader/main.cpp +++ b/src/system/boot/loader/main.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2003-2005, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2003-2013, Axel Dörfler, axeld@pinc-software.de. * Distributed under the terms of the MIT License. */ @@ -14,8 +14,6 @@ #include #include -#include - //#define TRACE_MAIN #ifdef TRACE_MAIN diff --git a/src/system/boot/loader/menu.cpp b/src/system/boot/loader/menu.cpp index 3328c543b7..38241b6729 100644 --- a/src/system/boot/loader/menu.cpp +++ b/src/system/boot/loader/menu.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2003-2010, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2003-2013, Axel Dörfler, axeld@pinc-software.de. * Copyright 2011, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ @@ -21,7 +21,6 @@ #include #include #include -#include #include #include "kernel_debug_config.h" diff --git a/src/system/boot/loader/partitions.cpp b/src/system/boot/loader/partitions.cpp index 29d4f20f76..f70bc8a407 100644 --- a/src/system/boot/loader/partitions.cpp +++ b/src/system/boot/loader/partitions.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2003-2008, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2003-2013, Axel Dörfler, axeld@pinc-software.de. * Distributed under the terms of the MIT License. */ @@ -16,7 +16,6 @@ #include #include #include -#include #include "RootFileSystem.h" @@ -212,7 +211,7 @@ Partition::Type() const Partition * Partition::AddChild() { - Partition *child = new Partition(fFD); + Partition *child = new(nothrow) Partition(fFD); TRACE(("%p Partition::AddChild %p\n", this, child)); if (child == NULL) return NULL; @@ -426,7 +425,7 @@ add_partitions_for(int fd, bool mountFileSystems, bool isBootDevice) TRACE(("add_partitions_for(fd = %d, mountFS = %s)\n", fd, mountFileSystems ? "yes" : "no")); - Partition *partition = new Partition(fd); + Partition *partition = new(nothrow) Partition(fd); // set some magic/default values partition->block_size = 512; diff --git a/src/system/boot/loader/stdio.cpp b/src/system/boot/loader/stdio.cpp index ca430ea730..267ddbd46f 100644 --- a/src/system/boot/loader/stdio.cpp +++ b/src/system/boot/loader/stdio.cpp @@ -1,12 +1,11 @@ /* - * Copyright 2003-2006, Axel Dörfler, axeld@pinc-software.de. All rights reserved. + * Copyright 2003-2013, Axel Dörfler, axeld@pinc-software.de. * Distributed under the terms of the MIT License. */ #include #include -#include #include #include diff --git a/src/system/boot/loader/vfs.cpp b/src/system/boot/loader/vfs.cpp index 2740b6ceca..b94e5dd97a 100644 --- a/src/system/boot/loader/vfs.cpp +++ b/src/system/boot/loader/vfs.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2003-2008, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2003-2013, Axel Dörfler, axeld@pinc-software.de. * Distributed under the terms of the MIT License. */ @@ -18,7 +18,6 @@ #include #include #include -#include #include #include "RootFileSystem.h" diff --git a/src/system/kernel/arch/x86/64/arch.S b/src/system/kernel/arch/x86/64/arch.S index baf8d09f4e..3f9b6d1e48 100644 --- a/src/system/kernel/arch/x86/64/arch.S +++ b/src/system/kernel/arch/x86/64/arch.S @@ -253,10 +253,10 @@ FUNCTION(arch_cpu_user_strlcpy): not %rcx # %rcx was 0 and is now max xor %al, %al - movl %rsi, %rdi + movq %rsi, %rdi repnz scasb - movl %rdi, %rsi + movq %rdi, %rsi .L_user_strlcpy_source_done: // Restore the old fault handler diff --git a/src/tests/kits/game/chart/ChartWindow.cpp b/src/tests/kits/game/chart/ChartWindow.cpp index aa182c2236..a3190711c8 100644 --- a/src/tests/kits/game/chart/ChartWindow.cpp +++ b/src/tests/kits/game/chart/ChartWindow.cpp @@ -1171,7 +1171,7 @@ ChartWindow::ButtonPicture(bool active, int32 button_type) than what a standard BButton would allow) with the current value of the star density pourcentage. */ value = (fCurrentSettings.star_density*100 + STAR_DENSITY_MAX/2) / STAR_DENSITY_MAX; - sprintf(word, "%3ld", value); + sprintf(word, "%3" B_PRId32, value); draw_string: fOffwindowButton->SetFont(be_bold_font); fOffwindowButton->SetFontSize(14.0); @@ -2135,7 +2135,7 @@ ChartWindow::SetPatternBits(buffer *buf) That's the main thread controling the animation and synchronising the engine state with the changes coming from the UI. */ -long +int32 ChartWindow::Animation(void *data) { int32 i, cur_4_frames_index, cur_last_fps, count_fps; @@ -2253,7 +2253,7 @@ ChartWindow::Animation(void *data) slave of the Animation thread. It's directly synchronised with its master, and will only do some star animation processing whenever its master allows him to do so. */ -long +int32 ChartWindow::Animation2(void *data) { ChartWindow *w = (ChartWindow*)data; diff --git a/src/tests/kits/game/chart/ChartWindow.h b/src/tests/kits/game/chart/ChartWindow.h index 51a430a477..659c51735b 100644 --- a/src/tests/kits/game/chart/ChartWindow.h +++ b/src/tests/kits/game/chart/ChartWindow.h @@ -292,8 +292,8 @@ static BWindow *GetAppWindow(const char *name); /* Engine processing related functions. */ /* those functions are the two processing threads launcher */ -static long Animation(void *data); -static long Animation2(void *data); +static int32 Animation(void *data); +static int32 Animation2(void *data); /* After every camera move or rotation, reprocess the torus cycle of the starfield to maintain the pyramid of vision of the camera completly inside a 1x1x1 iteration of the