From 4fad6eb32d8af6e9c523bb66d00a2ff4d4890105 Mon Sep 17 00:00:00 2001 From: PulkoMandy Date: Mon, 31 Oct 2022 01:04:43 +0100 Subject: [PATCH 01/10] Tracker: fix thumbnail caching system_time returns the number of microseconds since booting. This is not what's needed for the thumbnail generation timestamp attribute, as a result the attribute was always considered out of date and the stored attribute would never be used. Change-Id: I3728077c484f341b765700532d3f986e64f165ad Reviewed-on: https://review.haiku-os.org/c/haiku/+/5767 Tested-by: Commit checker robot Reviewed-by: waddlesplash Reviewed-by: John Scipione --- src/kits/tracker/Thumbnails.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kits/tracker/Thumbnails.cpp b/src/kits/tracker/Thumbnails.cpp index bb997131a6..3e7d71724f 100644 --- a/src/kits/tracker/Thumbnails.cpp +++ b/src/kits/tracker/Thumbnails.cpp @@ -224,7 +224,7 @@ GenerateThumbnailJob::Execute() thumbnailWritten = (status == B_OK); // write thumbnail creation time into an attribute - bigtime_t created = system_time(); + bigtime_t created = real_time_clock_usecs(); fFile->WriteAttr(kAttrThumbnailCreationTime, B_TIME_TYPE, 0, &created, sizeof(bigtime_t)); } From dfd7e48a6c3e531fad6e3fe5f5586eed3d5ee0a7 Mon Sep 17 00:00:00 2001 From: Oscar Lesta Date: Mon, 31 Oct 2022 01:51:40 -0300 Subject: [PATCH 02/10] Partitioner: fixed warnings, and usage of BPartition::ContentName() Not particularly high priority (this being a test) but... I came across these while searching for code still needing updates after the changes on BPartition::ContentName(). Change-Id: I05e8d6c02ba34688cee4f0b55e4e782243b0af4d Reviewed-on: https://review.haiku-os.org/c/haiku/+/5769 Tested-by: Commit checker robot Reviewed-by: waddlesplash --- src/tests/apps/partitioner/Partitioner.cpp | 36 +++++++++++----------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/tests/apps/partitioner/Partitioner.cpp b/src/tests/apps/partitioner/Partitioner.cpp index adb93fcef1..461427f6be 100644 --- a/src/tests/apps/partitioner/Partitioner.cpp +++ b/src/tests/apps/partitioner/Partitioner.cpp @@ -81,7 +81,7 @@ public: pathString = path.Path(); else pathString = strerror(error); - printf("device %ld: \"%s\"\n", device->ID(), pathString); + printf("device %" B_PRId32 ": \"%s\"\n", device->ID(), pathString); printf(" has media: %d\n", device->HasMedia()); printf(" removable: %d\n", device->IsRemovableMedia()); printf(" read only: %d\n", device->IsReadOnlyMedia()); @@ -103,14 +103,14 @@ public: pathString = path.Path(); else pathString = strerror(error); - printf("%spartition %ld: \"%s\"\n", prefix, partition->ID(), + printf("%spartition %" B_PRId32 ": \"%s\"\n", prefix, partition->ID(), pathString); } - printf("%s offset: %lld\n", prefix, partition->Offset()); - printf("%s size: %lld\n", prefix, partition->Size()); - printf("%s block size: %lu\n", prefix, partition->BlockSize()); - printf("%s index: %ld\n", prefix, partition->Index()); - printf("%s status: %lu\n", prefix, partition->Status()); + printf("%s offset: %" B_PRId64 "\n", prefix, partition->Offset()); + printf("%s size: %" B_PRId64 "\n", prefix, partition->Size()); + printf("%s block size: %" B_PRIu32 "\n", prefix, partition->BlockSize()); + printf("%s index: %" B_PRId32 "\n", prefix, partition->Index()); + printf("%s status: %" B_PRIu32 "\n", prefix, partition->Status()); printf("%s file system: %d\n", prefix, partition->ContainsFileSystem()); printf("%s part. system: %d\n", prefix, @@ -118,10 +118,10 @@ public: printf("%s device: %d\n", prefix, partition->IsDevice()); printf("%s read only: %d\n", prefix, partition->IsReadOnly()); printf("%s mounted: %d\n", prefix, partition->IsMounted()); - printf("%s flags: %lx\n", prefix, partition->Flags()); + printf("%s flags: %" B_PRIx32 "\n", prefix, partition->Flags()); printf("%s name: \"%s\"\n", prefix, partition->Name()); printf("%s content name: \"%s\"\n", prefix, - partition->ContentName()); + partition->ContentName().String()); printf("%s type: \"%s\"\n", prefix, partition->Type()); printf("%s content type: \"%s\"\n", prefix, partition->ContentType()); @@ -156,7 +156,7 @@ print_partition(BPartition* partition, int level, int index) 2 * max_c(3 - level, 0), "", offset.String(), size.String(), (partition->ContentType() ? partition->ContentType() : "-"), - (partition->ContentName() ? partition->ContentName() : "")); + partition->ContentName().String()); } @@ -198,7 +198,7 @@ public: readWrite = ""; } - printf("\ndevice %ld: \"%s\": %s%s\n\n", device->ID(), pathString, + printf("\ndevice %" B_PRId32 ": \"%s\": %s%s\n\n", device->ID(), pathString, media, readWrite); print_partition_table_header(); @@ -360,7 +360,7 @@ private: // print the available disk systems printf("\ndisk systems that can initialize the selected partition:\n"); for (int32 i = 0; BDiskSystem* diskSystem = diskSystems.ItemAt(i); i++) - printf("%2ld %s\n", i, diskSystem->PrettyName()); + printf("%2" B_PRId32 " %s\n", i, diskSystem->PrettyName()); printf("\n"); @@ -378,7 +378,7 @@ private: BString parameters; while (true) { // let the user enter name and parameters - if (supportsName && !_ReadLine("partition name: ", name) + if ((supportsName && !_ReadLine("partition name: ", name)) || !_ReadLine("partition parameters: ", parameters)) { return; } @@ -497,7 +497,7 @@ private: // list them printf("Possible partition types:\n"); for (int32 i = 0; i < supportedTypesCount; i++) - printf("%2ld %s\n", i, supportedTypes.ItemAt(i)->String()); + printf("%2" B_PRId32 " %s\n", i, supportedTypes.ItemAt(i)->String()); if (!_ReadNumber("supported type index [-1 to abort]: ", 0, supportedTypesCount - 1, -1, "invalid index", typeIndex)) { @@ -516,7 +516,7 @@ private: BString offset, size; get_size_string(_offset, offset); get_size_string(_size, size); - printf("%2ld start: %8s, size: %8s\n", i, offset.String(), + printf("%2" B_PRId32 " start: %8s, size: %8s\n", i, offset.String(), size.String()); } @@ -594,7 +594,7 @@ private: get_size_string(validatedStart, startString); get_size_string(validatedSize, sizeString); printf("The disk system adjusted the partition start and " - "size to %lld (%s) and %lld (%s).\n", + "size to %" B_PRIdOFF " (%s) and %" B_PRIdOFF " (%s).\n", validatedStart, startString.String(), validatedSize, sizeString.String()); start = validatedStart; @@ -713,7 +713,7 @@ private: return false; char buffer[256]; - if (sscanf(line.String(), "%lld%s", &number, buffer) == 1) + if (sscanf(line.String(), "%" B_PRId64 "%s", &number, buffer) == 1) return true; printf("invalid input\n"); @@ -729,7 +729,7 @@ private: return false; char buffer[256]; - if (sscanf(line.String(), "%lld%s", &number, buffer) != 1) { + if (sscanf(line.String(), "%" B_PRId64 "%s", &number, buffer) != 1) { printf("invalid input\n"); continue; } From 62b6a4c615f44a958ffdc725079d9d392a930eee Mon Sep 17 00:00:00 2001 From: Oscar Lesta Date: Mon, 31 Oct 2022 02:34:58 -0300 Subject: [PATCH 03/10] mount_server: BPartition::ContentName() returns a BString now. Change-Id: I9a236f6a28826d9394265081c3ebf6e96290fa54 Reviewed-on: https://review.haiku-os.org/c/haiku/+/5770 Reviewed-by: waddlesplash Tested-by: Commit checker robot --- src/servers/mount/AutoMounter.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/servers/mount/AutoMounter.cpp b/src/servers/mount/AutoMounter.cpp index a9d9a9de82..512ff76ff5 100644 --- a/src/servers/mount/AutoMounter.cpp +++ b/src/servers/mount/AutoMounter.cpp @@ -210,10 +210,9 @@ MountVisitor::_WasPreviouslyMounted(const BPath& path, // We only check the legacy config data here; the current method // is implemented in ArchivedVolumeVisitor -- this can be removed // some day. - const char* volumeName = NULL; - if (partition->ContentName() == NULL - || fPrevious.FindString(path.Path(), &volumeName) != B_OK - || strcmp(volumeName, partition->ContentName()) != 0) + BString volumeName; + if (fPrevious.FindString(path.Path(), &volumeName) != B_OK + || volumeName != partition->ContentName()) return false; return true; From 7b3e89c0944ae1efa9a8fc66c7303874b7a344b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1ximo=20Casta=C3=B1eda?= Date: Mon, 31 Oct 2022 21:11:08 +0100 Subject: [PATCH 04/10] PoorMan: some libhttpd fixes The last thttpd update was less than perfect. A bad format string was causing crashes on directory listings, and some of our changes were removed, like PoorMan's setting for directory listings, leaks and thread safety. Fixes: #17329 Change-Id: I84d9862a0ebd5492a2542cf9776462e7fe7dbe77 Reviewed-on: https://review.haiku-os.org/c/haiku/+/5772 Tested-by: Commit checker robot Reviewed-by: waddlesplash --- src/apps/poorman/libhttpd/libhttpd.c | 48 ++++++++++++++++------------ 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/src/apps/poorman/libhttpd/libhttpd.c b/src/apps/poorman/libhttpd/libhttpd.c index 13e3aca197..8d8f67923f 100644 --- a/src/apps/poorman/libhttpd/libhttpd.c +++ b/src/apps/poorman/libhttpd/libhttpd.c @@ -2725,19 +2725,19 @@ ls( httpd_conn* hc ) int namlen; /*static*/int maxnames = 0; int nnames; - /*static*/char* names; - /*static*/char** nameptrs; - /*static*/char* name; + /*static*/char* names = NULL; + /*static*/char** nameptrs = NULL; + /*static*/char* name = NULL; /*static*/size_t maxname = 0; - /*static*/char* rname; + /*static*/char* rname = NULL; /*static*/size_t maxrname = 0; - /*static*/char* encrname; + /*static*/char* encrname = NULL; /*static*/size_t maxencrname = 0; FILE* fp; int i/*, r*/; struct stat sb; struct stat lsb; - //char modestr[20]; + char modestr[20]; char* linkprefix; char lnk[MAXPATHLEN+1]; int linklen; @@ -2763,6 +2763,7 @@ ls( httpd_conn* hc ) send_mime( hc, 200, ok200title, "", "", "text/html; charset=%s", (off_t) -1, hc->sb.st_mtime ); + httpd_write_response( hc ); } else if ( hc->method == METHOD_GET ) { @@ -2856,7 +2857,8 @@ mode links bytes last-changed name\n\ if ( names == (char*) 0 || nameptrs == (char**) 0 ) { // syslog( LOG_ERR, "out of memory reallocating directory names" ); - exit( 1 ); + closedir( dirp ); + return -1; } for ( i = 0; i < maxnames; ++i ) nameptrs[i] = &names[i * ( MAXPATHLEN + 1 )]; @@ -2909,13 +2911,13 @@ mode links bytes last-changed name\n\ /* Break down mode word. First the file type. */ switch ( lsb.st_mode & S_IFMT ) { - /*case S_IFIFO: modestr[0] = 'p'; break; + case S_IFIFO: modestr[0] = 'p'; break; case S_IFCHR: modestr[0] = 'c'; break; case S_IFDIR: modestr[0] = 'd'; break; case S_IFBLK: modestr[0] = 'b'; break; case S_IFREG: modestr[0] = '-'; break; - case S_IFSOCK: modestr[0] = 's'; break;*/ - case S_IFLNK: //modestr[0] = 'l'; + case S_IFSOCK: modestr[0] = 's'; break; + case S_IFLNK: modestr[0] = 'l'; linklen = readlink( name, lnk, sizeof(lnk) - 1 ); if ( linklen != -1 ) { @@ -2923,15 +2925,15 @@ mode links bytes last-changed name\n\ linkprefix = " -> "; } break; - //default: modestr[0] = '?'; break; + default: modestr[0] = '?'; break; } /* Now the world permissions. Owner and group permissions ** are not of interest to web clients. */ - /*modestr[1] = ( lsb.st_mode & S_IROTH ) ? 'r' : '-'; + modestr[1] = ( lsb.st_mode & S_IROTH ) ? 'r' : '-'; modestr[2] = ( lsb.st_mode & S_IWOTH ) ? 'w' : '-'; modestr[3] = ( lsb.st_mode & S_IXOTH ) ? 'x' : '-'; - modestr[4] = '\0';*/ + modestr[4] = '\0'; /* We also leave out the owner and group name, they are ** also not of interest to web clients. Plus if we're @@ -2971,28 +2973,25 @@ mode links bytes last-changed name\n\ switch ( sb.st_mode & S_IFMT ) { case S_IFDIR: fileclass = "/"; break; - //case S_IFSOCK: fileclass = "="; break; - //case S_IFLNK: fileclass = "@"; break; + case S_IFSOCK: fileclass = "="; break; + case S_IFLNK: fileclass = "@"; break; default: - fileclass = "";//( sb.st_mode & S_IXOTH ) ? "*" : ""; + fileclass = ( sb.st_mode & S_IXOTH ) ? "*" : ""; break; } /* And print. */ (void) fprintf( fp, "%s %3ld %10lld %s %.80s%s%s%s\n", - /*modestr,*/ (long) lsb.st_nlink, (long long) lsb.st_size, + modestr, (long) lsb.st_nlink, (long long) lsb.st_size, timestr, encrname, S_ISDIR(sb.st_mode) ? "/" : "", nameptrs[i], linkprefix, lnk, fileclass ); } (void) fprintf( fp, " \n \n\n" ); (void) fclose( fp ); - exit( 0 ); // } - /* Parent process. */ - closedir( dirp ); // syslog( LOG_DEBUG, "spawned indexing process %d for directory '%.200s'", r, hc->expnfilename ); #ifdef CGI_TIMELIMIT /* Schedule a kill for the child process, in case it runs too long */ @@ -3006,6 +3005,12 @@ mode links bytes last-changed name\n\ hc->status = 200; hc->bytes_sent = CGI_BYTECOUNT; hc->should_linger = 0; + + free(names); + free(nameptrs); + free(name); + free(rname); + free(encrname); } else { @@ -3730,6 +3735,7 @@ really_start_request( httpd_conn* hc, struct timeval* nowP ) free(indexname); /* Nope, no index file, so it's an actual directory request. */ #ifdef GENERATE_INDEXES +if(hc->hs->do_list_dir){ /* Directories must be readable for indexing. */ if ( ! ( hc->sb.st_mode & S_IROTH ) ) { @@ -3754,6 +3760,7 @@ free(indexname); /* Ok, generate an index. */ return ls( hc ); //#else /* GENERATE_INDEXES */ +} else { // syslog( // LOG_INFO, "%.80s URL \"%.80s\" tried to index a directory", // httpd_ntoa( &hc->client_addr ), hc->encodedurl ); @@ -3762,6 +3769,7 @@ free(indexname); ERROR_FORM( err403form, "The requested URL '%.80s' is a directory, and directory indexing is disabled on this server.\n" ), hc->encodedurl ); return -1; +} #endif /* GENERATE_INDEXES */ got_one: ; From 20136c336cb044bc813052eb4c2cdef24392951d Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Mon, 31 Oct 2022 23:29:20 -0400 Subject: [PATCH 05/10] docs/develop: Linkify version-change hrev. --- docs/develop/release/milestones.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/develop/release/milestones.rst b/docs/develop/release/milestones.rst index 298c746374..a84d9d61d4 100644 --- a/docs/develop/release/milestones.rst +++ b/docs/develop/release/milestones.rst @@ -36,7 +36,7 @@ Branch **Time:** ~ 1 week -* Update the version constants in master (example: hrev52295) +* Update the version constants in master (`example: hrev52295 `_) * Branch haiku and buildtools (git push origin master:r1beta1) * Update the version constants in the branch (`example `_) * Update copyright years in the `bootloader menu `_ From baf401757e6811c48aab87971a07e02476db11b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1ximo=20Casta=C3=B1eda?= Date: Wed, 31 Aug 2022 13:20:26 +0200 Subject: [PATCH 06/10] HaikuBook: small list levels and grammar tweaks Change-Id: I186e38108a57a8a8b82dbfbdf27766730fe659e4 Reviewed-on: https://review.haiku-os.org/c/haiku/+/5774 Tested-by: Commit checker robot Reviewed-by: Oscar Lesta Reviewed-by: waddlesplash --- docs/user/apidoc.dox | 39 ++++++++++++------------ docs/user/book.dox | 12 ++++---- docs/user/interface/_interface_intro.dox | 2 +- 3 files changed, 27 insertions(+), 26 deletions(-) diff --git a/docs/user/apidoc.dox b/docs/user/apidoc.dox index 81ba8569c9..bbe0c820b6 100644 --- a/docs/user/apidoc.dox +++ b/docs/user/apidoc.dox @@ -200,10 +200,10 @@ There are two different cases where you must or could use these blocks: - 1. For non-public API of a public header file, you must always - add the classes and other elements to the documentation (even if they) + -# For non-public API of a public header file, you must always + add the classes and other elements to the documentation even if they are placeholders, and put them in the conditional block. - 2. For parts of the non-public API that is in a private header + -# For parts of the non-public API that is in a private header file, you could put the documentation in a conditional block. If you choose to do so, you must document all elements in that header file. @@ -226,13 +226,13 @@ - \ - The argument is a single word. - (until the end of the line) - The argument runs until the end of the line. - {paragraph} - The argument runs for an entire paragraph. A paragraph is - ended by an empty line, or if another command that defines a \ref - commands_sections sections is found. Note that if you use commands that - work on a paragraph and you split it over multiple lines (because of the - maximum line width of 80 characters or because it looks better), you - will have to indent subsequent lines that belong to the paragraph with - two more spaces, making the total of four. This is to visually - distinguish paragraphs for other documenters. + ended by an empty line, or if another command that defines a \link + commands_sections section \endlink is found. Note that if you use + commands that work on a paragraph and you split it over multiple lines + (because of the maximum line width of 80 characters or because it looks + better), you will have to indent subsequent lines that belong to the + paragraph with two more spaces, making the total of four. This is to + visually distinguish paragraphs for other documenters. \subsection commands_definitions Block Definitions @@ -273,8 +273,8 @@ If you have a look at the output that Doxygen generates, you can see that there are recurring sections in the documentation. Documentation that belongs to a certain section should be placed after a command that marks the - start of that section. All the commands take a paragraph as answer. A - paragraph ends with a whitespace, or with a command that marks a new + start of that section. All the commands take a paragraph as argument. A + paragraph ends with an empty line, or with a command that marks a new section. Note that this list only shows the syntax of the commands. For the semantics, have a look at the next section on style. In member documentation you can use the following: @@ -423,7 +423,7 @@ you will end up using every now and then. This section will describe those commands. - The first one is \c \\n. This commands sort of belongs to the category of + The first one is \c \\n. This command sort of belongs to the category of markup commands. It basically forces a newline. Because Doxygen parses paragraphs as a single contiguous entity, it's not possible to mark up the text using carriage returns in the documentation. \c \\n forces a newline in @@ -453,8 +453,8 @@ Finally, it is a good idea to link between parts of the documentation. There are two commands for that. The first one is \c \\ref, which enable you to refer to pages, sections, etc. that you created yourself. The second one is - \c \\link which refers to members. The first one is takes one word as an - argument, the name of the section, and it inserts a link with the name of + \c \\link which refers to members. The first one takes one word as an + argument, the name of the section, and it inserts a link with the text of the title. \c \\link is more complex. It should always be accompanied by \c \\endlink. The first word between the two commands is the object that is referred to, and the rest is the link text. @@ -595,7 +595,7 @@ -# End with a list of references to other classes, functions, pages, etc. that might be of interest to the reader. - When documenting classes, don't be to exhaustive. Avoid becoming a tutorial + When documenting classes, don't be too exhaustive. Avoid becoming a tutorial or a complete guide. This documentation is for reference only. If you want to enlighten the reader on bigger subjects, consider writing a separate documentation page that connects the different points you want to make. @@ -623,7 +623,8 @@ clear description. The description starts with a capital letter and ends with a dot. Don't write the description saying what the method does, like "Starts the timer", but rather as what it will do: "Start the - timer." -# If the brief description doesn't cover all of what the method + timer." + -# If the brief description doesn't cover all of what the method or function does, then you can add a few paragraphs that explain it in more depth. Don't be too verbose, and use an example to illustrate points. Point out any potential misunderstandings or problems you expect @@ -646,7 +647,7 @@ In case of overloaded members, you'll need to make a decision. If you need to copy too much information, you might resort to putting it in one paragraph with the text "This is an overloaded member function, and differs - from \ only by the type of parameter it takes." That will keep the + from only by the type of parameter it takes." That will keep the copying down and will point developers right to the place where they can get more documentation. @@ -693,7 +694,7 @@ depend on this variable. Defines are usually used as message constants. Give a short description of - what the message constant stands for, and where it might be send from and + what the message constant stands for, and where it might be sent from and where it might be received. Enumerations can either be anonymous or named. In case of the latter, you diff --git a/docs/user/book.dox b/docs/user/book.dox index 18de7e9c71..3347c4f612 100644 --- a/docs/user/book.dox +++ b/docs/user/book.dox @@ -502,13 +502,13 @@ snooze_until(time - Latency(), B_SYSTEM_TIMEBASE); prevent this, Haiku implements a \"locking\" mechanism, allowing one thread to \"lock out\" other threads from executing code that might modify the same data. - - \b Archiving \b and \b IO. These classes allow a programmer to + - \b Archiving \b and \b IO. These classes allow a programmer to convert objects into a form that can more easily be transferred to other applications or stored to disk, as well as performing basic input and output operations. - - \b Memory \b Allocation. This class allows a programmer to hand off + - \b Memory \b Allocation. This class allows a programmer to hand off some of the duties of memory accounting and management. - - \b Common \b Datatypes. To avoid unnecessary duplication of code + - \b Common \b Datatypes. To avoid unnecessary duplication of code and to make life easier for programmers, Haiku includes classes that handle management of ordered lists and strings. @@ -551,9 +551,9 @@ snooze_until(time - Latency(), B_SYSTEM_TIMEBASE); - BString allows strings and provides common access, modification, and comparison functions. - BStopWatch allows an application to measure the time an action takes. - - \ref support_globals "Global functions" - - \ref TypeConstants.h "Common types and constants" - - Error codes for all kits + - \ref support_globals "Global functions" + - \ref TypeConstants.h "Common types and constants" + - Error codes for all kits \defgroup translation Translation Kit diff --git a/docs/user/interface/_interface_intro.dox b/docs/user/interface/_interface_intro.dox index c1ca9fe0fe..e2ef3ada83 100644 --- a/docs/user/interface/_interface_intro.dox +++ b/docs/user/interface/_interface_intro.dox @@ -43,7 +43,7 @@ The initial coordinate space, from which all others are derived, is the screen space. Its origin is at the center of the screen's top-left pixel. Coordinates can be converted between this and a specific window or view - space is done using the ConvertToScreen and ConvertFromScreen methods of + space using the ConvertToScreen and ConvertFromScreen methods of the corresponding object. Each BWindow has its own coordinate space. Its origin is at the center of From b71020b09540dc7b661834240cbfa1873e5c9a0c Mon Sep 17 00:00:00 2001 From: X512 Date: Wed, 2 Nov 2022 07:11:10 +0900 Subject: [PATCH 07/10] util/DoublyLinkedList: make GetPrevious/GetNext methods static This methods do not need DoublyLinkedList class state. sGetLink field that actually implement GetPrevious/GetNext methods is already static. Change-Id: Ie0b40f7f1b72d640d75403905b8944666874dc87 Reviewed-on: https://review.haiku-os.org/c/haiku/+/5796 Tested-by: Commit checker robot Reviewed-by: waddlesplash --- headers/private/kernel/util/DoublyLinkedList.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/headers/private/kernel/util/DoublyLinkedList.h b/headers/private/kernel/util/DoublyLinkedList.h index f796bfa3ea..ce6845e3e2 100644 --- a/headers/private/kernel/util/DoublyLinkedList.h +++ b/headers/private/kernel/util/DoublyLinkedList.h @@ -356,8 +356,8 @@ public: inline Element* RemoveHead(); inline Element* RemoveTail(); - inline Element* GetPrevious(Element* element) const; - inline Element* GetNext(Element* element) const; + static inline Element* GetPrevious(Element* element); + static inline Element* GetNext(Element* element); inline bool Contains(Element* element) const; // O(n)! @@ -605,7 +605,7 @@ DOUBLY_LINKED_LIST_CLASS_NAME::RemoveTail() // GetPrevious DOUBLY_LINKED_LIST_TEMPLATE_LIST Element* -DOUBLY_LINKED_LIST_CLASS_NAME::GetPrevious(Element* element) const +DOUBLY_LINKED_LIST_CLASS_NAME::GetPrevious(Element* element) { Element* result = NULL; if (element) @@ -616,7 +616,7 @@ DOUBLY_LINKED_LIST_CLASS_NAME::GetPrevious(Element* element) const // GetNext DOUBLY_LINKED_LIST_TEMPLATE_LIST Element* -DOUBLY_LINKED_LIST_CLASS_NAME::GetNext(Element* element) const +DOUBLY_LINKED_LIST_CLASS_NAME::GetNext(Element* element) { Element* result = NULL; if (element) From 4f18dc04961d4aebde79313f24e9cfa1ae3a1e53 Mon Sep 17 00:00:00 2001 From: Zelenoviy Date: Tue, 1 Nov 2022 03:26:55 +0700 Subject: [PATCH 08/10] usb_hid: Fix MaxReportSize computation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While calculating buffer size for IN reports, only "Input" report type should been taken in account. Complex HID devices, such as "Gaming" keyboards and mice, often have "Feature"-reports declared (with size way bigger than "typical" kbd IN report) for vendor-specific device configurations. But "Feature"-reports are sent over control channel only and can't appear on interrupt channel. Should fix #14919, #17937, #17699 Change-Id: I4b9eb51938ca4aba2bc34247d00ae164eb2c19fc Reviewed-on: https://review.haiku-os.org/c/haiku/+/5771 Reviewed-by: Jérôme Duval Tested-by: Commit checker robot --- .../kernel/drivers/input/hid_shared/HIDParser.cpp | 10 ++++++++++ .../kernel/drivers/input/hid_shared/HIDParser.h | 1 + .../input/hid_shared/KeyboardProtocolHandler.cpp | 5 +++-- src/add-ons/kernel/drivers/input/usb_hid/HIDDevice.cpp | 2 +- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/add-ons/kernel/drivers/input/hid_shared/HIDParser.cpp b/src/add-ons/kernel/drivers/input/hid_shared/HIDParser.cpp index aaef7dce68..05d8729d2e 100644 --- a/src/add-ons/kernel/drivers/input/hid_shared/HIDParser.cpp +++ b/src/add-ons/kernel/drivers/input/hid_shared/HIDParser.cpp @@ -430,6 +430,13 @@ HIDParser::ReportAt(uint8 type, uint8 index) size_t HIDParser::MaxReportSize() +{ + return MaxReportSize(HID_REPORT_TYPE_ANY); +} + + +size_t +HIDParser::MaxReportSize(uint8 type) { size_t maxSize = 0; for (int32 i = 0; i < fReports.Count(); i++) { @@ -437,6 +444,9 @@ HIDParser::MaxReportSize() if (report == NULL) continue; + if (type != HID_REPORT_TYPE_ANY && report->Type() != type) + continue; + if (report->ReportSize() > maxSize) maxSize = report->ReportSize(); } diff --git a/src/add-ons/kernel/drivers/input/hid_shared/HIDParser.h b/src/add-ons/kernel/drivers/input/hid_shared/HIDParser.h index 75f1101158..b8523eb431 100644 --- a/src/add-ons/kernel/drivers/input/hid_shared/HIDParser.h +++ b/src/add-ons/kernel/drivers/input/hid_shared/HIDParser.h @@ -30,6 +30,7 @@ public: uint8 CountReports(uint8 type); HIDReport * ReportAt(uint8 type, uint8 index); size_t MaxReportSize(); + size_t MaxReportSize(uint8 type); HIDCollection * RootCollection() { return fRootCollection; }; diff --git a/src/add-ons/kernel/drivers/input/hid_shared/KeyboardProtocolHandler.cpp b/src/add-ons/kernel/drivers/input/hid_shared/KeyboardProtocolHandler.cpp index ad3128b482..da6619f109 100644 --- a/src/add-ons/kernel/drivers/input/hid_shared/KeyboardProtocolHandler.cpp +++ b/src/add-ons/kernel/drivers/input/hid_shared/KeyboardProtocolHandler.cpp @@ -110,7 +110,8 @@ KeyboardProtocolHandler::KeyboardProtocolHandler(HIDReport &inputReport, #ifdef USB_KDL sDebugKeyboardPipe = fInputReport.Device()->InterruptPipe(); #endif - sDebugKeyboardReportSize = fInputReport.Parser()->MaxReportSize(); + sDebugKeyboardReportSize = + fInputReport.Parser()->MaxReportSize(HID_REPORT_TYPE_INPUT); if (outputReport != NULL) sDebugKeyboardFound = true; } @@ -794,7 +795,7 @@ KeyboardProtocolHandler::_ReadReport(bigtime_t timeout, uint32 *cookie) = fInputReport.Device()->InterruptPipe(); #endif sDebugKeyboardReportSize - = fInputReport.Parser()->MaxReportSize(); + = fInputReport.Parser()->MaxReportSize(HID_REPORT_TYPE_INPUT); #endif char letter = current[i] - 4 + 'a'; diff --git a/src/add-ons/kernel/drivers/input/usb_hid/HIDDevice.cpp b/src/add-ons/kernel/drivers/input/usb_hid/HIDDevice.cpp index cbce1e65ee..7902bbf5ff 100644 --- a/src/add-ons/kernel/drivers/input/usb_hid/HIDDevice.cpp +++ b/src/add-ons/kernel/drivers/input/usb_hid/HIDDevice.cpp @@ -181,7 +181,7 @@ HIDDevice::HIDDevice(usb_device device, const usb_configuration_info *config, return; } - fTransferBufferSize = fParser.MaxReportSize(); + fTransferBufferSize = fParser.MaxReportSize(HID_REPORT_TYPE_INPUT); if (fTransferBufferSize == 0) { TRACE_ALWAYS("report claims a report size of 0\n"); return; From afe965f464ff4c77527f5b6a4990f0bfaae2d202 Mon Sep 17 00:00:00 2001 From: Zelenoviy Date: Tue, 1 Nov 2022 03:58:25 +0700 Subject: [PATCH 09/10] usb_hid: properly device remove handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Small fix to device remove handling, when multiple hid-devices published on multiple interfaces. Fixes #18008. Change-Id: I64e1a9fb6cbac503e3d55b51ee0539bb6f1908e4 Reviewed-on: https://review.haiku-os.org/c/haiku/+/5773 Tested-by: Commit checker robot Reviewed-by: Jérôme Duval --- src/add-ons/kernel/drivers/input/usb_hid/Driver.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/add-ons/kernel/drivers/input/usb_hid/Driver.cpp b/src/add-ons/kernel/drivers/input/usb_hid/Driver.cpp index a1435c457c..deccd43550 100644 --- a/src/add-ons/kernel/drivers/input/usb_hid/Driver.cpp +++ b/src/add-ons/kernel/drivers/input/usb_hid/Driver.cpp @@ -192,6 +192,8 @@ usb_hid_device_removed(void *cookie) int32 parentCookie = (int32)(addr_t)cookie; TRACE("device_removed(%" B_PRId32 ")\n", parentCookie); + // removed device may contain multiple HID devices on multiple interfaces + // we must go through all published devices and remove all that belong to this parent for (int32 i = 0; i < gDeviceList->CountDevices(); i++) { ProtocolHandler *handler = (ProtocolHandler *)gDeviceList->DeviceAt(i); if (!handler) @@ -202,12 +204,13 @@ usb_hid_device_removed(void *cookie) continue; // remove all the handlers - for (uint32 i = 0;; i++) { - handler = device->ProtocolHandlerAt(i); + for (uint32 j = 0;; j++) { + handler = device->ProtocolHandlerAt(j); if (handler == NULL) break; gDeviceList->RemoveDevice(NULL, handler); + i--; // device count changed, adjust index } // this handler's device belongs to the one removed @@ -216,8 +219,6 @@ usb_hid_device_removed(void *cookie) device->Removed(); } else delete device; - - break; } mutex_unlock(&sDriverLock); From 8672fc2739b8601218f6d0f83a4fe492b7ffb5ae Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Wed, 28 Sep 2022 20:03:59 -0400 Subject: [PATCH 10/10] InterfaceDefs: Adjust and introduce new spacing/insets constants. * Nothing in the tree and few things outside it used BIG_{SPACING|INSETS}; it seems a value of 15px (at default font size) is not that useful. There are, however, a lot of things around the tree that use multiples of 20px. So, make BIG be that, with the intent to replace those with BIG directly. * Introduce CORNER_{SPACING|INSETS}. There are a lot of applications (e.g. Tracker, Terminal, Debugger etc.) which use scroll bar width/height to metrically align controls with the window frame or with some other control which contains scroll bars. Rather than have to invoke BScrollBar or BControlLook directly to get the value, we should just derive the size of scrollbars from a spacing constant instead and get rid of the custom function. (For now it is just replaced.) This reuses the old values for BIG, as it is equal to 14px at default. * Introduce BORDER_{SPACING|INSETS}. This is equal to the typical border size of 1px at default font size (or lower) and uses floor() instead of ciel() to compute what the size should be (i.e. it will remain 1px at 150%/18pt and only go up at 200%/24pt.) This will allow a lot of the hardcoded border sizes around the tree and elsewhere to use ComposeSpacing() instead. Change-Id: Iaea3fa30364859888e816a9d61ac156268d70758 Reviewed-on: https://review.haiku-os.org/c/haiku/+/5702 Reviewed-by: waddlesplash Reviewed-by: nephele Tested-by: Commit checker robot --- headers/os/interface/InterfaceDefs.h | 6 +++++- headers/private/interface/HaikuControlLook.h | 2 -- src/kits/interface/ControlLook.cpp | 14 ++++++++------ src/kits/interface/HaikuControlLook.cpp | 11 ----------- 4 files changed, 13 insertions(+), 20 deletions(-) diff --git a/headers/os/interface/InterfaceDefs.h b/headers/os/interface/InterfaceDefs.h index d692a0127a..c5a59b8a80 100644 --- a/headers/os/interface/InterfaceDefs.h +++ b/headers/os/interface/InterfaceDefs.h @@ -239,8 +239,12 @@ enum { B_USE_WINDOW_INSETS = B_USE_WINDOW_SPACING, B_USE_SMALL_SPACING = -1006, B_USE_SMALL_INSETS = B_USE_SMALL_SPACING, - B_USE_BIG_SPACING = -1007, + B_USE_CORNER_SPACING = -1007, + B_USE_CORNER_INSETS = B_USE_CORNER_SPACING, + B_USE_BIG_SPACING = -1008, B_USE_BIG_INSETS = B_USE_BIG_SPACING, + B_USE_BORDER_SPACING = -1009, + B_USE_BORDER_INSETS = B_USE_BORDER_SPACING, }; diff --git a/headers/private/interface/HaikuControlLook.h b/headers/private/interface/HaikuControlLook.h index b8edf7f152..be6f9c624d 100644 --- a/headers/private/interface/HaikuControlLook.h +++ b/headers/private/interface/HaikuControlLook.h @@ -337,8 +337,6 @@ public: uint32 flags = 0, uint32 borders = B_ALL_BORDERS, orientation orientation = B_HORIZONTAL); - virtual float GetScrollBarWidth( - orientation orientation = B_VERTICAL); protected: void _DrawButtonFrame(BView* view, BRect& rect, diff --git a/src/kits/interface/ControlLook.cpp b/src/kits/interface/ControlLook.cpp index 6081cffded..85f882048b 100644 --- a/src/kits/interface/ControlLook.cpp +++ b/src/kits/interface/ControlLook.cpp @@ -3,9 +3,9 @@ * Distributed under the terms of the MIT License. */ - #include +#include #include @@ -37,8 +37,13 @@ BControlLook::ComposeSpacing(float spacing) return be_control_look->DefaultItemSpacing(); case B_USE_SMALL_SPACING: return ceilf(be_control_look->DefaultItemSpacing() * 0.7f); + case B_USE_CORNER_SPACING: + return ceilf(be_control_look->DefaultItemSpacing() * 1.273f); case B_USE_BIG_SPACING: - return ceilf(be_control_look->DefaultItemSpacing() * 1.3f); + return ceilf(be_control_look->DefaultItemSpacing() * 1.8f); + + case B_USE_BORDER_SPACING: + return std::max(1.0f, floorf(be_control_look->DefaultItemSpacing() / 11.0f)); } return spacing; @@ -86,10 +91,7 @@ BControlLook::GetInsets(frame_type frameType, background_type backgroundType, float BControlLook::GetScrollBarWidth(orientation orientation) { - // this matches HaikuControlLook.cpp currently - if (be_plain_font->Size() <= 12.0f) - return 14.0f; - return be_plain_font->Size() / 12.0f * 14.0f; + return ComposeSpacing(B_USE_CORNER_SPACING); } diff --git a/src/kits/interface/HaikuControlLook.cpp b/src/kits/interface/HaikuControlLook.cpp index edd31589d1..ab2ef31d8f 100644 --- a/src/kits/interface/HaikuControlLook.cpp +++ b/src/kits/interface/HaikuControlLook.cpp @@ -3840,17 +3840,6 @@ HaikuControlLook::_FillGlossyGradient(BView* view, const BRect& rect, } -float -HaikuControlLook::GetScrollBarWidth(orientation orientation) -{ - // HaikuControlLook does not make a distinction between the - // width and height of the scrollbar, but other controllooks may - if (be_plain_font->Size() <= 12.0f) - return 14.0f; - return be_plain_font->Size() / 12.0f * 14.0f; -} - - void HaikuControlLook::_MakeGradient(BGradientLinear& gradient, const BRect& rect, const rgb_color& base, float topTint, float bottomTint,