Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

warnings: set warning level to 2 #21

Merged
merged 2 commits into from
Feb 28, 2024
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
28 changes: 14 additions & 14 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ jobs:
clang-format:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Clang-Format
run: sudo apt-get update && sudo apt-get -y install clang-format
- name: Run Clang-Format
run: |
find . -name "*.cpp" -o -name "*.hpp" | xargs -I {} clang-format -i {} -n --verbose --Werror
- name: Checkout
uses: actions/checkout@v2
- name: Install Clang-Format
run: sudo apt-get update && sudo apt-get -y install clang-format
- name: Run Clang-Format
run: |
find . -name "*.cpp" -o -name "*.hpp" | xargs -I {} clang-format -i {} -n --verbose --Werror

ci-linux-x86_64:
strategy:
Expand All @@ -44,9 +44,9 @@ jobs:
- name: Set i386 environment variables
if: matrix.platform == 'linux-x86'
run: |
echo "CC=cc -m32" >> $GITHUB_ENV
echo "CXX=c++ -m32" >> $GITHUB_ENV
echo "PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu/pkgconfig/" >> $GITHUB_ENV
echo "CC=cc -m32" >> $GITHUB_ENV
echo "CXX=c++ -m32" >> $GITHUB_ENV
echo "PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu/pkgconfig/" >> $GITHUB_ENV

- name: Install dependencies
run: |
Expand All @@ -64,7 +64,7 @@ jobs:
sudo apt remove --assume-yes zlib1g-dev

- name: Configure
run: meson setup builddir --default-library=both
run: meson setup builddir --default-library=both --warnlevel=2 --werror

- name: Build
run: meson compile --verbose -C builddir
Expand Down Expand Up @@ -100,7 +100,7 @@ jobs:
if: matrix.platform == 'windows-x86'
uses: ilammy/msvc-dev-cmd@v1
with:
arch: 'x86'
arch: "x86"
- name: Checkout code
uses: actions/checkout@v3

Expand All @@ -114,13 +114,13 @@ jobs:
- name: Install python
uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: "3.10"

- name: Install meson
run: python -m pip install meson ninja

- name: Configure
run: meson setup --vsenv builddir --default-library=both
run: meson setup --vsenv builddir --default-library=both --warnlevel=2 --werror

- name: Build
run: meson compile --verbose -C builddir
Expand Down
12 changes: 6 additions & 6 deletions lib/esedatareader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ ESEDataReader::prepare ()
return true;
}

uint32_t
ESEDataReader::readData (int32_t size, int32_t position, bool append)
size_t
ESEDataReader::readData (size_t size, int32_t position, bool append)
{
ESEBuffer buffer;
int32_t read_size;
size_t read_size;

buffer.resize (size);
m_streamPosition = position;
Expand All @@ -52,7 +52,7 @@ ESEDataReader::readData (int32_t size, int32_t position, bool append)
}

m_readSize += read_size;
m_streamPosition += read_size;
m_streamPosition += static_cast<int32_t> (read_size);

if (append) {
m_buffer.insert (m_buffer.end (), buffer.begin (), buffer.end ());
Expand All @@ -67,9 +67,9 @@ ESEDataReader::readData (int32_t size, int32_t position, bool append)
}

ESEBuffer
ESEDataReader::getBuffer (uint32_t size)
ESEDataReader::getBuffer (size_t size)
{
uint32_t real_size = size;
size_t real_size = size;
ESEBuffer buffer;

while (m_buffer.size () < size) {
Expand Down
4 changes: 2 additions & 2 deletions lib/esedatareader.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ class ESEDataReader : public ESEReader {
~ESEDataReader () { }

bool prepare ();
virtual ESEBuffer getBuffer (uint32_t size);
virtual ESEBuffer getBuffer (size_t size);
virtual bool isEOS () { return m_eos; }
virtual size_t streamSize () { return 0; }

private:
uint32_t readData (int32_t data_size, int32_t pos = 0, bool append = false);
size_t readData (size_t data_size, int32_t pos = 0, bool append = false);

ese_read_buffer_func m_readFunc;
void *m_dataPointer;
Expand Down
20 changes: 10 additions & 10 deletions lib/esefilereader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ ESEFileReader::prepare ()

m_file = std::ifstream (m_fileName, std::ios::binary | std::ios::ate);
DBG ("The file %s is now %s", m_fileName.c_str (), m_file.is_open () ? "open" : "closed");
m_fileSize = m_file.tellg ();
m_fileSize = static_cast<size_t> (m_file.tellg ());
if (!m_file.is_open () || m_fileSize <= 0) {
ERR ("Unable to open the file %s", m_fileName.c_str ());
return false;
Expand All @@ -43,14 +43,14 @@ ESEFileReader::prepare ()
return true;
}

uint32_t
ESEFileReader::readFile (int32_t data_size, int32_t pos, bool append)
size_t
ESEFileReader::readFile (size_t data_size, int32_t pos, bool append)
{
ESEBuffer buffer;
size_t read_size;

if (!m_fileSize)
m_fileSize = m_file.tellg ();
m_fileSize = static_cast<size_t> (m_file.tellg ());
if (m_fileSize <= 0) {
ERR ("The file is empty. Exit.");
return 0;
Expand All @@ -63,11 +63,11 @@ ESEFileReader::readFile (int32_t data_size, int32_t pos, bool append)
m_streamPosition = pos;

buffer.resize (data_size);
m_file.read ((char *)buffer.data (), data_size);
read_size = m_file.gcount ();
m_file.read (reinterpret_cast<char *> (buffer.data ()), data_size);
read_size = static_cast<size_t> (m_file.gcount ());
buffer.resize (read_size);
m_readSize += read_size;
m_streamPosition += read_size;
m_streamPosition += static_cast<int32_t> (read_size);
if (append) {
m_buffer.insert (m_buffer.end (), buffer.begin (), buffer.end ());
DBG ("ReadFile: Append %d to a buffer of new size %zd read %zd", data_size,
Expand All @@ -81,9 +81,9 @@ ESEFileReader::readFile (int32_t data_size, int32_t pos, bool append)
}

ESEBuffer
ESEFileReader::getBuffer (uint32_t size)
ESEFileReader::getBuffer (size_t size)
{
uint32_t real_size = size;
size_t real_size = size;
ESEBuffer buffer;

while (m_buffer.size () < size) {
Expand All @@ -97,6 +97,6 @@ ESEFileReader::getBuffer (uint32_t size)

buffer = subVector (m_buffer, 0, real_size);
m_buffer.erase (m_buffer.begin (), m_buffer.begin () + real_size);
m_bufferSize = m_buffer.size ();
m_bufferSize = static_cast<int32_t> (m_buffer.size ());
return buffer;
}
4 changes: 2 additions & 2 deletions lib/esefilereader.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ class ESEFileReader : public ESEReader {

virtual bool prepare ();

virtual ESEBuffer getBuffer (uint32_t size);
virtual ESEBuffer getBuffer (size_t size);
virtual size_t streamSize () { return m_fileSize; }
virtual bool isEOS () { return m_bufferSize == 0 && m_readSize == streamSize (); }

private:
uint32_t readFile (int32_t data_size, int32_t pos = 0, bool append = false);
size_t readFile (size_t data_size, int32_t pos = 0, bool append = false);

std::ifstream m_file;
std::string m_fileName;
Expand Down
2 changes: 1 addition & 1 deletion lib/eseivfstream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ ESEIVFStream::reset ()
void
ESEIVFStream::parseOptions (const char *options)
{
INFO ("Create a IFV stream");
INFO ("Create a IFV stream with options %s", options);
}

ESEVideoCodec
Expand Down
4 changes: 2 additions & 2 deletions lib/eselogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ class Logger {
va_end (argptr);
}

void createLogData (const uint8_t *buffer, uint32_t length, const char *format, ...)
void createLogData (const uint8_t *buffer, size_t length, const char *format, ...)
{
va_list argptr;
va_start (argptr, format);
vfprintf (stdout, format, argptr);
va_end (argptr);
for (uint32_t i = 0; i < length; i++) {
for (size_t i = 0; i < length; i++) {
fprintf (stdout, "0x%.2X ", buffer[i]);
}
fprintf (stdout, "\n");
Expand Down
16 changes: 8 additions & 8 deletions lib/esenalstream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ int32_t
ESENALStream::parseStream (int32_t start_position)
{
int32_t pos = start_position;
int32_t buffer_size = m_buffer.size ();
int32_t buffer_size = static_cast<int32_t> (m_buffer.size ());

while (pos < buffer_size) {
if (!m_mpegDetected) {
Expand Down Expand Up @@ -120,12 +120,12 @@ ESENALStream::readStream ()
return ESE_RESULT_EOS;
}

if (m_bufferPosition >= (uint32_t)m_buffer.size ()) {
if (m_bufferPosition >= static_cast<uint32_t> (m_buffer.size ())) {
m_buffer = m_reader->getBuffer (m_reader->bufferReadLength () >= MINIMUM_HEADER_SEARCH_FRAME ? m_reader->bufferReadLength () : MINIMUM_HEADER_SEARCH_FRAME);
}
while (m_bufferPosition <= (uint32_t)m_buffer.size () || !m_reader->isEOS ()) {
while (m_bufferPosition <= static_cast<uint32_t> (m_buffer.size ()) || !m_reader->isEOS ()) {
pos = parseStream (m_bufferPosition);
if (pos == (int32_t)-1) {
if (pos == static_cast<int32_t> (-1)) {
return ESE_RESULT_NO_PACKET;
} else {
if (m_frameState == ESE_NAL_FRAME_STATE_END) {
Expand All @@ -139,7 +139,7 @@ ESENALStream::readStream ()
return ESE_RESULT_NEW_PACKET;
} else {
m_bufferPosition = pos;
if (m_bufferPosition >= (uint32_t)m_buffer.size ()) {
if (m_bufferPosition >= static_cast<uint32_t> (m_buffer.size ())) {
if (m_reader->isEOS ()) {
m_nextFrame = prepareFrame (m_buffer, m_frameStartPos, m_buffer.size ());
m_nalCount++;
Expand Down Expand Up @@ -177,14 +177,14 @@ ESENALStream::processToNextFrame ()
} else {
m_currentFrame = {};
while ((res = readStream ()) <= ESE_RESULT_EOS) {
if (!ese_is_aud_nalu (m_nextFrame, (ESENaluCodec)m_codec)) {
if (!ese_is_aud_nalu (m_nextFrame, static_cast<ESENaluCodec> (m_codec))) {
m_currentFrame.insert (m_currentFrame.end (), m_nextFrame.begin (),
m_nextFrame.end ());
}
if (res == ESE_RESULT_EOS
|| ese_is_new_frame (m_nextFrame, (ESENaluCodec)m_codec)) {
|| ese_is_new_frame (m_nextFrame, static_cast<ESENaluCodec> (m_codec))) {
if (m_currentFrame.size () > 0) {
const ESEBuffer &audNalu = ese_aud_nalu ((ESENaluCodec)m_codec);
const ESEBuffer &audNalu = ese_aud_nalu (static_cast<ESENaluCodec> (m_codec));
m_currentFrame.insert (m_currentFrame.begin (), audNalu.begin (),
audNalu.end ());
prepareNextPacket ();
Expand Down
14 changes: 7 additions & 7 deletions lib/esereader.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,21 @@ class ESEReader {
/// @brief Reset the reader
virtual void reset ();

virtual bool prepare () = 0;
virtual ESEBuffer getBuffer (uint32_t size) = 0;
virtual bool prepare () = 0;
virtual ESEBuffer getBuffer (size_t size) = 0;

int32_t readSize () { return m_readSize; }
size_t readSize () { return m_readSize; }
virtual size_t streamSize () = 0;
int32_t streamPosition () { return m_streamPosition; }
uint32_t bufferReadLength () { return m_bufferReadLength; }
void setBufferReadLength (uint32_t bufferReadLength) { m_bufferReadLength = bufferReadLength; }
size_t bufferReadLength () { return m_bufferReadLength; }
void setBufferReadLength (size_t bufferReadLength) { m_bufferReadLength = bufferReadLength; }

virtual bool isEOS () = 0;

protected:
int32_t m_streamPosition;
int32_t m_bufferSize;
size_t m_bufferSize;
size_t m_readSize;
uint32_t m_bufferReadLength;
size_t m_bufferReadLength;
ESEBuffer m_buffer;
};
11 changes: 6 additions & 5 deletions lib/esestream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
#define _CRT_SECURE_NO_WARNINGS 1

#include "esestream.h"
#include "esedatareader.h"
Expand Down Expand Up @@ -89,7 +90,7 @@ ESEStream::prepare (ese_read_buffer_func read_func, void *pointer, const char *o
}

void
ESEStream::setBufferReadLength (int32_t len)
ESEStream::setBufferReadLength (size_t len)
{
if (m_reader)
m_reader->setBufferReadLength (len);
Expand All @@ -102,10 +103,10 @@ ESEStream::setOptions (const char *options)
}

ESEBuffer
ESEStream::prepareFrame (ESEBuffer buffer, uint32_t start,
uint32_t end)
ESEStream::prepareFrame (ESEBuffer buffer, size_t start,
size_t end)
{
uint32_t frame_start = start;
size_t frame_start = start;
if (start > buffer.size () || end > buffer.size ()) {
throw std::out_of_range ("start and end positions must be within the buffer size");
}
Expand Down Expand Up @@ -263,7 +264,7 @@ ESEStream::parseOptions (const char *options)
char *token;
if (options == nullptr)
return;
token = strtok ((char *)options, "\n");
token = strtok (const_cast<char *> (options), "\n");
while (token != NULL) {
std::string s (token);
size_t pos = s.find (":");
Expand Down
6 changes: 3 additions & 3 deletions lib/esestream.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#define MAX_SEARCH_SIZE 5

#define ESE_MAKE_FOURCC(a, b, c, d) \
((uint32_t)(a) | ((uint32_t)(b)) << 8 | ((uint32_t)(c)) << 16 | ((uint32_t)(d)) << 24)
(static_cast<uint32_t> (a) | (static_cast<uint32_t> (b)) << 8 | (static_cast<uint32_t> (c)) << 16 | (static_cast<uint32_t> (d)) << 24)

class ESEStream {
public:
Expand All @@ -40,7 +40,7 @@ class ESEStream {

bool prepare (const char *uri, const char *options = nullptr);
bool prepare (ese_read_buffer_func func, void *pointer, const char *options);
void setBufferReadLength (int32_t len);
void setBufferReadLength (size_t len);
void setOptions (const char *options);
virtual void parseOptions (const char *options);
/// @brief This method will build the next frame (NAL or AU) available.
Expand Down Expand Up @@ -68,7 +68,7 @@ class ESEStream {
virtual ESEBuffer getStartCode () { return {}; }

// Prepare the next frame available from the given buffer at given position.
ESEBuffer prepareFrame (ESEBuffer buffer, uint32_t start, uint32_t end);
ESEBuffer prepareFrame (ESEBuffer buffer, size_t start, size_t end);
ESEPacket *prepareNextPacket (uint64_t pts = 0, uint64_t dts = 0, uint64_t duration = 0);

ESEVideoCodec m_codec;
Expand Down
2 changes: 1 addition & 1 deletion lib/eseutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ make_unique (Args &&...args)

template <typename T>
static inline std::vector<T>
subVector (std::vector<T> const &v, int pos, int size)
subVector (std::vector<T> const &v, size_t pos, size_t size)
{
auto first = v.cbegin () + pos;
auto last = v.cbegin () + pos + size;
Expand Down
4 changes: 2 additions & 2 deletions lib/esextractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ struct ESExtractor {
m_stream->processToNextFrame ();
}

void setBufferReadLength (uint32_t len)
void setBufferReadLength (size_t len)
{
m_stream->setBufferReadLength (len);
}
Expand Down Expand Up @@ -170,7 +170,7 @@ es_extractor_read_packet (ESExtractor *extractor, ESEPacket **packet)
}

void
es_extractor_set_buffer_read_length (ESExtractor *extractor, uint32_t buffer_read_length)
es_extractor_set_buffer_read_length (ESExtractor *extractor, size_t buffer_read_length)
{
ESE_CHECK_VOID (extractor != NULL);
extractor->setBufferReadLength (buffer_read_length);
Expand Down
Loading
Loading