Uppercase the literal suffixes

* MISRA C++:2008, 2-13-4 - Literal suffixes shall be upper case
* MISRA C:2012, 7.3 - The lowercase character "l" shall not be used in a
  literal suffix
* CERT DCL16-C. - Use "L," not "l," to indicate a long value
* CERT, DCL50-J. - Use visually distinct identifiers
This commit is contained in:
Mike Gelfand
2019-03-17 07:07:48 +03:00
parent a2c42268dc
commit d3b8982195
19 changed files with 55 additions and 55 deletions
+5 -5
View File
@@ -1226,7 +1226,7 @@ static GtkWidget* info_page_new(struct DetailsImpl* di)
gtk_frame_set_shadow_type(GTK_FRAME(fr), GTK_SHADOW_IN);
gtk_container_add(GTK_CONTAINER(fr), sw);
w = hig_workarea_add_tall_row(t, &row, _("Comment:"), fr, NULL);
gtk_misc_set_alignment(GTK_MISC(w), 0.0f, 0.0f);
gtk_misc_set_alignment(GTK_MISC(w), 0.0F, 0.0F);
hig_workarea_add_section_divider(t, &row);
return t;
@@ -1962,14 +1962,14 @@ static void setPeerViewColumns(GtkTreeView* peer_view)
case PEER_COL_DOWNLOAD_RATE_STRING:
r = gtk_cell_renderer_text_new();
g_object_set(G_OBJECT(r), "xalign", 1.0f, NULL);
g_object_set(G_OBJECT(r), "xalign", 1.0F, NULL);
c = gtk_tree_view_column_new_with_attributes(t, r, "text", col, NULL);
sort_col = PEER_COL_DOWNLOAD_RATE_DOUBLE;
break;
case PEER_COL_UPLOAD_RATE_STRING:
r = gtk_cell_renderer_text_new();
g_object_set(G_OBJECT(r), "xalign", 1.0f, NULL);
g_object_set(G_OBJECT(r), "xalign", 1.0F, NULL);
c = gtk_tree_view_column_new_with_attributes(t, r, "text", col, NULL);
sort_col = PEER_COL_UPLOAD_RATE_DOUBLE;
break;
@@ -2627,7 +2627,7 @@ static void on_edit_trackers(GtkButton* button, gpointer data)
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_container_add(GTK_CONTAINER(sw), w);
gtk_container_add(GTK_CONTAINER(fr), sw);
gtk_widget_set_size_request(fr, 500u, 166u);
gtk_widget_set_size_request(fr, 500U, 166U);
hig_workarea_add_wide_tall_control(t, &row, fr);
gtr_dialog_set_content(GTK_DIALOG(d), t);
@@ -2814,7 +2814,7 @@ static GtkWidget* tracker_page_new(struct DetailsImpl* di)
gtk_tree_view_append_column(GTK_TREE_VIEW(v), c);
r = gtk_cell_renderer_pixbuf_new();
g_object_set(r, "width", 20 + (GUI_PAD_SMALL * 2), "xpad", GUI_PAD_SMALL, "ypad", pad, "yalign", 0.0f, NULL);
g_object_set(r, "width", 20 + (GUI_PAD_SMALL * 2), "xpad", GUI_PAD_SMALL, "ypad", pad, "yalign", 0.0F, NULL);
gtk_tree_view_column_pack_start(c, r, FALSE);
gtk_tree_view_column_add_attribute(c, r, "pixbuf", TRACKER_COL_FAVICON);
+2 -2
View File
@@ -962,8 +962,8 @@ GtkWidget* gtr_file_list_new(TrCore* core, int torrentId)
/* add "size" column */
title = _("Size");
rend = gtk_cell_renderer_text_new();
g_object_set(rend, "alignment", PANGO_ALIGN_RIGHT, "font-desc", pango_font_description, "xpad", GUI_PAD, "xalign", 1.0f,
"yalign", 0.5f, NULL);
g_object_set(rend, "alignment", PANGO_ALIGN_RIGHT, "font-desc", pango_font_description, "xpad", GUI_PAD, "xalign", 1.0F,
"yalign", 0.5F, NULL);
col = gtk_tree_view_column_new_with_attributes(title, rend, NULL);
gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
gtk_tree_view_column_set_sort_column_id(col, FC_SIZE);
+4 -4
View File
@@ -961,8 +961,8 @@ GtkWidget* gtr_filter_bar_new(tr_session* session, GtkTreeModel* tmodel, GtkTree
gtk_box_pack_start(h_box, w, TRUE, TRUE, 0);
/* add a spacer */
w = gtk_alignment_new(0.0f, 0.0f, 0.0f, 0.0f);
gtk_widget_set_size_request(w, 0u, GUI_PAD_BIG);
w = gtk_alignment_new(0.0F, 0.0F, 0.0F, 0.0F);
gtk_widget_set_size_request(w, 0U, GUI_PAD_BIG);
gtk_box_pack_start(h_box, w, FALSE, FALSE, 0);
/* add the tracker combobox */
@@ -970,8 +970,8 @@ GtkWidget* gtr_filter_bar_new(tr_session* session, GtkTreeModel* tmodel, GtkTree
gtk_box_pack_start(h_box, w, TRUE, TRUE, 0);
/* add a spacer */
w = gtk_alignment_new(0.0f, 0.0f, 0.0f, 0.0f);
gtk_widget_set_size_request(w, 0u, GUI_PAD_BIG);
w = gtk_alignment_new(0.0F, 0.0F, 0.0F, 0.0F);
gtk_widget_set_size_request(w, 0U, GUI_PAD_BIG);
gtk_box_pack_start(h_box, w, FALSE, FALSE, 0);
/* add the entry field */
+6 -6
View File
@@ -22,9 +22,9 @@ GtkWidget* hig_workarea_create(void)
void hig_workarea_add_section_divider(GtkWidget* t, guint* row)
{
GtkWidget* w = gtk_alignment_new(0.0f, 0.0f, 0.0f, 0.0f);
GtkWidget* w = gtk_alignment_new(0.0F, 0.0F, 0.0F, 0.0F);
gtk_widget_set_size_request(w, 0u, 6u);
gtk_widget_set_size_request(w, 0U, 6U);
gtk_grid_attach(GTK_GRID(t), w, 0, *row, 2, 1);
++*row;
}
@@ -43,7 +43,7 @@ void hig_workarea_add_section_title(GtkWidget* t, guint* row, char const* sectio
g_snprintf(buf, sizeof(buf), "<b>%s</b>", section_title);
l = gtk_label_new(buf);
gtk_misc_set_alignment(GTK_MISC(l), 0.0f, 0.5f);
gtk_misc_set_alignment(GTK_MISC(l), 0.0F, 0.5F);
gtk_label_set_use_markup(GTK_LABEL(l), TRUE);
hig_workarea_add_section_title_widget(t, row, l);
}
@@ -77,7 +77,7 @@ void hig_workarea_add_label_w(GtkWidget* t, guint row, GtkWidget* w)
if (GTK_IS_MISC(w))
{
gtk_misc_set_alignment(GTK_MISC(w), 0.0f, 0.5f);
gtk_misc_set_alignment(GTK_MISC(w), 0.0F, 0.5F);
}
if (GTK_IS_LABEL(w))
@@ -92,7 +92,7 @@ static void hig_workarea_add_tall_control(GtkWidget* t, guint row, GtkWidget* co
{
if (GTK_IS_MISC(control))
{
gtk_misc_set_alignment(GTK_MISC(control), 0.0f, 0.5f);
gtk_misc_set_alignment(GTK_MISC(control), 0.0F, 0.5F);
}
g_object_set(control, "expand", TRUE, NULL);
@@ -103,7 +103,7 @@ static void hig_workarea_add_control(GtkWidget* t, guint row, GtkWidget* control
{
if (GTK_IS_MISC(control))
{
gtk_misc_set_alignment(GTK_MISC(control), 0.0f, 0.5f);
gtk_misc_set_alignment(GTK_MISC(control), 0.0F, 0.5F);
}
gtk_widget_set_hexpand(control, TRUE);
+5 -5
View File
@@ -317,7 +317,7 @@ GtkWidget* gtr_torrent_options_dialog_new(GtkWindow* parent, TrCore* core, tr_ct
/* "torrent file" row */
l = gtk_label_new_with_mnemonic(_("_Torrent file:"));
gtk_misc_set_alignment(GTK_MISC(l), 0.0f, 0.5f);
gtk_misc_set_alignment(GTK_MISC(l), 0.0F, 0.5F);
gtk_grid_attach(grid, l, 0, row, 1, 1);
w = gtk_file_chooser_button_new(_("Select Source File"), GTK_FILE_CHOOSER_ACTION_OPEN);
source_chooser = w;
@@ -330,7 +330,7 @@ GtkWidget* gtr_torrent_options_dialog_new(GtkWindow* parent, TrCore* core, tr_ct
/* "destination folder" row */
row++;
l = gtk_label_new_with_mnemonic(_("_Destination folder:"));
gtk_misc_set_alignment(GTK_MISC(l), 0.0f, 0.5f);
gtk_misc_set_alignment(GTK_MISC(l), 0.0F, 0.5F);
gtk_grid_attach(grid, l, 0, row, 1, 1);
w = gtk_file_chooser_button_new(_("Select Destination Folder"), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
@@ -354,20 +354,20 @@ GtkWidget* gtr_torrent_options_dialog_new(GtkWindow* parent, TrCore* core, tr_ct
row++;
l = data->freespace_label = gtr_freespace_label_new(core, data->downloadDir);
gtk_widget_set_margin_bottom(l, GUI_PAD_BIG);
gtk_misc_set_alignment(GTK_MISC(l), 1.0f, 0.5f);
gtk_misc_set_alignment(GTK_MISC(l), 1.0F, 0.5F);
gtk_grid_attach(grid, l, 0, row, 2, 1);
/* file list row */
row++;
w = data->file_list;
gtk_widget_set_vexpand(w, TRUE);
gtk_widget_set_size_request(w, 466u, 300u);
gtk_widget_set_size_request(w, 466U, 300U);
gtk_grid_attach(grid, w, 0, row, 2, 1);
/* torrent priority row */
row++;
l = gtk_label_new_with_mnemonic(_("Torrent _priority:"));
gtk_misc_set_alignment(GTK_MISC(l), 0.0f, 0.5f);
gtk_misc_set_alignment(GTK_MISC(l), 0.0F, 0.5F);
gtk_grid_attach(grid, l, 0, row, 1, 1);
w = data->priority_combo;
gtk_label_set_mnemonic_widget(GTK_LABEL(l), w);
+7 -7
View File
@@ -98,7 +98,7 @@ static gboolean spun_cb_idle(gpointer spin)
struct spin_idle_data* data = g_object_get_data(o, IDLE_DATA);
/* has the user stopped making changes? */
if (g_timer_elapsed(data->last_change, NULL) > 0.33f)
if (g_timer_elapsed(data->last_change, NULL) > 0.33F)
{
/* update the core */
tr_quark const key = GPOINTER_TO_INT(g_object_get_data(o, PREF_KEY));
@@ -280,7 +280,7 @@ static GtkWidget* downloadingPage(GObject* core, struct prefs_dialog_data* data)
hig_workarea_add_row(t, &row, _("Save to _Location:"), w, NULL);
l = data->freespace_label = gtr_freespace_label_new(TR_CORE(core), NULL);
gtk_misc_set_alignment(GTK_MISC(l), 1.0f, 0.5f);
gtk_misc_set_alignment(GTK_MISC(l), 1.0F, 0.5F);
hig_workarea_add_wide_control(t, &row, l);
hig_workarea_add_section_divider(t, &row);
@@ -526,7 +526,7 @@ static GtkWidget* privacyPage(GObject* core)
target_cb(b, e);
w = gtk_label_new("");
gtk_misc_set_alignment(GTK_MISC(w), 0.0f, 0.5f);
gtk_misc_set_alignment(GTK_MISC(w), 0.0F, 0.5F);
updateBlocklistText(w, TR_CORE(core));
data->label = w;
h = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, GUI_PAD_BIG);
@@ -834,7 +834,7 @@ static GtkWidget* remotePage(GObject* core)
s = _("Addresses:");
w = hig_workarea_add_row(t, &row, s, w, NULL);
gtk_misc_set_alignment(GTK_MISC(w), 0.0f, 0.0f);
gtk_misc_set_alignment(GTK_MISC(w), 0.0F, 0.0F);
gtk_misc_set_padding(GTK_MISC(w), 0, GUI_PAD);
page->whitelist_widgets = g_slist_prepend(page->whitelist_widgets, w);
@@ -994,7 +994,7 @@ static GtkWidget* speedPage(GObject* core)
h = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, GUI_PAD);
g_snprintf(buf, sizeof(buf), "<b>%s</b>", _("Alternative Speed Limits"));
w = gtk_label_new(buf);
gtk_misc_set_alignment(GTK_MISC(w), 0.0f, 0.5f);
gtk_misc_set_alignment(GTK_MISC(w), 0.0F, 0.5F);
gtk_label_set_use_markup(GTK_LABEL(w), TRUE);
gtk_box_pack_start(GTK_BOX(h), w, FALSE, FALSE, 0);
w = gtk_image_new_from_stock("alt-speed-on", -1);
@@ -1005,7 +1005,7 @@ static GtkWidget* speedPage(GObject* core)
g_snprintf(buf, sizeof(buf), "<small>%s</small>", s);
w = gtk_label_new(buf);
gtk_label_set_use_markup(GTK_LABEL(w), TRUE);
gtk_misc_set_alignment(GTK_MISC(w), 0.0f, 0.5f);
gtk_misc_set_alignment(GTK_MISC(w), 0.0F, 0.5F);
hig_workarea_add_wide_control(t, &row, w);
g_snprintf(buf, sizeof(buf), _("U_pload (%s):"), _(speed_K_str));
@@ -1137,7 +1137,7 @@ static GtkWidget* networkPage(GObject* core)
h = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, GUI_PAD_BIG);
l = data->portLabel = gtk_label_new(_("Status unknown"));
gtk_misc_set_alignment(GTK_MISC(l), 0.0f, 0.5f);
gtk_misc_set_alignment(GTK_MISC(l), 0.0F, 0.5F);
gtk_box_pack_start(GTK_BOX(h), l, TRUE, TRUE, 0);
w = data->portButton = gtk_button_new_with_mnemonic(_("Te_st Port"));
gtk_box_pack_end(GTK_BOX(h), w, FALSE, FALSE, 0);
+1 -1
View File
@@ -647,7 +647,7 @@ GtkWidget* gtr_window_new(GtkApplication* app, GtkUIManager* ui_mgr, TrCore* cor
sibling = w;
/* spacer */
w = gtk_alignment_new(0.0f, 0.0f, 0.0f, 0.0f);
w = gtk_alignment_new(0.0F, 0.0F, 0.0F, 0.0F);
gtk_widget_set_hexpand(w, TRUE);
gtk_grid_attach_next_to(grid, w, sibling, GTK_POS_RIGHT, 1, 1);
sibling = w;
+2 -2
View File
@@ -50,7 +50,7 @@ static unsigned int getSpeed_Bps(struct bratecontrol const* r, unsigned int inte
}
}
rvolatile->cache_val = (unsigned int)(bytes * 1000u / interval_msec);
rvolatile->cache_val = (unsigned int)(bytes * 1000U / interval_msec);
rvolatile->cache_time = now;
}
@@ -161,7 +161,7 @@ static void allocateBandwidth(tr_bandwidth* b, tr_priority_t parent_priority, tr
if (b->band[dir].isLimited)
{
uint64_t const nextPulseSpeed = b->band[dir].desiredSpeed_Bps;
b->band[dir].bytesLeft = nextPulseSpeed * period_msec / 1000u;
b->band[dir].bytesLeft = nextPulseSpeed * period_msec / 1000U;
}
/* add this bandwidth's peer, if any, to the peer pool */
+1 -1
View File
@@ -28,7 +28,7 @@ struct tr_peerIo;
* it's included in the header for inlining and composition. */
enum
{
HISTORY_MSEC = 2000u,
HISTORY_MSEC = 2000U,
INTERVAL_MSEC = HISTORY_MSEC,
GRANULARITY_MSEC = 200,
HISTORY_SIZE = (INTERVAL_MSEC / GRANULARITY_MSEC),
+7 -7
View File
@@ -63,8 +63,8 @@ static size_t countArray(tr_bitfield const* b)
static size_t countRange(tr_bitfield const* b, size_t begin, size_t end)
{
size_t ret = 0;
size_t const first_byte = begin >> 3u;
size_t const last_byte = (end - 1) >> 3u;
size_t const first_byte = begin >> 3U;
size_t const last_byte = (end - 1) >> 3U;
if (b->bit_count == 0)
{
@@ -153,12 +153,12 @@ bool tr_bitfieldHas(tr_bitfield const* b, size_t n)
return false;
}
if (n >> 3u >= b->alloc_count)
if (n >> 3U >= b->alloc_count)
{
return false;
}
return (b->bits[n >> 3u] << (n & 7u) & 0x80) != 0;
return (b->bits[n >> 3U] << (n & 7U) & 0x80) != 0;
}
/***
@@ -399,7 +399,7 @@ void tr_bitfieldSetFromFlags(tr_bitfield* b, bool const* flags, size_t n)
if (flags[i])
{
++trueCount;
b->bits[i >> 3u] |= (0x80 >> (i & 7u));
b->bits[i >> 3U] |= (0x80 >> (i & 7U));
}
}
@@ -410,7 +410,7 @@ void tr_bitfieldAdd(tr_bitfield* b, size_t nth)
{
if (!tr_bitfieldHas(b, nth) && tr_bitfieldEnsureNthBitAlloced(b, nth))
{
b->bits[nth >> 3u] |= 0x80 >> (nth & 7u);
b->bits[nth >> 3U] |= 0x80 >> (nth & 7U);
tr_bitfieldIncTrueCount(b, 1);
}
}
@@ -470,7 +470,7 @@ void tr_bitfieldRem(tr_bitfield* b, size_t nth)
if (tr_bitfieldHas(b, nth) && tr_bitfieldEnsureNthBitAlloced(b, nth))
{
b->bits[nth >> 3u] &= 0xff7f >> (nth & 7u);
b->bits[nth >> 3U] &= 0xff7f >> (nth & 7U);
tr_bitfieldDecTrueCount(b, 1);
}
}
+1 -1
View File
@@ -224,7 +224,7 @@ void tr_cpGetAmountDone(tr_completion const* cp, float* tab, int tabCount)
{
if (seed)
{
tab[i] = 1.0f;
tab[i] = 1.0F;
}
else
{
+1 -1
View File
@@ -1053,7 +1053,7 @@ static unsigned int getDesiredOutputBufferSize(tr_peerIo const* io, uint64_t now
* or a few blocks, whichever is bigger.
* It's okay to tweak this as needed */
unsigned int const currentSpeed_Bps = tr_bandwidthGetPieceSpeed_Bps(&io->bandwidth, now, TR_UP);
unsigned int const period = 15u; /* arbitrary */
unsigned int const period = 15U; /* arbitrary */
/* the 3 is arbitrary; the .5 is to leave room for messages */
static unsigned int const ceiling = (unsigned int)(MAX_BLOCK_SIZE * 3.5);
return MAX(ceiling, currentSpeed_Bps * period);
+1 -1
View File
@@ -1412,7 +1412,7 @@ static bool messageLengthIsCorrect(tr_peerMsgs const* msg, uint8_t id, uint32_t
case BT_BITFIELD:
if (tr_torrentHasMetadata(msg->torrent))
{
return len == (msg->torrent->info.pieceCount >> 3) + ((msg->torrent->info.pieceCount & 7) != 0 ? 1 : 0) + 1u;
return len == (msg->torrent->info.pieceCount >> 3) + ((msg->torrent->info.pieceCount & 7) != 0 ? 1 : 0) + 1U;
}
/* we don't know the piece count yet,
+1 -1
View File
@@ -20,7 +20,7 @@
struct tr_session_stats const TR_SESSION_STATS_INIT =
{
.ratio = 0.0f,
.ratio = 0.0F,
.uploadedBytes = 0,
.downloadedBytes = 0,
.filesAdded = 0,
+3 -3
View File
@@ -509,7 +509,7 @@ static bool tr_torrentIsSeedIdleLimitDone(tr_torrent* tor)
{
uint16_t idleMinutes;
return tr_torrentGetSeedIdle(tor, &idleMinutes) &&
difftime(tr_time(), MAX(tor->startDate, tor->activityDate)) >= idleMinutes * 60u;
difftime(tr_time(), MAX(tor->startDate, tor->activityDate)) >= idleMinutes * 60U;
}
/***
@@ -809,7 +809,7 @@ uint32_t tr_getBlockSize(uint32_t pieceSize)
while (b > MAX_BLOCK_SIZE)
{
b /= 2u;
b /= 2U;
}
if (b == 0 || pieceSize % b != 0) /* not cleanly divisible */
@@ -1581,7 +1581,7 @@ tr_file_stat* tr_torrentFiles(tr_torrent const* tor, tr_file_index_t* fileCount)
{
uint64_t const b = isSeed ? tor->info.files[i].length : countFileBytesCompleted(tor, i);
walk->bytesCompleted = b;
walk->progress = tor->info.files[i].length > 0 ? (float)b / tor->info.files[i].length : 1.0f;
walk->progress = tor->info.files[i].length > 0 ? (float)b / tor->info.files[i].length : 1.0F;
}
if (fileCount != NULL)
+2 -2
View File
@@ -314,14 +314,14 @@ static int test_array(void)
size_t array[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
size_t n = TR_N_ELEMENTS(array);
tr_removeElementFromArray(array, 5u, sizeof(size_t), n--);
tr_removeElementFromArray(array, 5U, sizeof(size_t), n--);
for (size_t i = 0; i < n; ++i)
{
check_int(array[i], ==, i < 5 ? i : i + 1);
}
tr_removeElementFromArray(array, 0u, sizeof(size_t), n--);
tr_removeElementFromArray(array, 0U, sizeof(size_t), n--);
for (size_t i = 0; i < n; ++i)
{
+3 -3
View File
@@ -1085,7 +1085,7 @@ static void quickfindFirstK(char* base, size_t left, size_t right, size_t size,
{
if (right > left)
{
size_t const pivotIndex = left + (right - left) / 2u;
size_t const pivotIndex = left + (right - left) / 2U;
size_t const pivotNewIndex = quickfindPartition(base, left, right, size, compar, pivotIndex);
@@ -1974,7 +1974,7 @@ char* tr_formatter_size_B(char* buf, int64_t bytes, size_t buflen)
static struct formatter_units speed_units;
unsigned int tr_speed_K = 0u;
unsigned int tr_speed_K = 0U;
void tr_formatter_speed_init(unsigned int kilo, char const* kb, char const* mb, char const* gb, char const* tb)
{
@@ -2014,7 +2014,7 @@ char* tr_formatter_speed_KBps(char* buf, double KBps, size_t buflen)
static struct formatter_units mem_units;
unsigned int tr_mem_K = 0u;
unsigned int tr_mem_K = 0U;
void tr_formatter_mem_init(unsigned int kilo, char const* kb, char const* mb, char const* gb, char const* tb)
{
+2 -2
View File
@@ -147,11 +147,11 @@ static bool decode_hex_string(char const* in, unsigned int* setme)
}
else if ('a' <= *in && *in <= 'f')
{
val += *in - 'a' + 10u;
val += *in - 'a' + 10U;
}
else if ('A' <= *in && *in <= 'F')
{
val += *in - 'A' + 10u;
val += *in - 'A' + 10U;
}
else
{
+1 -1
View File
@@ -499,7 +499,7 @@ static void containerReserve(tr_variant* v, size_t count)
while (n < needed)
{
n *= 2u;
n *= 2U;
}
v->val.l.vals = tr_renew(tr_variant, v->val.l.vals, n);