Commit graph

15804 commits

Author SHA1 Message Date
Emanuele Torre 9dc44bf8c4 wc: Remove a memory leak. 2021-01-12 09:01:21 +01:00
Emanuele Torre dcd259a100 wc: printf(), fprintf(stderr, ...) -> out(), outln(), warnln().
Problem:
- We were using some incorrect format strings in printf-functions:
 * "%7lu" to print `size_t` values instead of "%7zu";
 * "%7i" to print `unsigned int` values instead of "%7u".

Solution:
- Use out(), outln() and warnln() instead of printf-functions. :^)
2021-01-12 09:01:21 +01:00
Emanuele Torre 725eb702b7 wc: Fix code style.
`unsigned int` -> `unsigned`.
Use brace initialisers instead of equal initialisers for struct members.
Prefix global variables with `g_`.
Wrap multi-line statements in curly braces.

Also:
Use const references instead of references when possible.
Rename `file_name` to `file_specifier`: "-" is not a file name.
Rename `files` to `file_specifiers`.
Avoid some useless checks.
2021-01-12 09:01:21 +01:00
Brendan Coles 24d6814ee5 CatDog: Add pledge() and lock unveil state 2021-01-12 08:59:39 +01:00
Brendan Coles 959970e060 userdel: Use pledge() and unveil() 2021-01-12 08:59:24 +01:00
Brendan Coles eece9edd91 useradd: Use pledge() 2021-01-12 08:58:59 +01:00
Nick Vella eeffdb9725 FileManager: Show location bar on breadcrumb bar double-click. 2021-01-12 08:58:49 +01:00
Nick Vella 4b3c61fad8 LibGUI: Add 'on_doubleclick' event to BreadcrumbBar. 2021-01-12 08:58:49 +01:00
Andreas Kling 254312aa22 Revert "Themes: Tweak "Sunshine" theme colors slightly"
This reverts commit 0ae9ae48fa.

@bcoles informs me that these match Solaris 9 and it checks out.
I don't know what version I was comparing against, and who cares?
2021-01-12 08:49:18 +01:00
Andreas Kling 6412e7e8e3 Kernel: Remove /proc/mounts
Everyone was already using /proc/df which has all the info anyway.
2021-01-11 23:00:07 +01:00
Andreas Kling 9b907e27ce Kernel: Remove /proc/inodes
There was nothing interesting in this file.
2021-01-11 22:51:28 +01:00
Andreas Kling a0506cb39e Kernel: Only send SIGTTOU if TTY termios has TOSTOP flag
Fixes #4909
2021-01-11 22:40:40 +01:00
Andreas Kling e5234f9560 strace: Use pledge() 2021-01-11 22:36:09 +01:00
Andreas Kling f03800cee3 Kernel: Add dedicated "ptrace" pledge promise
The vast majority of programs don't ever need to use sys$ptrace(),
and it seems like a high-value system call to prevent a compromised
process from using.

This patch moves sys$ptrace() from the "proc" promise to its own,
new "ptrace" promise and updates the affected apps.
2021-01-11 22:32:59 +01:00
Andreas Kling 127ce32d9e LibGfx: Adjust margin between window title/stripes by 1px
This makes it symmetrical with the margin between window icon/title.
2021-01-11 22:15:09 +01:00
Andreas Kling f7435dd95f Kernel: Remove MM_DEBUG debug spam code
This was too spammy to ever actually be used anyway.
2021-01-11 22:09:40 +01:00
Andreas Kling 7c4ddecacb Kernel: Convert a bunch of String::format() => String::formatted() 2021-01-11 22:07:01 +01:00
Andreas Kling 0ae9ae48fa Themes: Tweak "Sunshine" theme colors slightly
Bring them a little closer to the original CDE colors. :^)
2021-01-11 21:49:39 +01:00
asynts 843ebbd2c3 Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.
2021-01-11 21:49:29 +01:00
asynts 6fa42af567 Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.

The modifications in this commit were automatically made using the
following command:

    find . -name '*.h' -exec sed -i -E 's/dbg\(\) << ("[^"{]*");/dbgln\(\1\);/' {} \;
2021-01-11 21:49:29 +01:00
asynts a410bb8fd5 Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.
2021-01-11 21:49:29 +01:00
AnotherTest 510030971b LibLine: Handle history across multiple concurrent sessions better
- Store history entries as (timestamp)::(entry)\n\n
- Merge the entries together when saving to avoid loss of history
  entries

To ideally make having two concurrently open shells
(or `js` repls or whatever) not overwrite each others' history entries.
2021-01-11 21:09:36 +01:00
AnotherTest 711ced80c0 LibCore: Add line iterators to IODevice 2021-01-11 21:09:36 +01:00
AnotherTest 7029a8f605 AK: Specialise convert_to_uint<T> and to_uint<T> for 'long' variants 2021-01-11 21:09:36 +01:00
Sahan Fernando ccf4368ca5 AK: Enable format string warnings for AK printf wrappers 2021-01-11 21:06:32 +01:00
Sahan Fernando 9bf76a85c8 Everywhere: Fix incorrect uses of String::format and StringBuilder::appendf
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.
2021-01-11 21:06:32 +01:00
Sahan Fernando fe2b8906d4 Everywhere: Fix incorrect uses of String::format and StringBuilder::appendf
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.
2021-01-11 21:06:32 +01:00
Sahan Fernando 6d97b623cd Everywhere: Fix incorrect uses of String::format and StringBuilder::appendf
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.
2021-01-11 21:06:32 +01:00
Sahan Fernando 099b83fd28 Everywhere: Fix incorrect uses of String::format and StringBuilder::appendf
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.
2021-01-11 21:06:32 +01:00
Nico Weber 009c753a12 Playground: Show placeholders for unregistered widgets
With this, Playground can be used to interactively edit e.g.
DisplaySettingsWindow.gml.
2021-01-11 20:12:26 +01:00
Lenny Maiorani 1b2364846f SinglyLinkedList: Implement find in terms of AK::find
Problem:
- The implementation of `find` is coupled to the implementation of
  `SinglyLinkedList`.

Solution:
- Decouple the implementation of `find` from the class by using a
  generic `find` algorithm.
2021-01-11 19:45:05 +01:00
Lenny Maiorani 853cb8af5c DoublyLinkedList: Implement find in terms of AK::find
Problem:
- The implementation of `find` is coupled to the implementation of
  `DoublyLinkedList`.
- `append` and `prepend` are implemented multiple times so that
  r-value references can be moved from into the new node. This is
  probably not called very often because a pr-value or x-value needs
  to be used here.

Solution:
- Decouple the implementation of `find` from the class by using a
  generic `find` algorithm.
- Make `append` and `prepend` be function templates so that they can
  have binding references which can be forwarded.
2021-01-11 19:45:05 +01:00
Lenny Maiorani f99d1d3bd7 Vector: Implement find, find_if, find_first_matching in terms of AK::find*
Problem:
- The implementation of `find` is coupled to the implementation of `Vector`.
- `Vector::find` takes the predicate by value which might be expensive.

Solution:
- Decouple the implementation of `find` from `Vector` by using a
  generic `find` algorithm.
- Change the name of `find` with a predicate to `find_if` so that a
  binding reference can be used and the predicate can be forwarded to
  avoid copies.
- Change all the `find(pred)` call sites to use `find_if`.
2021-01-11 19:45:05 +01:00
Lenny Maiorani 4333a9a8d6 AK: Find a value in any container offering iterators
Problem:
- `find` is implemented inside of each container. This coupling
  requires that each container needs to individually provide `find`.

Solution:
- Decouple the `find` functionality from the container. This allows
  provides a `find` algorithm which can work with all
  containers. Containers can still provide their own `find` in the
  case where it can be optimized.
- This also allows for searching sub-ranges of a container rather than
  the entire container as some of the container-specific member
  functions enforced.

Note:
- @davidstone's talk from 2015 C++Now conference entitled "Functions
  Want to be Free" encourages this style:
  (https://www.youtube.com/watch?v=_lVlC0xzXDc), but it does come at
  the cost of composability.
- A logical follow-on to this is to provide a mechanism to use a
  short-hand function which automatically searches the entire
  container. This could automatically use the container-provided
  version if available so that functions which provide their own
  optimized version get the benefit.
2021-01-11 19:45:05 +01:00
Andreas Kling 04c6245fe8 LibGfx: Fail PBM decode if there isn't enough color data in image
Found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=29417
2021-01-11 19:24:54 +01:00
Andreas Kling e1cc2acded CrashDaemon: Use pledge 2021-01-11 19:03:09 +01:00
Andreas Kling 5c73c1bff8 Kernel: Don't dump perfcore for non-dumpable processes
Fixes #4904
2021-01-11 18:53:45 +01:00
Andreas Kling cf3d2411fa UserspaceEmulator: Implement the ftruncate and umask syscalls
It's now possible to copy files with FileManager running in UE. :^)
2021-01-11 12:01:42 +01:00
asynts 723effd051 Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.Everything:
2021-01-11 11:55:47 +01:00
asynts 5931758dbc Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.Everything:
2021-01-11 11:55:47 +01:00
asynts dca6f1f49b Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.Everything:
2021-01-11 11:55:47 +01:00
asynts 872f2a3b90 Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.Everything:
2021-01-11 11:55:47 +01:00
asynts 11d651d447 Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.Everything:
2021-01-11 11:55:47 +01:00
campital c7fc9d185d
LibGUI: Update TextEditor after triple-click to select (#4897)
Previously, it was "relying" on the cursor blink timer to update
the visual selection.

This caused some delay after the whole line was selected by
triple-clicking specifically the last word in a line.

Now, the widget is updated after triple-clicking.
2021-01-11 11:42:06 +01:00
Andreas Kling 603147f47a Kernel: Fix perfcore filename generation build error 2021-01-11 11:37:14 +01:00
Andreas Kling 5dafb72370 Kernel+Profiler: Make profiling per-process and without core dumps
This patch merges the profiling functionality in the kernel with the
performance events mechanism. A profiler sample is now just another
perf event, rather than a dedicated thing.

Since perf events were already per-process, this now makes profiling
per-process as well.

Processes with perf events would already write out a perfcore.PID file
to the current directory on death, but since we may want to profile
a process and then let it continue running, recorded perf events can
now be accessed at any time via /proc/PID/perf_events.

This patch also adds information about process memory regions to the
perfcore JSON format. This removes the need to supply a core dump to
the Profiler app for symbolication, and so the "profiler coredump"
mechanism is removed entirely.

There's still a hard limit of 4MB worth of perf events per process,
so this is by no means a perfect final design, but it's a nice step
forward for both simplicity and stability.

Fixes #4848
Fixes #4849
2021-01-11 11:36:00 +01:00
Itamar f259d96871 Kernel: Avoid collision between dynamic loader and main program
When loading non position-independent programs, we now take care not to
load the dynamic loader at an address that collides with the location
the main program wants to load at.

Fixes #4847.
2021-01-10 22:04:43 +01:00
Itamar 40a8159c62 Kernel: Plumb the elf header of the main program down to Process::load
This will enable us to take the desired load address of non-position
independent programs into account when randomizing the load address
of the dynamic loader.
2021-01-10 22:04:43 +01:00
Linus Groh f369229770 LibJS: Replace all uses of to_size_t() and remove it :^)
Yay for more spec compliance! This is pretty easy as everything using
to_size_t() should just be using one of the other abstract operations we
already have implemented.
This allows us to get rid of get_length() in ArrayPrototype, which is
basically a slightly incorrect implementation of length_of_array_like(),
and then finally remove to_size_t()!
Also fixes a couple of "argument is undefined" vs "argument isn't given"
issues along the way.
2021-01-10 21:57:03 +01:00
Linus Groh 9be0b664e3 LibJS: Make length_of_array_like() take an Object rather than Value
The pseudo-code from the spec says "Assert: Type(obj) is Object.", so we
can just enforce this at compile time rather than taking it literally
and doing "ASSERT(value.is_object())".

Also fix an issue where the absence of a "length" property on the object
would cause a crash (to_number() on empty value).
2021-01-10 21:57:03 +01:00