Skip to content

Commit

Permalink
[writer] Change ticksPerQuarterNote to be uint16_t (#119)
Browse files Browse the repository at this point in the history
This is passed to util::write_uint16_be(), which could cause a
truncation if it was set to a value that didn't fit into a 16-bit
unsigned integer.

This produced the following compiler warning for me:

	/build/source/libremidi/include/libremidi/writer.cpp: In member function 'void libremidi::writer::write(std::ostream&) const':
	/build/source/libremidi/include/libremidi/writer.cpp:205:30: error: conversion from 'int' to 'uint16_t' {aka short unsigned int'} may change value [-Werror=conversion]
	  205 |   util::write_uint16_be(out, ticksPerQuarterNote);
	      |                              ^~~~~~~~~~~~~~~~~~~
	cc1plus: all warnings being treated as errors
  • Loading branch information
alyssais authored Oct 13, 2024
1 parent 5b78e34 commit 90ca39f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion include/libremidi/writer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace libremidi
struct LIBREMIDI_EXPORT writer
{
public:
int ticksPerQuarterNote{120};
uint16_t ticksPerQuarterNote{120};
std::vector<midi_track> tracks;

void add_event(int tick, int track, const message& m);
Expand Down

0 comments on commit 90ca39f

Please sign in to comment.