Skip to content

Commit

Permalink
address clangd warnings
Browse files Browse the repository at this point in the history
avoid including headers where they aren't being directly used

in floating point arithmetic, use int multiplication over
int division, or be explicit about using division.

use C++-standardized, namespace-aware headers instead of
the older C-style headers.
  • Loading branch information
myQwil committed Mar 5, 2025
1 parent daaa7c6 commit 7729cd9
Show file tree
Hide file tree
Showing 86 changed files with 160 additions and 177 deletions.
6 changes: 3 additions & 3 deletions demo/Wave_Writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

#include "Wave_Writer.h"

#include <assert.h>
#include <stdint.h>
#include <stdlib.h>
#include <cassert>
#include <cstdint>
#include <cstdlib>

/* Copyright (C) 2003-2006 by Shay Green. Permission is hereby granted, free
of charge, to any person obtaining a copy of this software and associated
Expand Down
4 changes: 2 additions & 2 deletions demo/Wave_Writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ void wave_close( void );
#endif

#ifdef __cplusplus
#include <stddef.h>
#include <stdio.h>
#include <cstddef>
#include <cstdio>

/* C++ interface */
class Wave_Writer {
Expand Down
1 change: 1 addition & 0 deletions gme/Ay_Apu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ details. You should have received a copy of the GNU Lesser General Public
License along with this module; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */

#include "blargg_common.h"
#include "blargg_source.h"

// Emulation inaccuracies:
Expand Down
2 changes: 1 addition & 1 deletion gme/Ay_Apu.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#ifndef AY_APU_H
#define AY_APU_H

#include "blargg_common.h"
#include "Blip_Buffer.h"
#include <cstdint>

class Ay_Apu {
public:
Expand Down
3 changes: 2 additions & 1 deletion gme/Ay_Cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ Last validated with zexall 2006.11.21 5:26 PM

#include "Ay_Cpu.h"

#include "blargg_common.h"
#include "blargg_endian.h"
#include <string.h>
#include <cstring>

//#include "z80_cpu_log.h"

Expand Down
2 changes: 1 addition & 1 deletion gme/Ay_Cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#ifndef AY_CPU_H
#define AY_CPU_H

#include "blargg_endian.h"
#include <cstdint>

typedef int32_t cpu_time_t;

Expand Down
5 changes: 2 additions & 3 deletions gme/Ay_Emu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "Ay_Emu.h"

#include "blargg_endian.h"
#include <string.h>
#include <cstring>

#include <algorithm> // min, max

Expand All @@ -27,7 +27,6 @@ static unsigned const ram_start = 0x4000;
static int const osc_count = Ay_Apu::osc_count + 1;

using std::min;
using std::max;

Ay_Emu::Ay_Emu()
{
Expand Down Expand Up @@ -159,7 +158,7 @@ void Ay_Emu::set_voice( int i, Blip_Buffer* center, Blip_Buffer*, Blip_Buffer* )

void Ay_Emu::set_tempo_( double t )
{
play_period = blip_time_t (clock_rate() / 50 / t);
play_period = blip_time_t (clock_rate() / (50 * t));
}

blargg_err_t Ay_Emu::start_track_( int track )
Expand Down
8 changes: 3 additions & 5 deletions gme/Blip_Buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

#include "Blip_Buffer.h"

#include <assert.h>
#include <limits.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cstring>
#include <cstdlib>
#include <cmath>

/* Copyright (C) 2003-2006 Shay Green. This module is free software; you
can redistribute it and/or modify it under the terms of the GNU Lesser
Expand Down
6 changes: 2 additions & 4 deletions gme/Blip_Buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#define BLIP_BUFFER_H

// internal
#include <limits.h>
#include <climits>
#if INT_MAX < 0x7FFFFFFF
#error "int must be at least 32 bits"
#endif
Expand Down Expand Up @@ -121,8 +121,6 @@ class Blip_Buffer {
friend class Blip_Reader;
};

#include "blargg_config.h"

// Number of bits in resample ratio fraction. Higher values give a more accurate ratio
// but reduce maximum buffer size.
#ifndef BLIP_BUFFER_ACCURACY
Expand Down Expand Up @@ -336,7 +334,7 @@ class Blip_Reader {

// End of public interface

#include <assert.h>
#include <cassert>

template<int quality,int range>
inline void Blip_Synth<quality,range>::offset_resampled( blip_resampled_time_t time,
Expand Down
2 changes: 1 addition & 1 deletion gme/Classic_Emu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "Classic_Emu.h"

#include "Multi_Buffer.h"
#include <string.h>
#include <cstring>

/* Copyright (C) 2003-2006 Shay Green. This module is free software; you
can redistribute it and/or modify it under the terms of the GNU Lesser
Expand Down
10 changes: 4 additions & 6 deletions gme/Data_Reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#include "Data_Reader.h"

#include "blargg_endian.h"
#include <assert.h>
#include <string.h>
#include <stdio.h>
#include <climits>
#include <cstring>
#include <cstdio>
#include <algorithm>

/* Copyright (C) 2005-2006 Shay Green. This module is free software; you
Expand All @@ -23,12 +23,10 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */

#ifdef HAVE_ZLIB_H
#include <zlib.h>
#include <stdlib.h>
#include <errno.h>
#include <cstdlib>
static const unsigned char gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */
#endif /* HAVE_ZLIB_H */

using std::min;
using std::max;

const char Data_Reader::eof_error [] = "Unexpected end of file";
Expand Down
4 changes: 2 additions & 2 deletions gme/Dual_Resampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

#include "Dual_Resampler.h"

#include <stdlib.h>
#include <string.h>
#include <cstdlib>
#include <cstring>

/* Copyright (C) 2003-2006 Shay Green. This module is free software; you
can redistribute it and/or modify it under the terms of the GNU Lesser
Expand Down
3 changes: 2 additions & 1 deletion gme/Effects_Buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

#include "Effects_Buffer.h"

#include <string.h>
#include <cstring>
#include <cstdint>
#include <algorithm>

/* Copyright (C) 2003-2006 Shay Green. This module is free software; you
Expand Down
9 changes: 4 additions & 5 deletions gme/Fir_Resampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

#include "Fir_Resampler.h"

#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <cstring>
#include <cstdlib>
#include <cmath>

/* Copyright (C) 2004-2006 Shay Green. This module is free software; you
can redistribute it and/or modify it under the terms of the GNU Lesser
Expand All @@ -32,7 +31,7 @@ static void gen_sinc( double rolloff, int width, double offset, double spacing,
double const pow_a_n = pow( rolloff, maxh );
scale /= maxh * 2;

double angle = (count / 2 - 1 + offset) * -step;
double angle = ((int)(count / 2) - 1 + offset) * -step;
while ( count-- )
{
*out++ = 0;
Expand Down
3 changes: 2 additions & 1 deletion gme/Fir_Resampler.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
#define FIR_RESAMPLER_H

#include "blargg_common.h"
#include <string.h>
#include <cstdint>
#include <cstring>

class Fir_Resampler_ {
public:
Expand Down
3 changes: 1 addition & 2 deletions gme/Gb_Apu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "Gb_Apu.h"

#include <string.h>
#include <cstring>
#include <algorithm>

/* Copyright (C) 2003-2006 Shay Green. This module is free software; you
Expand All @@ -21,7 +21,6 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
static unsigned const vol_reg = 0xFF24;
static unsigned const status_reg = 0xFF26;

using std::min;
using std::max;

Gb_Apu::Gb_Apu()
Expand Down
3 changes: 2 additions & 1 deletion gme/Gb_Cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "Gb_Cpu.h"

#include <string.h>
#include <cstring>

//#include "gb_cpu_log.h"

Expand All @@ -20,6 +20,7 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
#include "gb_cpu_io.h"

#include "blargg_source.h"
#include "blargg_endian.h"

// Common instructions:
//
Expand Down
3 changes: 1 addition & 2 deletions gme/Gb_Cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
#ifndef GB_CPU_H
#define GB_CPU_H

#include "blargg_common.h"
#include "blargg_endian.h"
#include <cstdint>

typedef unsigned gb_addr_t; // 16-bit CPU address

Expand Down
4 changes: 0 additions & 4 deletions gme/Gb_Oscs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

#include "Gb_Apu.h"

#include <string.h>

/* Copyright (C) 2003-2006 Shay Green. This module is free software; you
can redistribute it and/or modify it under the terms of the GNU Lesser
General Public License as published by the Free Software Foundation; either
Expand All @@ -15,8 +13,6 @@ details. You should have received a copy of the GNU Lesser General Public
License along with this module; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */

#include "blargg_source.h"

// Gb_Osc

void Gb_Osc::reset()
Expand Down
2 changes: 1 addition & 1 deletion gme/Gb_Oscs.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#ifndef GB_OSCS_H
#define GB_OSCS_H

#include "blargg_common.h"
#include "Blip_Buffer.h"
#include <cstdint>

struct Gb_Osc
{
Expand Down
2 changes: 1 addition & 1 deletion gme/Gbs_Emu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "Gbs_Emu.h"

#include "blargg_endian.h"
#include <string.h>
#include <cstring>

/* Copyright (C) 2003-2006 Shay Green. This module is free software; you
can redistribute it and/or modify it under the terms of the GNU Lesser
Expand Down
2 changes: 1 addition & 1 deletion gme/Gme_File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "Gme_File.h"

#include "blargg_endian.h"
#include <string.h>
#include <cstring>

/* Copyright (C) 2003-2006 Shay Green. This module is free software; you
can redistribute it and/or modify it under the terms of the GNU Lesser
Expand Down
1 change: 1 addition & 0 deletions gme/Gme_File.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "blargg_common.h"
#include "Data_Reader.h"
#include "M3u_Playlist.h"
#include <cstdint>

// Error returned if file is wrong type
//extern const char gme_wrong_file_type []; // declared in gme.h
Expand Down
4 changes: 2 additions & 2 deletions gme/Gym_Emu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "Gym_Emu.h"

#include "blargg_endian.h"
#include <string.h>
#include <cstring>

/* Copyright (C) 2003-2006 Shay Green. This module is free software; you
can redistribute it and/or modify it under the terms of the GNU Lesser
Expand Down Expand Up @@ -195,7 +195,7 @@ void Gym_Emu::set_tempo_( double t )

if ( blip_buf.sample_rate() )
{
clocks_per_frame = long (clock_rate / 60 / tempo());
clocks_per_frame = long (clock_rate / (60 * tempo()));
Dual_Resampler::resize( long (sample_rate() / (60.0 * tempo())) );
}
}
Expand Down
4 changes: 3 additions & 1 deletion gme/Hes_Apu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

#include "Hes_Apu.h"

#include <string.h>
#include <cstring>
#include <cstdint>

/* Copyright (C) 2006 Shay Green. This module is free software; you
can redistribute it and/or modify it under the terms of the GNU Lesser
Expand All @@ -15,6 +16,7 @@ details. You should have received a copy of the GNU Lesser General Public
License along with this module; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */

#include "blargg_common.h"
#include "blargg_source.h"

static bool const center_waves = true; // reduces asymmetry and clamping when starting notes
Expand Down
1 change: 0 additions & 1 deletion gme/Hes_Apu.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#ifndef HES_APU_H
#define HES_APU_H

#include "blargg_common.h"
#include "Blip_Buffer.h"

struct Hes_Osc
Expand Down
4 changes: 3 additions & 1 deletion gme/Hes_Cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
#ifndef HES_CPU_H
#define HES_CPU_H

#include "blargg_common.h"
#include <cassert>
#include <climits>
#include <cstdint>

typedef int32_t hes_time_t; // clock cycle count
typedef unsigned hes_addr_t; // 16-bit address
Expand Down
3 changes: 1 addition & 2 deletions gme/Hes_Emu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "Hes_Emu.h"

#include "blargg_endian.h"
#include <string.h>
#include <cstring>
#include <algorithm>

/* Copyright (C) 2006 Shay Green. This module is free software; you
Expand All @@ -27,7 +27,6 @@ static int const unmapped = 0xFF;
static long const period_60hz = 262 * 455L; // scanlines * clocks per scanline

using std::min;
using std::max;

Hes_Emu::Hes_Emu()
{
Expand Down
Loading

0 comments on commit 7729cd9

Please sign in to comment.