@bitfield

Тег c в блоге bitfield

bitfield
    unsigned long  f_bsize;    /* file system block size */
    unsigned long  f_frsize;   /* fragment size */
    fsblkcnt_t     f_blocks;   /* size of fs in f_frsize units */

Линус, ты пьян, иди домой.

bitfield

Нашли прекрасную багу у сотрудника, который в отпуске.

В заголовочном файле есть константа

#define BUFSIZE 8128

Приходит пакет размером 3 КБ и ... обрабатывается неверно.
Читаем код функции: буфер размером BUFSIZ, в который копируется пакет.
Стоп! Что такое BUFSIZ? Откуда оно берется?
F12 (Go to Definition) и попадаем в stdio.h:

#define BUFSIZ 512

PS. Осталось еще узнать, почему 8128, а не 8*1024=8192.

bitfield

мимими 1:

The "best" example of this maintainability problem could be found in the old implementation of the printf family of functions. The CRT provides 142 different variations of printf, but most of the behavior is the same for all of the functions, so there are a set of common implementation functions that do the bulk of the work. These common implementation functions were all defined in output.c in the CRT sources(1). This 2,696 line file had 223 conditionally compiled regions of code (#ifdef, #else, etc.), over half of which were in a single 1,400 line function. This file was compiled 12 different ways to generate all of the common implementation functions.

мимими 2:

We have converted most of the CRT sources to compile as C++, enabling us to replace many ugly C idioms with simpler and more advanced C++ constructs. The publicly callable functions are still declared as C functions, of course (extern "C" in C++), so they can still be called from C. But internally we now take full advantage of the C++ language and its many useful features.

мимими 3:

Before this refactoring, the sprintf functions, which write formatted data to a character buffer, were implemented by wrapping the result buffer in a temporary FILE object and then deferring to the equivalent fprintf function.

Добавить пост

Вы можете выбрать до 10 файлов общим размером не более 10 МБ.
Для форматирования текста используется Markdown.