Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ void to_uppercase(char *buffer, size_t size) __attribute__((access(read_write, 1

---

### Mark positional arguments holding open file desriptors
### Mark positional arguments holding open file descriptors

| Attribute | Supported since | Type | Description |
|:-----------------------------------------------------------------------------------------------|:---------------------------:|:----------------------------:|:------------------------------------------------------------------------------------------------- |
Expand All @@ -237,7 +237,7 @@ void to_uppercase(char *buffer, size_t size) __attribute__((access(read_write, 1
The `fd_arg`, `fd_arg_read`, and `fd_arg_write` attributes in GCC[^gcc-fd_arg] indicate that the annotated function expects an open file descriptor as an argument. GCC’s static analyzer (`-fanalyzer`[^gcc-analyzer]) can use this information to to catch:

- **Access mode mismatches** (`-Wanalyzer-fd-access-mode-mismatch`) if there are code paths through which a read on a write-only file descriptor or write on a read-only file descriptor is attempted.
- **Double-close conditions** (`-Wanalyzer-fd-double-close`) if there are code paths thorugh which a file descriptor can be closed more than once.
- **Double-close conditions** (`-Wanalyzer-fd-double-close`) if there are code paths thorough which a file descriptor can be closed more than once.
- **File descriptor leaks** (`-Wanalyzer-fd-leak`) if there are code paths through which a file descriptor goes out of scope without being closed.
- **Use-after-close** (`-Wanalyzer-fd-use-after-close`) if there are code paths through which a read or write is attempted on a closed file descriptor.
- **Use-without-check** (`-Wanalyzer-fd-use-without-check`) if there are code paths through which a file descriptor is used without being first checked for validity.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ print_number_of_students(None)

```

This code example returns: `TypeError: exceptions must derive from BaseException`. This is problematic because rasing `None` does not provide any useful error information or traceback, leading to less informative error handling and potentially causing the program to crash unexpectedly without clear diagnostic details.
This code example returns: `TypeError: exceptions must derive from BaseException`. This is problematic because raising `None` does not provide any useful error information or traceback, leading to less informative error handling and potentially causing the program to crash unexpectedly without clear diagnostic details.

## Compliant Code Example - Raise only exceptions that properly inherit from the BaseException class, never raise "None"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Introduction paragraph, expanding on the introduction sentence...
* Be brief.
* Avoid duplicated content.

An `example01.py` code is optional and usefull to demonstrate behaviour that does __not__ work well in the compliant or noncompliant code.
An `example01.py` code is optional and useful to demonstrate behaviour that does __not__ work well in the compliant or noncompliant code.

_[example01.py:](example01.py)_

Expand Down