From 12327e6f68b7a7fbc7e4f39420eaabe986d1c453 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Mangano?= Date: Wed, 24 Feb 2016 09:55:23 +0100 Subject: [PATCH] style fixes missing newlines nullptr instead of NULL bracket tweak --- src/actions.cc | 4 ++-- src/actions.h | 3 ++- src/ogg.cc | 12 +++++++----- src/ogg.h | 2 +- src/options.cc | 2 +- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/actions.cc b/src/actions.cc index b5b365f..9ca52a2 100644 --- a/src/actions.cc +++ b/src/actions.cc @@ -7,7 +7,7 @@ void opustags::list_tags(ogg::Decoder &dec, TagsHandler &handler) ogg::Stream *s; while (!handler.done()) { s = dec.read_page(); - if (s == NULL) + if (s == nullptr) break; // end of stream switch (s->state) { case ogg::HEADER_READY: @@ -29,7 +29,7 @@ void opustags::edit_tags(ogg::Decoder &in, ogg::Encoder &out, TagsHandler &handl ogg::Stream *s; while (true) { s = in.read_page(); - if (s == NULL) + if (s == nullptr) break; // end of stream switch (s->state) { diff --git a/src/actions.h b/src/actions.h index b8fdec5..68ef5de 100644 --- a/src/actions.h +++ b/src/actions.h @@ -8,7 +8,8 @@ namespace opustags { // TagsHandler define various operations related to tags and stream in // order to control the main loop. // In its implementation, it is expected to receive an option structure. - struct TagsHandler { + struct TagsHandler + { // Irrelevant streams don't even need to be parsed, so we can save some // effort with this method. diff --git a/src/ogg.cc b/src/ogg.cc index f9b8198..414580f 100644 --- a/src/ogg.cc +++ b/src/ogg.cc @@ -62,6 +62,7 @@ void ogg::Stream::handle_packet(const ogg_packet &op) parse_tags(op); // else shrug } + void ogg::Stream::parse_header(const ogg_packet &op) { // TODO @@ -97,7 +98,7 @@ ogg::Decoder::~Decoder() ogg_sync_clear(&sync); } -ogg::Stream* ogg::Decoder::read_page() +ogg::Stream *ogg::Decoder::read_page() { while (page_out()) { int streamno = ogg_page_serialno(¤t_page); @@ -109,7 +110,7 @@ ogg::Stream* ogg::Decoder::read_page() if (i->second.page_in(current_page)) return &(i->second); } - return NULL; // end of stream + return nullptr; // end of stream } // Read the next page and return true on success, false on end of stream. @@ -137,7 +138,7 @@ bool ogg::Decoder::buff() if (input->eof()) return false; char *buf = ogg_sync_buffer(&sync, 65536); - if (buf == NULL) + if (buf == nullptr) throw std::runtime_error("ogg_sync_buffer failed"); input->read(buf, 65536); ogg_sync_wrote(&sync, input->gcount()); @@ -184,6 +185,7 @@ void ogg::Encoder::forward_stream(ogg::Stream &in, ogg::Stream &out) } } } + void ogg::Encoder::flush_stream(ogg::Stream &out) { ogg_page og; @@ -193,8 +195,8 @@ void ogg::Encoder::flush_stream(ogg::Stream &out) void ogg::Encoder::write_raw_page(const ogg_page &og) { - output->write((const char*) og.header, og.header_len); - output->write((const char*) og.body, og.body_len); + output->write(reinterpret_cast(og.header), og.header_len); + output->write(reinterpret_cast(og.body), og.body_len); } void ogg::Encoder::write_tags(int streamno, const Tags&) diff --git a/src/ogg.h b/src/ogg.h index 21302ac..0e61f4d 100644 --- a/src/ogg.h +++ b/src/ogg.h @@ -77,7 +77,7 @@ namespace ogg // The read page is given to Stream::page_in before this function // returns. // After the end of the file is reached, it returns NULL. - Stream* read_page(); + Stream *read_page(); std::istream *input; diff --git a/src/options.cc b/src/options.cc index 045916b..3f1ecb6 100644 --- a/src/options.cc +++ b/src/options.cc @@ -30,7 +30,7 @@ Options opustags::parse_args(const int argc, char **argv) {"set", required_argument, 0, 's'}, {"delete-all", no_argument, 0, 'D'}, {"set-all", no_argument, 0, 'S'}, - {NULL, 0, 0, 0} + {nullptr, 0, 0, 0} }; Options options;