Commit Graph

3513 Commits

Author SHA1 Message Date
Andreas Kling
4e59300650 AK: Fix typo in TestVector.cpp, oops. 2019-08-02 08:59:26 +02:00
Andreas Kling
5e01ebfc56 Kernel: Clean up thread stacks when a thread dies
We were forgetting where we put the userspace thread stacks, so added a
member called Thread::m_userspace_thread_stack to keep track of it.

Then, in ~Thread(), we now deallocate the userspace, kernel and signal
stacks (if present.)

Out of curiosity, the "init_stage2" process doesn't have a kernel stack
which I found surprising. :^)
2019-08-01 20:17:12 +02:00
Andreas Kling
3ad6ae1842 Kernel: Delete non-main threads immediately after finalizing them
Previously we would wait until the whole process died before actually
deleting its threads.
2019-08-01 20:01:23 +02:00
Andreas Kling
55d6efd485 Scheduler: Fix bitrotted SCHEDULER_RUNNABLE_DEBUG code
The runnable lists have moved from Thread to Scheduler.
2019-08-01 20:00:56 +02:00
Andreas Kling
09cd3a7a07 Scheduler: Fix deadlock when first scheduling candidate being inspected
Somewhat reproducible by opening ProcessManager and trying to view the
stacks for WindowServer.

Regressed in 53262cd08b.
2019-08-01 19:33:36 +02:00
Andreas Kling
38c80d5e6d LibHTML: Make some use of Vector::empend(). 2019-08-01 16:50:15 +02:00
Andreas Kling
8b34b1222b ProcFS: Make some use of Vector::empend(). 2019-08-01 16:34:02 +02:00
Andreas Kling
4afafeae50 Ext2FS: Make some use of Vector::empend(). 2019-08-01 16:31:05 +02:00
Andreas Kling
9230b42f28 AK: Use Vector::empend() a bit in the unit tests, and fix a bug.
There was a bug in the "prepend_vector_object" test but it was masked
by us not printing failures. (The bug was that we were adding three
elements to the "objects" vector and then checking that another
vector called "more_objects" indeed had three elements. Oops!)
2019-08-01 16:24:31 +02:00
Andreas Kling
8434548f14 TestSuite: Actually print failed comparions.. :^) 2019-08-01 16:22:50 +02:00
Andreas Kling
eeff0cd570 AK: Don't allow constructing an OwnPtr from a const NonnullOwnPtr&
OwnPtr's must move around, they can't be copy constructed.
2019-08-01 15:46:18 +02:00
Andreas Kling
79ce75d862 AK: Add Vector::empend().
This is a complement to append() that works by constructing the new
element in-place via placement new and forwarded constructor arguments.

The STL calls this emplace_back() which looks ugly, so I'm inventing
a nice word for it instead. :^)
2019-08-01 15:35:45 +02:00
Andreas Kling
f4bae8971c Documentation: Add a paragraph about NonnullOwnPtr to SmartPointers.md 2019-08-01 14:35:50 +02:00
Andreas Kling
1c50dce7d2 SystemServer: Remove always-true "if (pid == 0)" check
This code should probably be structured differently to handle things
like children dying, etc. But not right now.

Found by PVS-Studio.
2019-08-01 14:08:43 +02:00
Andreas Kling
673a98258b GDirectoryModel: Fix redundant identical comparison.
Found by PVS-Studio.
2019-08-01 14:01:37 +02:00
Andreas Kling
ab8891c064 LibCore: Initialize pid/id variables in CoreIPC{Client,Server}
Also rename CoreIPCServer::m_pid to m_client_pid for clarification.

Found by PVS-Studio.
2019-08-01 11:42:30 +02:00
Andreas Kling
4271bebbef more: Don't printf(string), printf("%s", string)!
Found by PVS-Studio.
2019-08-01 11:39:41 +02:00
Andreas Kling
cbfa211988 ProcFS: Align the buffer used for the CPUID brand string.
I'm not sure if this actually matters, but it won't hurt anyone to use
a 32-bit aligned buffer here.

Found by PVS-Studio.
2019-08-01 11:38:15 +02:00
Andreas Kling
a3ee35510f AK: Make Bitmap movable but not copyable.
We were falling back to an incorrect compiler-generated copy ctor for
this class, and let's not do that.

Found by PVS-Studio.
2019-08-01 11:34:36 +02:00
Andreas Kling
1a13145cb3 Kernel: Remove unnecessary null check in Process::fork()
Found by PVS-Studio.
2019-08-01 11:15:48 +02:00
Andreas Kling
e8b3a539b4 ProcessManager: Fix timer leak in ProcessStacksWidget
CObjects should really be reference-counted instead of this error-prone
(but convenient) model.

Found by PVS-Studio.
2019-08-01 11:12:35 +02:00
Andreas Kling
488d57750d pidof: Remove redundant bool check.
Found by PVS-Studio.
2019-08-01 11:07:44 +02:00
Andreas Kling
b2aea6b4ff Painter: Scaling RGBA32 bitmaps treated the source as alpha-less RGB32
Found by PVS-Studio.
2019-08-01 11:05:52 +02:00
Andreas Kling
be4d33fb2c Kernel+LibC: A lot of the signal handling code was off-by-one.
There is no signal 0. The valid ones are 1 (SIGHUP) through 31 (SIGSYS)
Found by PVS-Studio.
2019-08-01 11:03:48 +02:00
Andreas Kling
bd08664f05 LibC: In fgetc(), fread() will never return < 0.
Furthermore, fread() has already handled EOF, so there's no need to do
it again. If we read a character, return it, otherwise return EOF.
Note that EOF means "EOF or error" here.
2019-08-01 10:50:51 +02:00
Andreas Kling
caeb4b7a7e CEventLoop: Add a missing initializer to EventLoopTimer. 2019-08-01 10:49:31 +02:00
Andreas Kling
2923d39106 JsonParser: Merge the parsing of '\n' and '\r' in quoted strings 2019-08-01 10:45:37 +02:00
Andreas Kling
385e9268f4 CIODevice: printf() thought it was calling ::write() but it was write()
There's some confusion between the write syscall and CIODevice::write()
here. The internal write() returns a boolean, and has already whined
in case the syscall failed, so we don't need to do that again.
2019-08-01 10:41:04 +02:00
Andreas Kling
b9c8b3137d Lagom: Append to CMAKE_CXX_FLAGS instead of overwriting it. 2019-08-01 10:03:56 +02:00
Andreas Kling
db5a4c3409 GDirectoryModel: Tweak default width of permission bits column
Now that GTableView elides text content by default, this column was a
little too wide and ended up getting elided sometimes.
2019-07-31 21:21:20 +02:00
Andreas Kling
df51014834 GTableView: Elide cell content so it doesn't overflow the cell rect
I originally thought I'd have to implement text clipping in Painter for
this, but it seems like I can get away without doing that today. :^)

Fixes #390.
2019-07-31 21:18:01 +02:00
Andreas Kling
b46dbfe7e4 WindowServer: Fix bad assertion when setting wallpaper
The create_thread() syscall returns the thread ID now, not 0.
2019-07-31 18:04:06 +02:00
Andreas Kling
b36108dc3c WindowServer: Allow moving the Launcher window type. 2019-07-31 17:49:40 +02:00
Andreas Kling
ecb1b93d53 Ext2FS: Fix fetching of the major/minor device numbers for st_rdev.
This is how it seems to work:

- If ext2_inode.i_blocks[0] is non-zero, it contains the major/minor.
- Otherwise, it's in ext2_inode.i_blocks[1].
2019-07-31 17:24:54 +02:00
Conrad Pankoff
6b5fbad250 LibGUI: Simplify GTreeView ancestor traversal 2019-07-31 16:38:10 +02:00
Conrad Pankoff
fed0133109 FileManager: Show home directory by default, or command line argument
FileManager used to open up with the root directory loaded by default.
Now it will try to load either 1) the first argument specified on the
command line, 2) the user's home directory, or 3) the root directory.

Fixes #389
2019-07-31 16:33:21 +02:00
Conrad Pankoff
9b6e99f17e LibGUI: Reify intermediate nodes during index traversal
In the event where you want to find the index of a deeply-nested path
with a GFileSystemModel that hasn't yet traversed most of that path, it
is possible for a false negative failure to occur. This failure is
caused by the GFileSystemModel incorrectly bailing out of the search
when it hits the first unseen path segment that is not at the very end
of the path.

This patch fixes this problem by reifying the intermediate nodes during
that search and traversal process.
2019-07-31 16:33:21 +02:00
Robin Burchell
246c011497 Kernel: Port /proc/PID/fds to JSON 2019-07-31 10:48:53 +02:00
Andreas Kling
f10e850644 HashTable: Assert on iteration attempt over table during clear/rehash
It doesn't seem sane to try to iterate over a HashTable while it's in
the middle of being cleared. Since this might cause strange problems,
this patch adds an assertion if an iterator is constructed during
clear() or rehash() of a HashTable.
2019-07-31 10:23:24 +02:00
Andreas Kling
eccc3c3ef0 WindowServer: Control WSClientConnection's window list teardown better
A lot of things happen in response to window destruction, and some of
them may call into the window's WSClientConnection and ask it to look
through its window list.

If we're right in the middle of tearing down the window list, it's not
a great idea to start iterating over it.

Fixes #386.
2019-07-31 10:23:12 +02:00
Robin Burchell
a82c60b22a Add Result<>, to use with/complement Error
An operation often has two pieces of underlying information:

* the data returned as a result from that operation
* an error that occurred while retrieving that data

Merely returning the data is not good enough. Result<> allows exposing
both the data, and the underlying error, and forces (via clang's
consumable attribute) you to check for the error before you try to
access the data.
2019-07-31 09:06:39 +02:00
Robin Burchell
7dd25141cd Add Error<>
Put simply, Error<> is a way of forcing error handling onto an API user.

Given a function like:

    bool might_work();

The following code might have been written previously:

    might_work(); // but what if it didn't?

The easy way to work around this is of course to [[nodiscard]] might_work.
But this doesn't work for more complex cases like, for instance, a
hypothetical read() function which might return one of _many_ errors
(typically signalled with an int, let's say).

    int might_read();

In such a case, the result is often _read_, but not properly handled. Like:

    return buffer.substr(0, might_read()); // but what if might_read returned an error?

This is where Error<> comes in:

    typedef Error<int, 0> ReadError;
    ReadError might_read();

    auto res = might_read();
    if (might_read.failed()) {
        switch (res.value()) {
        case EBADF:
            ...
        }
    }

Error<> uses clang's consumable attributes to force failed() to be
checked on an Error instance. If it's not checked, then you get smacked.
2019-07-31 09:06:39 +02:00
Robin Burchell
28362fcc57 Optional: Add consumable checks
These will, when building with clang, prevent using Optional::value
without first checking Optional::has_value() - at compile time.
2019-07-31 09:06:39 +02:00
Andreas Kling
993ab84a0d GDirectoryModel: Add "modification time" column.
Fixes #373.
2019-07-31 07:09:35 +02:00
Andreas Kling
10b4c92e21 GVariant: Add Type::UnsignedInt. 2019-07-31 07:07:59 +02:00
Andreas Kling
34db7067fa GDirectoryModel: Shrink the Permissions and Inode columns a little bit. 2019-07-31 06:50:01 +02:00
Robin Burchell
ae231cfe3d Lagom: Set project() right away
Checking CMAKE_CXX_COMPILER_ID before project() does not work.
2019-07-30 15:28:37 +02:00
Andreas Kling
0f3d191a70 LibCore: Rename CFileStreamReader => CIODeviceStreamReader. 2019-07-30 15:16:39 +02:00
rhin123
c869d62e16 GFilePicker: Edit file name on opening window
Overlooked that you can't have two GWidgets
selected at the same time, whoops!
2019-07-30 09:19:14 +02:00
Conrad Pankoff
973c2d9bfd Kernel: fix typo regarding floppy drives in init_stage2 2019-07-30 09:16:47 +02:00