Fix warnings on gcc 14.2.0.
This commit is contained in:
parent
02e0abfe5d
commit
82fa95f8cd
33 changed files with 115 additions and 112 deletions
4
Makefile
4
Makefile
|
@ -714,7 +714,7 @@ verify-manual:
|
|||
|
||||
verify-build-tools:
|
||||
$(MAKE) clean-build-tools
|
||||
$(MAKE) OPTLEVEL='-O2 -g -Werror -Werror=strict-prototypes' build-tools
|
||||
CFLAGS='-O2 -g -Werror -Werror=strict-prototypes' CXXFLAGS='-O2 -g -Werror' $(MAKE) build-tools
|
||||
|
||||
verify-sysroot-source:
|
||||
$(MAKE) clean-sysroot
|
||||
|
@ -726,7 +726,7 @@ verify-sysroot-source:
|
|||
|
||||
verify-build:
|
||||
$(MAKE) mostlyclean
|
||||
$(MAKE) OPTLEVEL='-O2 -g -Werror -Werror=strict-prototypes' PACKAGES=''
|
||||
CFLAGS='-O2 -g -Werror -Werror=strict-prototypes' CXXFLAGS='-O2 -g -Werror' $(MAKE) PACKAGES=''
|
||||
|
||||
verify-headers:
|
||||
# TODO: The gcc port doesn't ship with cross-compilers out of the box.
|
||||
|
|
|
@ -106,10 +106,10 @@ feature="$3"
|
|||
printf '%s:\n' "$header"
|
||||
case $std in
|
||||
*++*)
|
||||
printf '\t@%s\n' "$target-g++ $std $feature -c $header -o /dev/null -O3 -Wall -Wextra -Wsystem-headers -Werror -I libc/include -I libm/include -I $libm_machine -I kernel/include"
|
||||
printf '\t@%s\n' "$target-g++ $std $feature -c $header -o /dev/zero -O3 -Wall -Wextra -Wsystem-headers -Werror -I libc/include -I libm/include -I $libm_machine -I kernel/include"
|
||||
;;
|
||||
*)
|
||||
printf '\t@%s\n' "$target-gcc $std $feature -c $header -o /dev/null -O3 -Wall -Wextra -Wsystem-headers -Werror -I libc/include -I libm/include -I $libm_machine -I kernel/include"
|
||||
printf '\t@%s\n' "$target-gcc $std $feature -c $header -o /dev/zero -O3 -Wall -Wextra -Wsystem-headers -Werror -I libc/include -I libm/include -I $libm_machine -I kernel/include"
|
||||
;;
|
||||
esac
|
||||
done) | make -f - --no-print-directory
|
||||
|
|
|
@ -205,8 +205,8 @@ static int checklist_fp(FILE* fp,
|
|||
struct checklist** checklist_sorted = NULL;
|
||||
if ( files )
|
||||
{
|
||||
checklist = calloc(sizeof(struct checklist), files_count);
|
||||
checklist_sorted = calloc(sizeof(struct checklist*), files_count);
|
||||
checklist = calloc(files_count, sizeof(struct checklist));
|
||||
checklist_sorted = calloc(files_count, sizeof(struct checklist*));
|
||||
if ( !checklist || !checklist_sorted )
|
||||
err(1, "malloc");
|
||||
for ( size_t i = 0; i < files_count; i++ )
|
||||
|
|
|
@ -453,7 +453,7 @@ static void remove_partition_devices(const char* path)
|
|||
char* dir_path = strdup(path);
|
||||
if ( !dir_path )
|
||||
{
|
||||
warn("%s", dir_path);
|
||||
warn("malloc");
|
||||
return; // TODO: Error.
|
||||
}
|
||||
dirname(dir_path);
|
||||
|
|
|
@ -267,6 +267,11 @@ void editor_input_process_byte(struct editor_input* editor_input,
|
|||
if ( amount_read != sizeof(uc) )
|
||||
return;
|
||||
|
||||
// TODO: Work around https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110091
|
||||
// false positive warning on gcc 14.2.0 -O2.
|
||||
#if defined(__GNUC__) && 12 <= __GNUC__
|
||||
#pragma GCC diagnostic ignored "-Wdangling-pointer"
|
||||
#endif
|
||||
if ( editor_input->termseq_used < MAX_TERMSEQ_SIZE )
|
||||
editor_input->termseq[editor_input->termseq_used++] = (char) uc;
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
#include <display.h>
|
||||
|
||||
// Utility global variables every game will need.
|
||||
uint32_t window_id = 0;
|
||||
uint32_t my_window_id = 0;
|
||||
static size_t framesize;
|
||||
static uint32_t* fb;
|
||||
static bool game_running = true;
|
||||
|
@ -273,9 +273,9 @@ void render(struct display_connection* connection)
|
|||
}
|
||||
}
|
||||
|
||||
display_render_window(connection, window_id, 0, 0,
|
||||
display_render_window(connection, my_window_id, 0, 0,
|
||||
game_width, game_height, fb);
|
||||
display_show_window(connection, window_id);
|
||||
display_show_window(connection, my_window_id);
|
||||
}
|
||||
|
||||
// ... to here. No need to edit stuff below.
|
||||
|
@ -331,7 +331,7 @@ void on_quit(void* ctx, uint32_t window_id)
|
|||
void on_resize(void* ctx, uint32_t window_id, uint32_t width, uint32_t height)
|
||||
{
|
||||
(void) ctx;
|
||||
if ( window_id != window_id )
|
||||
if ( window_id != my_window_id )
|
||||
return;
|
||||
game_width = width;
|
||||
game_height = height;
|
||||
|
@ -341,7 +341,7 @@ void on_resize(void* ctx, uint32_t window_id, uint32_t width, uint32_t height)
|
|||
void on_keyboard(void* ctx, uint32_t window_id, uint32_t codepoint)
|
||||
{
|
||||
(void) ctx;
|
||||
if ( window_id != window_id )
|
||||
if ( window_id != my_window_id )
|
||||
return;
|
||||
int kbkey = KBKEY_DECODE(codepoint);
|
||||
if ( !kbkey )
|
||||
|
@ -399,9 +399,9 @@ int main(int argc, char* argv[])
|
|||
if ( !connection )
|
||||
error(1, errno, "Could not connect to display server");
|
||||
|
||||
display_create_window(connection, window_id);
|
||||
display_resize_window(connection, window_id, game_width, game_height);
|
||||
display_title_window(connection, window_id, "Aquatinspitz");
|
||||
display_create_window(connection, my_window_id);
|
||||
display_resize_window(connection, my_window_id, game_width, game_height);
|
||||
display_title_window(connection, my_window_id, "Aquatinspitz");
|
||||
|
||||
mainloop(connection);
|
||||
|
||||
|
|
|
@ -162,7 +162,8 @@ public:
|
|||
float y;
|
||||
|
||||
public:
|
||||
Vector(float x = 0.0f, float y = 0.0f) : x(x), y(y) { }
|
||||
constexpr Vector(float x = 0.0f, float y = 0.0f) : x(x), y(y) { }
|
||||
constexpr Vector(const Vector& v) : x(v.x), y(v.y) { }
|
||||
|
||||
Vector& operator=(const Vector& rhs)
|
||||
{
|
||||
|
|
|
@ -105,12 +105,7 @@ static void InitializeDevice(Ref<Descriptor> dev, const char* devpath,
|
|||
void Init(const char* devpath, Ref<Descriptor> dev)
|
||||
{
|
||||
uint32_t devaddr;
|
||||
pcifind_t filter;
|
||||
|
||||
memset(&filter, 255, sizeof(filter));
|
||||
filter.classid = 0x01;
|
||||
filter.subclassid = 0x06;
|
||||
|
||||
pcifind_t filter(NULL, 0xFFFF, 0xFFFF, 0x01, 0x06);
|
||||
devaddr = 0;
|
||||
while ( (devaddr = PCI::SearchForDevices(filter, devaddr)) )
|
||||
InitializeDevice(dev, devpath, devaddr);
|
||||
|
|
|
@ -50,11 +50,7 @@ static void InitializeDevice(Ref<Descriptor> dev, const char* devpath,
|
|||
void Init(const char* devpath, Ref<Descriptor> dev)
|
||||
{
|
||||
uint32_t devaddr;
|
||||
pcifind_t filter;
|
||||
|
||||
memset(&filter, 255, sizeof(filter));
|
||||
filter.classid = 0x01;
|
||||
filter.subclassid = 0x01;
|
||||
pcifind_t filter(NULL, 0xFFFF, 0xFFFF, 0x01, 0x01);
|
||||
devaddr = 0;
|
||||
while ( (devaddr = PCI::SearchForDevices(filter, devaddr)) )
|
||||
InitializeDevice(dev, devpath, devaddr);
|
||||
|
|
|
@ -619,15 +619,12 @@ static bool OnDevice(uint32_t devaddr, const pciid_t*, const pcitype_t*, void*,
|
|||
|
||||
void Init()
|
||||
{
|
||||
pcifind_t patterns[2];
|
||||
memset(&patterns[0], 255, sizeof(patterns[0]));
|
||||
patterns[0].vendorid = 0x1234;
|
||||
patterns[0].deviceid = 0x1111;
|
||||
memset(&patterns[1], 255, sizeof(patterns[1]));
|
||||
patterns[1].vendorid = 0x80EE;
|
||||
patterns[1].deviceid = 0xBEEF;
|
||||
|
||||
PCI::Search(OnDevice, NULL, patterns, 2);
|
||||
pcifind_t patterns[2] =
|
||||
{
|
||||
{ NULL, 0x1234, 0x1111 },
|
||||
{ NULL, 0x80EE, 0xBEEF },
|
||||
};
|
||||
PCI::Search(OnDevice, NULL, patterns, sizeof(patterns)/sizeof(patterns[0]));
|
||||
}
|
||||
|
||||
} // namespace BGA
|
||||
|
|
|
@ -30,8 +30,8 @@ namespace Sortix {
|
|||
// Functions for 32-bit and 64-bit x86.
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
namespace CPU {
|
||||
void Reboot();
|
||||
void ShutDown();
|
||||
__attribute__((noreturn)) void Reboot();
|
||||
__attribute__((noreturn)) void ShutDown();
|
||||
} // namespace CPU
|
||||
#endif
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ struct TextCharPOD
|
|||
|
||||
struct TextChar
|
||||
{
|
||||
TextChar() { }
|
||||
TextChar() : c(0), vgacolor(0), attr(0), fg(0), bg(0) { }
|
||||
TextChar(const TextCharPOD& o) :
|
||||
c(o.c), vgacolor(o.vgacolor), attr(o.attr), fg(o.fg), bg(o.bg) { }
|
||||
TextChar(wchar_t c, uint8_t vgacolor, uint16_t attr, uint32_t fg, uint32_t bg) :
|
||||
|
|
|
@ -106,7 +106,6 @@ LFBTextBuffer* CreateLFBTextBuffer(uint8_t* lfb, uint32_t lfbformat,
|
|||
ret->columns = columns;
|
||||
ret->rows = rows;
|
||||
ret->font = font;
|
||||
memset(chars, 0, sizeof(chars[0]) * columns * rows);
|
||||
ret->chars = chars;
|
||||
ret->cursorenabled = true;
|
||||
ret->cursorpos = TextPos(0, 0);
|
||||
|
|
|
@ -218,10 +218,10 @@ static struct arp_table* GetTable(NetworkInterface* netif)
|
|||
{
|
||||
if ( netif->arp_table )
|
||||
return netif->arp_table;
|
||||
struct arp_table* table = new struct arp_table;
|
||||
struct arp_table* table =
|
||||
(struct arp_table*) calloc(1, sizeof(struct arp_table));
|
||||
if ( !table )
|
||||
return NULL;
|
||||
memset(table, 0, sizeof(*table));
|
||||
netif->arp_table = table;
|
||||
table->netif = netif;
|
||||
// Enter every entry into the table's unused linked list.
|
||||
|
@ -301,7 +301,9 @@ static void EvictEntry(struct arp_table* table, struct arp_entry* entry)
|
|||
}
|
||||
|
||||
// Clear the entry.
|
||||
memset(entry, 0, sizeof(*entry));
|
||||
assert(!entry->pending_first);
|
||||
assert(!entry->pending_last);
|
||||
memset((char*) entry, 0, sizeof(*entry));
|
||||
entry->table = table;
|
||||
|
||||
// Insert the entry into the table's unused linked list.
|
||||
|
|
|
@ -495,7 +495,7 @@ bool EM::AddReceiveDescriptor(Ref<Packet> pkt) // ordered via interrupt worker
|
|||
if ( next_desc == rx_prochead )
|
||||
return false;
|
||||
struct rx_desc* desc = &rdesc[rx_tail];
|
||||
memset(desc, 0, sizeof(*desc));
|
||||
*desc = rx_desc{0, 0, 0, 0, 0, 0};
|
||||
desc->status = 0;
|
||||
desc->address = pkt->pmap.phys;
|
||||
rpackets[rx_tail] = pkt;
|
||||
|
|
|
@ -142,7 +142,12 @@ static void MakeCoarsePattern(pcifind_t* coarse,
|
|||
{
|
||||
if ( pattern_count < 1 )
|
||||
{
|
||||
memset(coarse, 255, sizeof(*coarse));
|
||||
coarse->vendorid = 0xffff;
|
||||
coarse->deviceid = 0xffff;
|
||||
coarse->classid = 0xff;
|
||||
coarse->subclassid = 0xff;
|
||||
coarse->progif = 0xff;
|
||||
coarse->revid = 0xff;
|
||||
return;
|
||||
}
|
||||
const pcifind_t* first = patterns;
|
||||
|
|
|
@ -1391,10 +1391,9 @@ int sys_execve(const char* user_filename,
|
|||
}
|
||||
}
|
||||
|
||||
argv = new char*[argc+1];
|
||||
argv = (char**) calloc(argc+1, sizeof(char*));
|
||||
if ( !argv )
|
||||
goto cleanup_filename;
|
||||
memset(argv, 0, sizeof(char*) * (argc+1));
|
||||
|
||||
for ( int i = 0; i < argc; i++ )
|
||||
{
|
||||
|
@ -1420,10 +1419,9 @@ int sys_execve(const char* user_filename,
|
|||
}
|
||||
}
|
||||
|
||||
envp = new char*[envc+1];
|
||||
envp = (char**) calloc(envc+1, sizeof(char*));
|
||||
if ( !envp )
|
||||
goto cleanup_argv;
|
||||
memset(envp, 0, sizeof(char*) * (envc+1));
|
||||
|
||||
for ( int i = 0; i < envc; i++ )
|
||||
{
|
||||
|
@ -1439,11 +1437,11 @@ int sys_execve(const char* user_filename,
|
|||
cleanup_envp:
|
||||
for ( int i = 0; i < envc; i++)
|
||||
delete[] envp[i];
|
||||
delete[] envp;
|
||||
free(envp);
|
||||
cleanup_argv:
|
||||
for ( int i = 0; i < argc; i++)
|
||||
delete[] argv[i];
|
||||
delete[] argv;
|
||||
free(argv);
|
||||
cleanup_filename:
|
||||
delete[] filename;
|
||||
cleanup_done:
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
namespace Sortix {
|
||||
namespace VGA {
|
||||
|
||||
uint8_t* const VGA = (uint8_t* const) 0xB8000;
|
||||
uint8_t* const VGA = (uint8_t*) 0xB8000;
|
||||
const unsigned WIDTH = 80;
|
||||
const unsigned HEIGHT = 25;
|
||||
const size_t VGA_SIZE = sizeof(uint16_t) * WIDTH * HEIGHT;
|
||||
|
|
|
@ -29,14 +29,14 @@ const size_t TRANSBITS = 9;
|
|||
|
||||
PML* const PMLS[TOPPMLLEVEL + 1] =
|
||||
{
|
||||
(PML* const) 0x0,
|
||||
(PML* const) 0xFFFFFF8000000000UL,
|
||||
(PML* const) 0xFFFFFF7FC0000000UL,
|
||||
(PML* const) 0XFFFFFF7FBFE00000UL,
|
||||
(PML* const) 0xFFFFFF7FBFDFF000UL,
|
||||
(PML*) 0x0,
|
||||
(PML*) 0xFFFFFF8000000000UL,
|
||||
(PML*) 0xFFFFFF7FC0000000UL,
|
||||
(PML*) 0XFFFFFF7FBFE00000UL,
|
||||
(PML*) 0xFFFFFF7FBFDFF000UL,
|
||||
};
|
||||
|
||||
PML* const FORKPML = (PML* const) 0xFFFFFF0000000000UL;
|
||||
PML* const FORKPML = (PML*) 0xFFFFFF0000000000UL;
|
||||
|
||||
} // namespace Memory
|
||||
} // namespace Sortix
|
||||
|
@ -44,7 +44,7 @@ PML* const FORKPML = (PML* const) 0xFFFFFF0000000000UL;
|
|||
namespace Sortix {
|
||||
namespace Page {
|
||||
|
||||
addr_t* const STACK = (addr_t* const) 0xFFFFFE8000000000UL;
|
||||
addr_t* const STACK = (addr_t*) 0xFFFFFE8000000000UL;
|
||||
const size_t MAXSTACKSIZE = (512UL*1024UL*1024UL*1024UL);
|
||||
const size_t MAXSTACKLENGTH = MAXSTACKSIZE / sizeof(addr_t);
|
||||
|
||||
|
|
|
@ -542,10 +542,7 @@ GuestAdditions* GetGuestAdditions()
|
|||
|
||||
void Init()
|
||||
{
|
||||
pcifind_t pcifind;
|
||||
memset(&pcifind, 255, sizeof(pcifind));
|
||||
pcifind.vendorid = 0x80EE;
|
||||
pcifind.deviceid = 0xCAFE;
|
||||
pcifind_t pcifind(NULL, 0x80EE, 0xCAFE);
|
||||
|
||||
uint32_t devaddr = PCI::SearchForDevices(pcifind, 0);
|
||||
if ( !devaddr )
|
||||
|
|
|
@ -29,12 +29,12 @@ const size_t TRANSBITS = 10;
|
|||
|
||||
PML* const PMLS[TOPPMLLEVEL + 1] =
|
||||
{
|
||||
(PML* const) 0x0,
|
||||
(PML* const) 0xFFC00000UL,
|
||||
(PML* const) 0xFFBFF000UL,
|
||||
(PML*) 0x0,
|
||||
(PML*) 0xFFC00000UL,
|
||||
(PML*) 0xFFBFF000UL,
|
||||
};
|
||||
|
||||
PML* const FORKPML = (PML* const) 0xFF800000UL;
|
||||
PML* const FORKPML = (PML*) 0xFF800000UL;
|
||||
|
||||
} // namespace Memory
|
||||
} // namespace Sortix
|
||||
|
@ -42,7 +42,7 @@ PML* const FORKPML = (PML* const) 0xFF800000UL;
|
|||
namespace Sortix {
|
||||
namespace Page {
|
||||
|
||||
addr_t* const STACK = (addr_t* const) 0xFF400000UL;
|
||||
addr_t* const STACK = (addr_t*) 0xFF400000UL;
|
||||
const size_t MAXSTACKSIZE = (4UL*1024UL*1024UL);
|
||||
const size_t MAXSTACKLENGTH = MAXSTACKSIZE / sizeof(addr_t);
|
||||
|
||||
|
|
|
@ -43,27 +43,28 @@ static void pthread_entrance(struct pthread* thread)
|
|||
}
|
||||
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
static const unsigned long FLAGS_CARRY = 1 << 0; // 0x000001
|
||||
static const unsigned long FLAGS_RESERVED1 = 1 << 1; // 0x000002, read as one
|
||||
static const unsigned long FLAGS_PARITY = 1 << 2; // 0x000004
|
||||
static const unsigned long FLAGS_RESERVED2 = 1 << 3; // 0x000008
|
||||
static const unsigned long FLAGS_AUX = 1 << 4; // 0x000010
|
||||
static const unsigned long FLAGS_RESERVED3 = 1 << 5; // 0x000020
|
||||
static const unsigned long FLAGS_ZERO = 1 << 6; // 0x000040
|
||||
static const unsigned long FLAGS_SIGN = 1 << 7; // 0x000080
|
||||
static const unsigned long FLAGS_TRAP = 1 << 8; // 0x000100
|
||||
static const unsigned long FLAGS_INTERRUPT = 1 << 9; // 0x000200
|
||||
static const unsigned long FLAGS_DIRECTION = 1 << 10; // 0x000400
|
||||
static const unsigned long FLAGS_OVERFLOW = 1 << 11; // 0x000800
|
||||
static const unsigned long FLAGS_IOPRIVLEVEL = 1 << 12 | 1 << 13;
|
||||
static const unsigned long FLAGS_NESTEDTASK = 1 << 14; // 0x004000
|
||||
static const unsigned long FLAGS_RESERVED4 = 1 << 15; // 0x008000
|
||||
static const unsigned long FLAGS_RESUME = 1 << 16; // 0x010000
|
||||
static const unsigned long FLAGS_VIRTUAL8086 = 1 << 17; // 0x020000
|
||||
static const unsigned long FLAGS_ALIGNCHECK = 1 << 18; // 0x040000
|
||||
static const unsigned long FLAGS_VIRTINTR = 1 << 19; // 0x080000
|
||||
static const unsigned long FLAGS_VIRTINTRPEND = 1 << 20; // 0x100000
|
||||
static const unsigned long FLAGS_ID = 1 << 21; // 0x200000
|
||||
#define unused __attribute__((unused))
|
||||
unused static const unsigned long FLAGS_CARRY = 1 << 0; // 0x000001
|
||||
unused static const unsigned long FLAGS_RESERVED1 = 1 << 1; // 0x000002, read as one
|
||||
unused static const unsigned long FLAGS_PARITY = 1 << 2; // 0x000004
|
||||
unused static const unsigned long FLAGS_RESERVED2 = 1 << 3; // 0x000008
|
||||
unused static const unsigned long FLAGS_AUX = 1 << 4; // 0x000010
|
||||
unused static const unsigned long FLAGS_RESERVED3 = 1 << 5; // 0x000020
|
||||
unused static const unsigned long FLAGS_ZERO = 1 << 6; // 0x000040
|
||||
unused static const unsigned long FLAGS_SIGN = 1 << 7; // 0x000080
|
||||
unused static const unsigned long FLAGS_TRAP = 1 << 8; // 0x000100
|
||||
unused static const unsigned long FLAGS_INTERRUPT = 1 << 9; // 0x000200
|
||||
unused static const unsigned long FLAGS_DIRECTION = 1 << 10; // 0x000400
|
||||
unused static const unsigned long FLAGS_OVERFLOW = 1 << 11; // 0x000800
|
||||
unused static const unsigned long FLAGS_IOPRIVLEVEL = 1 << 12 | 1 << 13;
|
||||
unused static const unsigned long FLAGS_NESTEDTASK = 1 << 14; // 0x004000
|
||||
unused static const unsigned long FLAGS_RESERVED4 = 1 << 15; // 0x008000
|
||||
unused static const unsigned long FLAGS_RESUME = 1 << 16; // 0x010000
|
||||
unused static const unsigned long FLAGS_VIRTUAL8086 = 1 << 17; // 0x020000
|
||||
unused static const unsigned long FLAGS_ALIGNCHECK = 1 << 18; // 0x040000
|
||||
unused static const unsigned long FLAGS_VIRTINTR = 1 << 19; // 0x080000
|
||||
unused static const unsigned long FLAGS_VIRTINTRPEND = 1 << 20; // 0x100000
|
||||
unused static const unsigned long FLAGS_ID = 1 << 21; // 0x200000
|
||||
#endif
|
||||
|
||||
#if defined(__i386__)
|
||||
|
|
|
@ -180,6 +180,7 @@ int vcbscanf(void* fp,
|
|||
if ( scan_type != TYPE_INT )
|
||||
return errno = EINVAL, matched_items ? matched_items : EOF;
|
||||
scan_type = TYPE_PTR;
|
||||
// fallthrough
|
||||
case 'X':
|
||||
case 'x': base = 16; is_unsigned = true; break;
|
||||
default: __builtin_unreachable();
|
||||
|
@ -321,12 +322,14 @@ int vcbscanf(void* fp,
|
|||
if ( scan_type != TYPE_INT )
|
||||
return errno = EINVAL, matched_items ? matched_items : EOF;
|
||||
scan_type = TYPE_LONG;
|
||||
// fallthrough
|
||||
case 's': string = true; use_scanset = false; break;
|
||||
case '[': string = true; use_scanset = true; break;
|
||||
case 'C':
|
||||
if ( scan_type != TYPE_INT )
|
||||
return errno = EINVAL, matched_items ? matched_items : EOF;
|
||||
scan_type = TYPE_LONG;
|
||||
// fallthrough
|
||||
case 'c': string = false; use_scanset = false; break;
|
||||
default: __builtin_unreachable();
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ void* memcpy(void* restrict dst_ptr,
|
|||
return dst_ptr;
|
||||
|
||||
void* dst_end = (char*) dst_ptr + size;
|
||||
const void* src_end = (const const char*) src_ptr + size;
|
||||
const void* src_end = (const char*) src_ptr + size;
|
||||
if ( (dst_ptr < src_ptr && src_ptr < dst_end) ||
|
||||
(src_ptr < dst_ptr && dst_ptr < src_end) )
|
||||
{
|
||||
|
|
|
@ -348,7 +348,7 @@ ctanf.c \
|
|||
ctanh.c \
|
||||
ctanhf.c \
|
||||
|
||||
CFLAGS:=$(CFLAGS) -std=gnu99 -Wall -Wextra
|
||||
CFLAGS:=$(CFLAGS) -std=gnu99 -Wall -Wextra -Wno-misleading-indentation -Wno-shift-negative-value -Wno-maybe-uninitialized
|
||||
CPPFLAGS:=$(CPPFLAGS) -I include -I src -I $(ARCH_SUBDIR)
|
||||
|
||||
# TODO: Figure out whether these are the defines that we want to pass.
|
||||
|
|
|
@ -30,11 +30,11 @@
|
|||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static const int VERBOSITY_SILENT = 0;
|
||||
static const int VERBOSITY_NO_OUTPUT = 1;
|
||||
static const int VERBOSITY_QUIET = 2;
|
||||
static const int VERBOSITY_NORMAL = 3;
|
||||
static const int VERBOSITY_VERBOSE = 4;
|
||||
__attribute__((unused)) static const int VERBOSITY_SILENT = 0;
|
||||
__attribute__((unused)) static const int VERBOSITY_NO_OUTPUT = 1;
|
||||
__attribute__((unused)) static const int VERBOSITY_QUIET = 2;
|
||||
__attribute__((unused)) static const int VERBOSITY_NORMAL = 3;
|
||||
__attribute__((unused)) static const int VERBOSITY_VERBOSE = 4;
|
||||
|
||||
bool is_usable_terminal(int fd)
|
||||
{
|
||||
|
|
|
@ -6,7 +6,7 @@ include ../build-aux/dirs.mak
|
|||
OPTLEVEL?=$(DEFAULT_OPTLEVEL)
|
||||
CFLAGS?=$(OPTLEVEL)
|
||||
|
||||
CFLAGS += -Wall -Wextra
|
||||
CFLAGS += -Wall -Wextra -Wno-format-truncation
|
||||
|
||||
BINARIES = rw
|
||||
MANPAGES1 = rw.1
|
||||
|
|
|
@ -582,7 +582,7 @@ bool edit_line_history_save(struct edit_line* edit_state, const char* path)
|
|||
}
|
||||
// Merge with any updated history.
|
||||
bool success = true;
|
||||
char** history = calloc(sizeof(char*), histsize);
|
||||
char** history = calloc(histsize, sizeof(char*));
|
||||
if ( !history )
|
||||
warn("malloc"), success = false;
|
||||
size_t first = 0;
|
||||
|
|
|
@ -153,7 +153,7 @@ static void scrollback_resize(size_t new_rows, size_t new_columns)
|
|||
// TODO: Recover gracefully if the scrollback fails.
|
||||
// TODO: Overflow.
|
||||
struct entry* new_scrollback =
|
||||
calloc(sizeof(struct entry), new_rows * new_columns);
|
||||
calloc(new_rows * new_columns, sizeof(struct entry));
|
||||
if ( !new_scrollback )
|
||||
err(1, "malloc");
|
||||
size_t src_y_after_cursor = rows ? row + 1 : 0;
|
||||
|
@ -1057,8 +1057,8 @@ void on_keyboard(void* ctx, uint32_t window_id, uint32_t codepoint)
|
|||
|
||||
void draw(struct display_connection* connection)
|
||||
{
|
||||
uint32_t* framebuffer = (uint32_t*)
|
||||
calloc(sizeof(uint32_t), WINDOW_WIDTH * WINDOW_HEIGHT);
|
||||
uint32_t* framebuffer =
|
||||
calloc(WINDOW_WIDTH * WINDOW_HEIGHT, sizeof(uint32_t));
|
||||
assert(framebuffer);
|
||||
|
||||
struct framebuffer fb;
|
||||
|
@ -1155,7 +1155,7 @@ int main(int argc, char* argv[])
|
|||
columns = 80;
|
||||
|
||||
// TODO: Overflow.
|
||||
scrollback = calloc(sizeof(struct entry), rows * columns);
|
||||
scrollback = calloc(rows * columns, sizeof(struct entry));
|
||||
if ( !scrollback )
|
||||
err(1, "malloc");
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Jonas 'Sortie' Termansen.
|
||||
* Copyright (c) 2013, 2024 Jonas 'Sortie' Termansen.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
|
@ -28,7 +28,8 @@ public:
|
|||
float z;
|
||||
|
||||
public:
|
||||
Vector(float x = 0.f, float y = 0.f, float z = 0.f) : x(x), y(y), z(z) { }
|
||||
constexpr Vector(float x = 0.f, float y = 0.f, float z = 0.f) : x(x), y(y), z(z) { }
|
||||
constexpr Vector(const Vector& v) : x(v.x), y(v.y), z(v.z) { }
|
||||
|
||||
Vector& operator=(const Vector& rhs)
|
||||
{
|
||||
|
|
|
@ -298,7 +298,7 @@ int main(int argc, char* argv[])
|
|||
if ( columns == 1 )
|
||||
rows = lines_used;
|
||||
|
||||
size_t* column_widths = (size_t*) calloc(sizeof(size_t), columns);
|
||||
size_t* column_widths = (size_t*) calloc(columns, sizeof(size_t));
|
||||
if ( !column_widths )
|
||||
error(1, errno, "calloc column widths");
|
||||
|
||||
|
|
12
utils/find.c
12
utils/find.c
|
@ -915,7 +915,7 @@ static bool find(const struct expr* expr,
|
|||
char* new_path = join_paths(state->path, entry->d_name);
|
||||
if ( !new_path )
|
||||
err(1, "malloc");
|
||||
struct state* new_state = calloc(sizeof(struct state), 1);
|
||||
struct state* new_state = calloc(1, sizeof(struct state));
|
||||
if ( !new_state )
|
||||
err(1, "malloc");
|
||||
new_state->parent = state;
|
||||
|
@ -1061,7 +1061,7 @@ int main(int argc, char* argv[])
|
|||
for ( int i = predicates_offset; i < argc; i++ )
|
||||
{
|
||||
const char* arg = argv[i];
|
||||
struct expr* subexpr = calloc(sizeof(struct expr), 1);
|
||||
struct expr* subexpr = calloc(1, sizeof(struct expr));
|
||||
if ( !subexpr )
|
||||
err(1, "malloc");
|
||||
struct expr** next_insert_at = NULL;
|
||||
|
@ -1070,7 +1070,7 @@ int main(int argc, char* argv[])
|
|||
subexpr->kind = EXPR_PAREN;
|
||||
subexpr->expr_not.expr = NULL;
|
||||
struct parse_state* new_parse_state =
|
||||
calloc(sizeof(struct parse_state), 1);
|
||||
calloc(1, sizeof(struct parse_state));
|
||||
if ( !new_parse_state )
|
||||
err(1, "malloc");
|
||||
new_parse_state->outer = parse_state;
|
||||
|
@ -1440,7 +1440,7 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
else
|
||||
{
|
||||
struct expr* and_expr = calloc(sizeof(struct expr), 1);
|
||||
struct expr* and_expr = calloc(1, sizeof(struct expr));
|
||||
if ( !and_expr )
|
||||
err(1, "malloc");
|
||||
and_expr->kind = EXPR_AND;
|
||||
|
@ -1465,7 +1465,7 @@ int main(int argc, char* argv[])
|
|||
|
||||
if ( !found_action )
|
||||
{
|
||||
struct expr* print_expr = calloc(sizeof(struct expr), 1);
|
||||
struct expr* print_expr = calloc(1, sizeof(struct expr));
|
||||
if ( !print_expr )
|
||||
err(1, "malloc");
|
||||
print_expr->kind = EXPR_PRINT;
|
||||
|
@ -1474,7 +1474,7 @@ int main(int argc, char* argv[])
|
|||
root = print_expr;
|
||||
else
|
||||
{
|
||||
struct expr* and_expr = calloc(sizeof(struct expr), 1);
|
||||
struct expr* and_expr = calloc(1, sizeof(struct expr));
|
||||
if ( !and_expr )
|
||||
err(1, "malloc");
|
||||
and_expr->kind = EXPR_AND;
|
||||
|
|
|
@ -85,7 +85,10 @@ int main(int argc, char* argv[])
|
|||
bool ok = true;
|
||||
bool stdout_ok = true;
|
||||
|
||||
int* fds = malloc(files_count * sizeof(*fds));
|
||||
#if defined(__GNUC__) && 7 <= __GNUC__
|
||||
#pragma GCC diagnostic ignored "-Walloc-size-larger-than="
|
||||
#endif
|
||||
int* fds = calloc(files_count, sizeof(*fds));
|
||||
if ( !fds )
|
||||
err(1, "malloc");
|
||||
|
||||
|
|
Loading…
Reference in a new issue