Skip to content

Commit

Permalink
Fixed some warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
fukuchi committed Oct 5, 2017
1 parent f318155 commit b25ff86
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- test_all.sh activates test_basic.sh + test_configure.sh.
- test_basic.sh is better during active development, especially when you
gave additional options to configure script.
* bitstream.c:
* split.c, qrspec.c, mqrspec.c, mask.c, mmask.c, qrencode.c, qrinput.c:
- Fixed some warnings.

2017.10.05 Kentaro Fukuchi <[email protected]>
Expand Down
10 changes: 5 additions & 5 deletions mask.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ unsigned char *Mask_makeMaskedFrame(int width, unsigned char *frame, int mask)
{
unsigned char *masked;

masked = (unsigned char *)malloc(width * width);
masked = (unsigned char *)malloc((size_t)(width * width));
if(masked == NULL) return NULL;

maskMakers[mask](width, frame, masked);
Expand All @@ -170,7 +170,7 @@ unsigned char *Mask_makeMask(int width, unsigned char *frame, int mask, QRecLeve
return NULL;
}

masked = (unsigned char *)malloc(width * width);
masked = (unsigned char *)malloc((size_t)(width * width));
if(masked == NULL) return NULL;

maskMakers[mask](width, frame, masked);
Expand Down Expand Up @@ -329,9 +329,9 @@ unsigned char *Mask_mask(int width, unsigned char *frame, QRecLevel level)
int demerit;
int w2 = width * width;

mask = (unsigned char *)malloc(w2);
mask = (unsigned char *)malloc((size_t)w2);
if(mask == NULL) return NULL;
bestMask = (unsigned char *)malloc(w2);
bestMask = (unsigned char *)malloc((size_t)w2);
if(bestMask == NULL) {
free(mask);
return NULL;
Expand All @@ -349,7 +349,7 @@ unsigned char *Mask_mask(int width, unsigned char *frame, QRecLevel level)
// printf("(%d,%d,%d,%d)=%d\n", n1, n2, n3 ,n4, demerit);
if(demerit < minDemerit) {
minDemerit = demerit;
memcpy(bestMask, mask, w2);
memcpy(bestMask, mask, (size_t)w2);
}
}
free(mask);
Expand Down
8 changes: 4 additions & 4 deletions mmask.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ unsigned char *MMask_makeMaskedFrame(int width, unsigned char *frame, int mask)
{
unsigned char *masked;

masked = (unsigned char *)malloc(width * width);
masked = (unsigned char *)malloc((size_t)(width * width));
if(masked == NULL) return NULL;

maskMakers[mask](width, frame, masked);
Expand All @@ -116,7 +116,7 @@ unsigned char *MMask_makeMask(int version, unsigned char *frame, int mask, QRecL
}

width = MQRspec_getWidth(version);
masked = (unsigned char *)malloc(width * width);
masked = (unsigned char *)malloc((size_t)(width * width));
if(masked == NULL) return NULL;

maskMakers[mask](width, frame, masked);
Expand Down Expand Up @@ -155,7 +155,7 @@ unsigned char *MMask_mask(int version, unsigned char *frame, QRecLevel level)

width = MQRspec_getWidth(version);

mask = (unsigned char *)malloc(width * width);
mask = (unsigned char *)malloc((size_t)(width * width));
if(mask == NULL) return NULL;
bestMask = NULL;

Expand All @@ -168,7 +168,7 @@ unsigned char *MMask_mask(int version, unsigned char *frame, QRecLevel level)
maxScore = score;
free(bestMask);
bestMask = mask;
mask = (unsigned char *)malloc(width * width);
mask = (unsigned char *)malloc((size_t)(width * width));
if(mask == NULL) break;
}
}
Expand Down
4 changes: 2 additions & 2 deletions mqrspec.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,10 @@ static unsigned char *MQRspec_createFrame(int version)
int x, y;

width = mqrspecCapacity[version].width;
frame = (unsigned char *)malloc(width * width);
frame = (unsigned char *)malloc((size_t)(width * width));
if(frame == NULL) return NULL;

memset(frame, 0, width * width);
memset(frame, 0, (size_t)(width * width));
/* Finder pattern */
putFinderPattern(frame, width, 0, 0);
/* Separator */
Expand Down
14 changes: 7 additions & 7 deletions qrencode.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,15 @@ STATIC_IN_RELEASE QRRawCode *QRraw_new(QRinput *input)
raw->b1 = QRspec_rsBlockNum1(spec);
raw->dataLength = QRspec_rsDataLength(spec);
raw->eccLength = QRspec_rsEccLength(spec);
raw->ecccode = (unsigned char *)malloc(raw->eccLength);
raw->ecccode = (unsigned char *)malloc((size_t)raw->eccLength);
if(raw->ecccode == NULL) {
free(raw->datacode);
free(raw);
return NULL;
}

raw->blocks = QRspec_rsBlockNum(spec);
raw->rsblock = (RSblock *)calloc(raw->blocks, sizeof(RSblock));
raw->rsblock = (RSblock *)calloc((size_t)(raw->blocks), sizeof(RSblock));
if(raw->rsblock == NULL) {
QRraw_free(raw);
return NULL;
Expand Down Expand Up @@ -219,7 +219,7 @@ STATIC_IN_RELEASE MQRRawCode *MQRraw_new(QRinput *input)
free(raw);
return NULL;
}
raw->ecccode = (unsigned char *)malloc(raw->eccLength);
raw->ecccode = (unsigned char *)malloc((size_t)raw->eccLength);
if(raw->ecccode == NULL) {
free(raw->datacode);
free(raw);
Expand Down Expand Up @@ -495,8 +495,8 @@ STATIC_IN_RELEASE QRcode *QRcode_encodeMask(QRinput *input, int mask)

/* masking */
if(mask == -2) { // just for debug purpose
masked = (unsigned char *)malloc(width * width);
memcpy(masked, frame, width * width);
masked = (unsigned char *)malloc((size_t)(width * width));
memcpy(masked, frame, (size_t)(width * width));
} else if(mask < 0) {
masked = Mask_mask(width, frame, input->level);
} else {
Expand Down Expand Up @@ -582,8 +582,8 @@ STATIC_IN_RELEASE QRcode *QRcode_encodeMaskMQR(QRinput *input, int mask)

/* masking */
if(mask == -2) { // just for debug purpose
masked = (unsigned char *)malloc(width * width);
memcpy(masked, frame, width * width);
masked = (unsigned char *)malloc((size_t)(width * width));
memcpy(masked, frame, (size_t)(width * width));
} else if(mask < 0) {
masked = MMask_mask(version, frame, input->level);
} else {
Expand Down
4 changes: 2 additions & 2 deletions qrinput.c
Original file line number Diff line number Diff line change
Expand Up @@ -1438,10 +1438,10 @@ static int QRinput_List_shrinkEntry(QRinput_List *entry, int bytes)
{
unsigned char *data;

data = (unsigned char *)malloc(bytes);
data = (unsigned char *)malloc((size_t)bytes);
if(data == NULL) return -1;

memcpy(data, entry->data, bytes);
memcpy(data, entry->data, (size_t)bytes);
free(entry->data);
entry->data = data;
entry->size = bytes;
Expand Down
4 changes: 2 additions & 2 deletions qrspec.c
Original file line number Diff line number Diff line change
Expand Up @@ -431,10 +431,10 @@ static unsigned char *QRspec_createFrame(int version)
unsigned int verinfo, v;

width = qrspecCapacity[version].width;
frame = (unsigned char *)malloc(width * width);
frame = (unsigned char *)malloc((size_t)(width * width));
if(frame == NULL) return NULL;

memset(frame, 0, width * width);
memset(frame, 0, (size_t)(width * width));
/* Finder pattern */
putFinderPattern(frame, width, 0, 0);
putFinderPattern(frame, width, width - 7, 0);
Expand Down
4 changes: 2 additions & 2 deletions split.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ static QRencodeMode Split_identifyMode(const char *string, QRencodeMode hint)
unsigned char c, d;
unsigned int word;

c = string[0];
c = (unsigned char)string[0];

if(c == '\0') return QR_MODE_NUL;
if(isdigit(c)) {
return QR_MODE_NUM;
} else if(isalnum(c)) {
return QR_MODE_AN;
} else if(hint == QR_MODE_KANJI) {
d = string[1];
d = (unsigned char)string[1];
if(d != '\0') {
word = ((unsigned int)c << 8) | d;
if((word >= 0x8140 && word <= 0x9ffc) || (word >= 0xe040 && word <= 0xebbf)) {
Expand Down

0 comments on commit b25ff86

Please sign in to comment.