mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:37:35 +00:00
AK: Use size_t for the length of strings
Using int was a mistake. This patch changes String, StringImpl, StringView and StringBuilder to use size_t instead of int for lengths. Obviously a lot of code needs to change as a result of this.
This commit is contained in:
parent
1726c17d0d
commit
6f4c380d95
54 changed files with 387 additions and 377 deletions
|
@ -46,7 +46,7 @@ FS::DirectoryEntry::DirectoryEntry(const char* n, InodeIdentifier i, u8 ft)
|
|||
name[name_length] = '\0';
|
||||
}
|
||||
|
||||
FS::DirectoryEntry::DirectoryEntry(const char* n, int nl, InodeIdentifier i, u8 ft)
|
||||
FS::DirectoryEntry::DirectoryEntry(const char* n, size_t nl, InodeIdentifier i, u8 ft)
|
||||
: name_length(nl)
|
||||
, inode(i)
|
||||
, file_type(ft)
|
||||
|
|
|
@ -50,9 +50,9 @@ public:
|
|||
// FIXME: This data structure is very clunky and unpleasant. Replace it with something nicer.
|
||||
struct DirectoryEntry {
|
||||
DirectoryEntry(const char* name, InodeIdentifier, u8 file_type);
|
||||
DirectoryEntry(const char* name, int name_length, InodeIdentifier, u8 file_type);
|
||||
DirectoryEntry(const char* name, size_t name_length, InodeIdentifier, u8 file_type);
|
||||
char name[256];
|
||||
int name_length { 0 };
|
||||
size_t name_length { 0 };
|
||||
InodeIdentifier inode;
|
||||
u8 file_type { 0 };
|
||||
};
|
||||
|
|
|
@ -1085,11 +1085,11 @@ bool ProcFSInode::traverse_as_directory(Function<bool(const FS::DirectoryEntry&)
|
|||
if (!entry.name)
|
||||
continue;
|
||||
if (entry.proc_file_type > __FI_Root_Start && entry.proc_file_type < __FI_Root_End)
|
||||
callback({ entry.name, (int)strlen(entry.name), to_identifier(fsid(), PDI_Root, 0, (ProcFileType)entry.proc_file_type), 0 });
|
||||
callback({ entry.name, strlen(entry.name), to_identifier(fsid(), PDI_Root, 0, (ProcFileType)entry.proc_file_type), 0 });
|
||||
}
|
||||
for (auto pid_child : Process::all_pids()) {
|
||||
char name[16];
|
||||
int name_length = sprintf(name, "%u", pid_child);
|
||||
size_t name_length = (size_t)sprintf(name, "%u", pid_child);
|
||||
callback({ name, name_length, to_identifier(fsid(), PDI_Root, pid_child, FI_PID), 0 });
|
||||
}
|
||||
break;
|
||||
|
@ -1119,7 +1119,7 @@ bool ProcFSInode::traverse_as_directory(Function<bool(const FS::DirectoryEntry&)
|
|||
if (entry.proc_file_type == FI_PID_exe && !process.executable())
|
||||
continue;
|
||||
// FIXME: strlen() here is sad.
|
||||
callback({ entry.name, (int)strlen(entry.name), to_identifier(fsid(), PDI_PID, pid, (ProcFileType)entry.proc_file_type), 0 });
|
||||
callback({ entry.name, strlen(entry.name), to_identifier(fsid(), PDI_PID, pid, (ProcFileType)entry.proc_file_type), 0 });
|
||||
}
|
||||
}
|
||||
} break;
|
||||
|
@ -1134,7 +1134,7 @@ bool ProcFSInode::traverse_as_directory(Function<bool(const FS::DirectoryEntry&)
|
|||
if (!description)
|
||||
continue;
|
||||
char name[16];
|
||||
int name_length = sprintf(name, "%u", i);
|
||||
size_t name_length = (size_t)sprintf(name, "%u", i);
|
||||
callback({ name, name_length, to_identifier_with_fd(fsid(), pid, i), 0 });
|
||||
}
|
||||
} break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue