Skip to content

Commit 559c799

Browse files
committed
Add comments to magic constants missing context
ROOT_KERNEL_TASK_ID = 2: note that PID 2 is kthreadd, parent of all kernel threads. HEADER_LINES = 2 in get_dev(): note that /proc/net/dev has two header rows (title + column names), distinguishing it from all other net files which have one. All other named constants in the parsers already carry sufficient context.
1 parent cfd2e5b commit 559c799

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

src/net.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ std::vector<net_device> net::get_dev(net_device_filter filter) const
4242
static const std::string DEV_FILE("dev");
4343
auto path = _net_root + DEV_FILE;
4444

45-
static const size_t HEADER_LINES = 2;
45+
static const size_t HEADER_LINES = 2; // /proc/net/dev has two header rows: title + column names
4646

4747
std::vector<net_device> output;
4848
parsers::parse_file_lines(path, std::back_inserter(output),

src/task.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ bool task::operator<(const task& rhs) const
6060

6161
bool task::is_kernel_thread(const task_stat& st)
6262
{
63-
static const int ROOT_KERNEL_TASK_ID = 2;
63+
static const int ROOT_KERNEL_TASK_ID = 2; // kthreadd, parent of all kernel threads
6464

6565
return st.pid == ROOT_KERNEL_TASK_ID || st.ppid == ROOT_KERNEL_TASK_ID;
6666
}

0 commit comments

Comments
 (0)