Avoid using unions for LongDirEntry.
GCC still assumes that the dirent has no data past the end for some scenarios here and still mis-optimizes things. Therefore, drop the usages of unions altogether, and instead use a casted character array. Additionally, use B_FILE_NAME_LENGTH for the array, not B_PATH_NAME_LENGTH, and make sure to add 1 for the NULL terminator.
This commit is contained in:
@@ -25,9 +25,9 @@ namespace BPrivate {
|
||||
namespace Storage {
|
||||
|
||||
// For convenience:
|
||||
union LongDirEntry {
|
||||
struct dirent dirent;
|
||||
char _[sizeof(struct dirent) + B_PATH_NAME_LENGTH];
|
||||
struct LongDirEntry {
|
||||
char _[sizeof(struct dirent) + B_FILE_NAME_LENGTH + 1];
|
||||
struct dirent* dirent() { return (struct dirent*)_; }
|
||||
};
|
||||
|
||||
//! Returns whether the supplied path is absolute.
|
||||
@@ -73,9 +73,9 @@ void to_lower(const char *str, std::string &result);
|
||||
|
||||
/*! \brief Copies \c str into \c result, converting any uppercase alphabetics
|
||||
to lowercase.
|
||||
|
||||
|
||||
\a str and \a result may point to the same string. \a result is
|
||||
assumed to be as long as or longer than \a str.
|
||||
assumed to be as long as or longer than \a str.
|
||||
*/
|
||||
void to_lower(const char *str, char *result);
|
||||
|
||||
@@ -87,7 +87,7 @@ void to_lower(char *str);
|
||||
\a result must be large enough to accomodate the addition of
|
||||
escape sequences to \a str. \a str and \a result may *NOT* point to
|
||||
the same string.
|
||||
|
||||
|
||||
Note that this function was designed for use with the registrar's
|
||||
RecentEntries class, and may not create escapes exactly like you're
|
||||
hoping. Please double check the code for the function to see if this
|
||||
|
||||
Reference in New Issue
Block a user