[A] Added more cppcheck checks

This commit is contained in:
seleznevae
2018-11-18 11:11:39 +03:00
parent 39fcdf8e4e
commit 6fb83bc58f
6 changed files with 23 additions and 21 deletions

View File

@@ -1009,7 +1009,7 @@ fort_table_properties_t *copy_table_properties(const fort_table_properties_t *pr
destroy_vector(new_opt->cell_properties);
new_opt->cell_properties = copy_cell_properties(properties->cell_properties);
if (new_opt == NULL) {
if (new_opt->cell_properties == NULL) {
destroy_table_properties(new_opt);
return NULL;
}

View File

@@ -1,9 +1,10 @@
#include <assert.h>
#include <ctype.h>
#include "row.h"
#include "cell.h"
#include "string_buffer.h"
#include "assert.h"
#include "vector.h"
#include "ctype.h"
struct fort_row {
vector_t *cells;
@@ -33,13 +34,12 @@ fort_row_t *create_row(void)
FT_INTERNAL
void destroy_row(fort_row_t *row)
{
size_t i = 0;
if (row == NULL)
return;
if (row->cells) {
size_t cells_n = vector_size(row->cells);
for (i = 0; i < cells_n; ++i) {
for (size_t i = 0; i < cells_n; ++i) {
fort_cell_t *cell = *(fort_cell_t **)vector_at(row->cells, i);
destroy_cell(cell);
}

View File

@@ -319,8 +319,8 @@ size_t buffer_text_width(string_buffer_t *buffer)
max_length = MAX(max_length, (size_t)(end - beg));
++n;
}
} else {
#ifdef FT_HAVE_WCHAR
} else {
while (1) {
const wchar_t *beg = NULL;
const wchar_t *end = NULL;

View File

@@ -73,12 +73,11 @@ struct interval {
static int bisearch(wchar_t ucs, const struct interval *table, int max)
{
int min = 0;
int mid;
if (ucs < table[0].first || ucs > table[max].last)
return 0;
while (max >= min) {
mid = (min + max) / 2;
int mid = (min + max) / 2;
if (ucs > table[mid].last)
min = mid + 1;
else if (ucs < table[mid].first)
@@ -211,13 +210,15 @@ static int mk_wcwidth(wchar_t ucs)
FT_INTERNAL
int mk_wcswidth(const wchar_t *pwcs, size_t n)
{
int w, width = 0;
int width = 0;
for (; *pwcs && n-- > 0; pwcs++)
for (; *pwcs && n-- > 0; pwcs++) {
int w;
if ((w = mk_wcwidth(*pwcs)) < 0)
return -1;
else
width += w;
}
return width;
}