Skip to content

Commit 53d6e5a

Browse files
committed
linting continued
1 parent 2deddcd commit 53d6e5a

16 files changed

+214
-186
lines changed

foundation/assert.c

-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ assert_report_formatted(hash_t context, const char* condition, size_t cond_lengt
9898
const char* file, size_t file_length, unsigned int line,
9999
const char* msg, size_t msg_length, ...) {
100100
if (msg) {
101-
/*lint --e{438} Lint gets confused about assignment to ap */
102101
string_t buffer = { _assert_buffer, sizeof(_assert_buffer) };
103102
va_list ap;
104103
va_start(ap, msg_length);

foundation/event.c

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ _event_post_delay_with_flags(event_stream_t* stream, int id, object_t object,
3030
char* part;
3131
void* ptr;
3232
size_t psize;
33-
/*lint -e438 */
3433
va_list clist;
3534

3635
//Events must have non-zero id

foundation/log.c

+15-13
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,14 @@ static char _log_error_name[LOG_ERROR_NAMES][18] = {
8080
"script"
8181
};
8282

83-
struct _log_timestamp {
83+
struct log_timestamp_t {
8484
int hours;
8585
int minutes;
8686
int seconds;
8787
int milliseconds;
8888
};
8989

90-
typedef struct _log_timestamp log_timestamp_t;
90+
typedef struct log_timestamp_t log_timestamp_t;
9191

9292
static log_timestamp_t
9393
_log_make_timestamp(void) {
@@ -137,26 +137,28 @@ _log_outputf(hash_t context, error_level_t severity, const char* prefix, size_t
137137
while (1) {
138138
//This is guaranteed to always fit in minimum size of 383 bytes defined above, so need is always > 0
139139
if (_log_prefix)
140-
need = snprintf(buffer, (size_t)size, "[%d:%02d:%02d.%03d] <%" PRIx64 ":%u> %.*s", timestamp.hours,
141-
timestamp.minutes, timestamp.seconds, timestamp.milliseconds, tid, pid, (int)prefix_length, prefix);
140+
need = snprintf(buffer, (unsigned int)size, "[%d:%02d:%02d.%03d] <%" PRIx64 ":%u> %.*s",
141+
timestamp.hours, timestamp.minutes, timestamp.seconds, timestamp.milliseconds,
142+
tid, pid, (int)prefix_length, prefix);
142143
else
143-
need = snprintf(buffer, (size_t)size, "%.*s", (int)prefix_length, prefix);
144+
need = snprintf(buffer, (unsigned int)size, "%.*s", (int)prefix_length, prefix);
144145

145146
remain = size - need;
146147
{
147148
va_list clist;
148149
va_copy(clist, list);
149-
more = vsnprintf(buffer + need, (size_t)remain, format, clist);
150+
more = vsnprintf(buffer + need, (unsigned int)remain, format, clist);
150151
va_end(clist);
151152
}
152153

153154
if ((more > -1) && (more < remain)) {
154-
buffer[need + more] = '\n';
155-
buffer[need + more + 1] = 0;
155+
int endl = need + more;
156+
buffer[endl++] = '\n';
157+
buffer[endl] = 0;
156158

157159
#if FOUNDATION_PLATFORM_WINDOWS
158160
if (_log_stdout)
159-
OutputDebugStringA(buffer);
161+
OutputDebugStringA(buffer);
160162
#endif
161163

162164
#if FOUNDATION_PLATFORM_ANDROID
@@ -171,14 +173,14 @@ _log_outputf(hash_t context, error_level_t severity, const char* prefix, size_t
171173
#elif FOUNDATION_PLATFORM_PNACL
172174
FOUNDATION_UNUSED(std);
173175
if (_log_stdout)
174-
pnacl_post_log(context, severity, buffer, (size_t)(need + more + 1));
176+
pnacl_post_log(context, severity, buffer, (unsigned int)endl);
175177
#else
176178
if (_log_stdout && std)
177179
fprintf(std, "%s", buffer);
178180
#endif
179181

180182
if (_log_callback)
181-
_log_callback(context, severity, buffer, (size_t)(need + more));
183+
_log_callback(context, severity, buffer, (unsigned int)(endl - 1));
182184

183185
break;
184186
}
@@ -190,7 +192,7 @@ _log_outputf(hash_t context, error_level_t severity, const char* prefix, size_t
190192

191193
if (buffer != local_buffer)
192194
memory_deallocate(buffer);
193-
buffer = memory_allocate(0, (size_t)size + 2, 0, MEMORY_TEMPORARY);
195+
buffer = memory_allocate(0, (unsigned int)(size + 2), 0, MEMORY_TEMPORARY);
194196
}
195197
if (buffer != local_buffer)
196198
memory_deallocate(buffer);
@@ -359,7 +361,7 @@ log_set_suppress(hash_t context, error_level_t level) {
359361
if (!context)
360362
_log_suppress_default = level;
361363
else if (_log_suppress)
362-
hashtable64_set(_log_suppress, context, level + 1);
364+
hashtable64_set(_log_suppress, context, (unsigned int)(level + 1));
363365
}
364366

365367
error_level_t

foundation/main.c

+10-3
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ _main_console_handler(DWORD control_type) {
4343
}
4444
log_infof(0, STRING_CONST("Caught console control: %s (%d)"), control_name, control_type);
4545
if (post_terminate) {
46+
/*lint -e{970} */
4647
unsigned long level = 0, flags = 0;
4748

4849
system_post_event(FOUNDATIONEVENT_TERMINATE);
@@ -63,7 +64,12 @@ WinMain(HINSTANCE, HINSTANCE, LPSTR, int);
6364

6465
int STDCALL
6566
WinMain(HINSTANCE instance, HINSTANCE previnst, LPSTR cline, int cmd_show) {
66-
int ret = -1;
67+
int ret;
68+
69+
FOUNDATION_UNUSED(instance);
70+
FOUNDATION_UNUSED(previnst);
71+
FOUNDATION_UNUSED(cline);
72+
FOUNDATION_UNUSED(cmd_show);
6773

6874
if (main_initialize() < 0)
6975
return -1;
@@ -149,15 +155,16 @@ int
149155
main(int argc, char** argv)
150156
#endif
151157
{
152-
int ret = -1;
158+
int ret;
153159

154160
#if !FOUNDATION_PLATFORM_ANDROID && !FOUNDATION_PLATFORM_PNACL
155161
_environment_main_args(argc, (const char* const*)argv);
156162
#elif FOUNDATION_PLATFORM_PNACL
157163
FOUNDATION_UNUSED(instance);
158164
#endif
159165

160-
if ((ret = main_initialize()) < 0)
166+
ret = main_initialize();
167+
if (ret < 0)
161168
return ret;
162169

163170
#if FOUNDATION_PLATFORM_POSIX

foundation/md5.c

+76-73
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@
1212

1313
#include <foundation/foundation.h>
1414

15-
#define F1(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
16-
#define F2(x, y, z) ((y) ^ ((z) & ((x) ^ (y))))
17-
#define F3(x, y, z) ((x) ^ (y) ^ (z))
18-
#define F4(x, y, z) ((y) ^ ((x) | ~(z)))
15+
/*lint -e123 */
16+
#define MD5_F1(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
17+
#define MD5_F2(x, y, z) ((y) ^ ((z) & ((x) ^ (y))))
18+
#define MD5_F3(x, y, z) ((x) ^ (y) ^ (z))
19+
#define MD5_F4(x, y, z) ((y) ^ ((x) | ~(z)))
1920

2021
#define MD5_STEP(f, a, b, c, d, t, s) (a) += f((b), (c), (d)) + (t); (a) = (((a) << (s)) | ((a) >> (32 - (s)))); (a) += (b);
2122

@@ -45,73 +46,73 @@ md5_transform(md5_t* digest, const unsigned char* buffer) {
4546

4647
md5_decode(x, buffer, 64);
4748

48-
MD5_STEP(F1, a, b, c, d, x[ 0] + 0xd76aa478, 7);
49-
MD5_STEP(F1, d, a, b, c, x[ 1] + 0xe8c7b756, 12);
50-
MD5_STEP(F1, c, d, a, b, x[ 2] + 0x242070db, 17);
51-
MD5_STEP(F1, b, c, d, a, x[ 3] + 0xc1bdceee, 22);
52-
MD5_STEP(F1, a, b, c, d, x[ 4] + 0xf57c0faf, 7);
53-
MD5_STEP(F1, d, a, b, c, x[ 5] + 0x4787c62a, 12);
54-
MD5_STEP(F1, c, d, a, b, x[ 6] + 0xa8304613, 17);
55-
MD5_STEP(F1, b, c, d, a, x[ 7] + 0xfd469501, 22);
56-
MD5_STEP(F1, a, b, c, d, x[ 8] + 0x698098d8, 7);
57-
MD5_STEP(F1, d, a, b, c, x[ 9] + 0x8b44f7af, 12);
58-
MD5_STEP(F1, c, d, a, b, x[10] + 0xffff5bb1, 17);
59-
MD5_STEP(F1, b, c, d, a, x[11] + 0x895cd7be, 22);
60-
MD5_STEP(F1, a, b, c, d, x[12] + 0x6b901122, 7);
61-
MD5_STEP(F1, d, a, b, c, x[13] + 0xfd987193, 12);
62-
MD5_STEP(F1, c, d, a, b, x[14] + 0xa679438e, 17);
63-
MD5_STEP(F1, b, c, d, a, x[15] + 0x49b40821, 22);
64-
65-
MD5_STEP(F2, a, b, c, d, x[ 1] + 0xf61e2562, 5);
66-
MD5_STEP(F2, d, a, b, c, x[ 6] + 0xc040b340, 9);
67-
MD5_STEP(F2, c, d, a, b, x[11] + 0x265e5a51, 14);
68-
MD5_STEP(F2, b, c, d, a, x[ 0] + 0xe9b6c7aa, 20);
69-
MD5_STEP(F2, a, b, c, d, x[ 5] + 0xd62f105d, 5);
70-
MD5_STEP(F2, d, a, b, c, x[10] + 0x02441453, 9);
71-
MD5_STEP(F2, c, d, a, b, x[15] + 0xd8a1e681, 14);
72-
MD5_STEP(F2, b, c, d, a, x[ 4] + 0xe7d3fbc8, 20);
73-
MD5_STEP(F2, a, b, c, d, x[ 9] + 0x21e1cde6, 5);
74-
MD5_STEP(F2, d, a, b, c, x[14] + 0xc33707d6, 9);
75-
MD5_STEP(F2, c, d, a, b, x[ 3] + 0xf4d50d87, 14);
76-
MD5_STEP(F2, b, c, d, a, x[ 8] + 0x455a14ed, 20);
77-
MD5_STEP(F2, a, b, c, d, x[13] + 0xa9e3e905, 5);
78-
MD5_STEP(F2, d, a, b, c, x[ 2] + 0xfcefa3f8, 9);
79-
MD5_STEP(F2, c, d, a, b, x[ 7] + 0x676f02d9, 14);
80-
MD5_STEP(F2, b, c, d, a, x[12] + 0x8d2a4c8a, 20);
81-
82-
MD5_STEP(F3, a, b, c, d, x[ 5] + 0xfffa3942, 4);
83-
MD5_STEP(F3, d, a, b, c, x[ 8] + 0x8771f681, 11);
84-
MD5_STEP(F3, c, d, a, b, x[11] + 0x6d9d6122, 16);
85-
MD5_STEP(F3, b, c, d, a, x[14] + 0xfde5380c, 23);
86-
MD5_STEP(F3, a, b, c, d, x[ 1] + 0xa4beea44, 4);
87-
MD5_STEP(F3, d, a, b, c, x[ 4] + 0x4bdecfa9, 11);
88-
MD5_STEP(F3, c, d, a, b, x[ 7] + 0xf6bb4b60, 16);
89-
MD5_STEP(F3, b, c, d, a, x[10] + 0xbebfbc70, 23);
90-
MD5_STEP(F3, a, b, c, d, x[13] + 0x289b7ec6, 4);
91-
MD5_STEP(F3, d, a, b, c, x[ 0] + 0xeaa127fa, 11);
92-
MD5_STEP(F3, c, d, a, b, x[ 3] + 0xd4ef3085, 16);
93-
MD5_STEP(F3, b, c, d, a, x[ 6] + 0x04881d05, 23);
94-
MD5_STEP(F3, a, b, c, d, x[ 9] + 0xd9d4d039, 4);
95-
MD5_STEP(F3, d, a, b, c, x[12] + 0xe6db99e5, 11);
96-
MD5_STEP(F3, c, d, a, b, x[15] + 0x1fa27cf8, 16);
97-
MD5_STEP(F3, b, c, d, a, x[ 2] + 0xc4ac5665, 23);
98-
99-
MD5_STEP(F4, a, b, c, d, x[ 0] + 0xf4292244, 6);
100-
MD5_STEP(F4, d, a, b, c, x[ 7] + 0x432aff97, 10);
101-
MD5_STEP(F4, c, d, a, b, x[14] + 0xab9423a7, 15);
102-
MD5_STEP(F4, b, c, d, a, x[ 5] + 0xfc93a039, 21);
103-
MD5_STEP(F4, a, b, c, d, x[12] + 0x655b59c3, 6);
104-
MD5_STEP(F4, d, a, b, c, x[ 3] + 0x8f0ccc92, 10);
105-
MD5_STEP(F4, c, d, a, b, x[10] + 0xffeff47d, 15);
106-
MD5_STEP(F4, b, c, d, a, x[ 1] + 0x85845dd1, 21);
107-
MD5_STEP(F4, a, b, c, d, x[ 8] + 0x6fa87e4f, 6);
108-
MD5_STEP(F4, d, a, b, c, x[15] + 0xfe2ce6e0, 10);
109-
MD5_STEP(F4, c, d, a, b, x[ 6] + 0xa3014314, 15);
110-
MD5_STEP(F4, b, c, d, a, x[13] + 0x4e0811a1, 21);
111-
MD5_STEP(F4, a, b, c, d, x[ 4] + 0xf7537e82, 6);
112-
MD5_STEP(F4, d, a, b, c, x[11] + 0xbd3af235, 10);
113-
MD5_STEP(F4, c, d, a, b, x[ 2] + 0x2ad7d2bb, 15);
114-
MD5_STEP(F4, b, c, d, a, x[ 9] + 0xeb86d391, 21);
49+
MD5_STEP(MD5_F1, a, b, c, d, x[ 0] + 0xd76aa478, 7);
50+
MD5_STEP(MD5_F1, d, a, b, c, x[ 1] + 0xe8c7b756, 12);
51+
MD5_STEP(MD5_F1, c, d, a, b, x[ 2] + 0x242070db, 17);
52+
MD5_STEP(MD5_F1, b, c, d, a, x[ 3] + 0xc1bdceee, 22);
53+
MD5_STEP(MD5_F1, a, b, c, d, x[ 4] + 0xf57c0faf, 7);
54+
MD5_STEP(MD5_F1, d, a, b, c, x[ 5] + 0x4787c62a, 12);
55+
MD5_STEP(MD5_F1, c, d, a, b, x[ 6] + 0xa8304613, 17);
56+
MD5_STEP(MD5_F1, b, c, d, a, x[ 7] + 0xfd469501, 22);
57+
MD5_STEP(MD5_F1, a, b, c, d, x[ 8] + 0x698098d8, 7);
58+
MD5_STEP(MD5_F1, d, a, b, c, x[ 9] + 0x8b44f7af, 12);
59+
MD5_STEP(MD5_F1, c, d, a, b, x[10] + 0xffff5bb1, 17);
60+
MD5_STEP(MD5_F1, b, c, d, a, x[11] + 0x895cd7be, 22);
61+
MD5_STEP(MD5_F1, a, b, c, d, x[12] + 0x6b901122, 7);
62+
MD5_STEP(MD5_F1, d, a, b, c, x[13] + 0xfd987193, 12);
63+
MD5_STEP(MD5_F1, c, d, a, b, x[14] + 0xa679438e, 17);
64+
MD5_STEP(MD5_F1, b, c, d, a, x[15] + 0x49b40821, 22);
65+
66+
MD5_STEP(MD5_F2, a, b, c, d, x[ 1] + 0xf61e2562, 5);
67+
MD5_STEP(MD5_F2, d, a, b, c, x[ 6] + 0xc040b340, 9);
68+
MD5_STEP(MD5_F2, c, d, a, b, x[11] + 0x265e5a51, 14);
69+
MD5_STEP(MD5_F2, b, c, d, a, x[ 0] + 0xe9b6c7aa, 20);
70+
MD5_STEP(MD5_F2, a, b, c, d, x[ 5] + 0xd62f105d, 5);
71+
MD5_STEP(MD5_F2, d, a, b, c, x[10] + 0x02441453, 9);
72+
MD5_STEP(MD5_F2, c, d, a, b, x[15] + 0xd8a1e681, 14);
73+
MD5_STEP(MD5_F2, b, c, d, a, x[ 4] + 0xe7d3fbc8, 20);
74+
MD5_STEP(MD5_F2, a, b, c, d, x[ 9] + 0x21e1cde6, 5);
75+
MD5_STEP(MD5_F2, d, a, b, c, x[14] + 0xc33707d6, 9);
76+
MD5_STEP(MD5_F2, c, d, a, b, x[ 3] + 0xf4d50d87, 14);
77+
MD5_STEP(MD5_F2, b, c, d, a, x[ 8] + 0x455a14ed, 20);
78+
MD5_STEP(MD5_F2, a, b, c, d, x[13] + 0xa9e3e905, 5);
79+
MD5_STEP(MD5_F2, d, a, b, c, x[ 2] + 0xfcefa3f8, 9);
80+
MD5_STEP(MD5_F2, c, d, a, b, x[ 7] + 0x676f02d9, 14);
81+
MD5_STEP(MD5_F2, b, c, d, a, x[12] + 0x8d2a4c8a, 20);
82+
83+
MD5_STEP(MD5_F3, a, b, c, d, x[ 5] + 0xfffa3942, 4);
84+
MD5_STEP(MD5_F3, d, a, b, c, x[ 8] + 0x8771f681, 11);
85+
MD5_STEP(MD5_F3, c, d, a, b, x[11] + 0x6d9d6122, 16);
86+
MD5_STEP(MD5_F3, b, c, d, a, x[14] + 0xfde5380c, 23);
87+
MD5_STEP(MD5_F3, a, b, c, d, x[ 1] + 0xa4beea44, 4);
88+
MD5_STEP(MD5_F3, d, a, b, c, x[ 4] + 0x4bdecfa9, 11);
89+
MD5_STEP(MD5_F3, c, d, a, b, x[ 7] + 0xf6bb4b60, 16);
90+
MD5_STEP(MD5_F3, b, c, d, a, x[10] + 0xbebfbc70, 23);
91+
MD5_STEP(MD5_F3, a, b, c, d, x[13] + 0x289b7ec6, 4);
92+
MD5_STEP(MD5_F3, d, a, b, c, x[ 0] + 0xeaa127fa, 11);
93+
MD5_STEP(MD5_F3, c, d, a, b, x[ 3] + 0xd4ef3085, 16);
94+
MD5_STEP(MD5_F3, b, c, d, a, x[ 6] + 0x04881d05, 23);
95+
MD5_STEP(MD5_F3, a, b, c, d, x[ 9] + 0xd9d4d039, 4);
96+
MD5_STEP(MD5_F3, d, a, b, c, x[12] + 0xe6db99e5, 11);
97+
MD5_STEP(MD5_F3, c, d, a, b, x[15] + 0x1fa27cf8, 16);
98+
MD5_STEP(MD5_F3, b, c, d, a, x[ 2] + 0xc4ac5665, 23);
99+
100+
MD5_STEP(MD5_F4, a, b, c, d, x[ 0] + 0xf4292244, 6);
101+
MD5_STEP(MD5_F4, d, a, b, c, x[ 7] + 0x432aff97, 10);
102+
MD5_STEP(MD5_F4, c, d, a, b, x[14] + 0xab9423a7, 15);
103+
MD5_STEP(MD5_F4, b, c, d, a, x[ 5] + 0xfc93a039, 21);
104+
MD5_STEP(MD5_F4, a, b, c, d, x[12] + 0x655b59c3, 6);
105+
MD5_STEP(MD5_F4, d, a, b, c, x[ 3] + 0x8f0ccc92, 10);
106+
MD5_STEP(MD5_F4, c, d, a, b, x[10] + 0xffeff47d, 15);
107+
MD5_STEP(MD5_F4, b, c, d, a, x[ 1] + 0x85845dd1, 21);
108+
MD5_STEP(MD5_F4, a, b, c, d, x[ 8] + 0x6fa87e4f, 6);
109+
MD5_STEP(MD5_F4, d, a, b, c, x[15] + 0xfe2ce6e0, 10);
110+
MD5_STEP(MD5_F4, c, d, a, b, x[ 6] + 0xa3014314, 15);
111+
MD5_STEP(MD5_F4, b, c, d, a, x[13] + 0x4e0811a1, 21);
112+
MD5_STEP(MD5_F4, a, b, c, d, x[ 4] + 0xf7537e82, 6);
113+
MD5_STEP(MD5_F4, d, a, b, c, x[11] + 0xbd3af235, 10);
114+
MD5_STEP(MD5_F4, c, d, a, b, x[ 2] + 0x2ad7d2bb, 15);
115+
MD5_STEP(MD5_F4, b, c, d, a, x[ 9] + 0xeb86d391, 21);
115116

116117
digest->state[0] += a;
117118
digest->state[1] += b;
@@ -179,13 +180,15 @@ md5_digest(md5_t* digest, const void* buffer, size_t size) {
179180
memcpy(digest->buffer + index_buf, buffer, space_buf);
180181
md5_transform(digest, digest->buffer);
181182

182-
for (index_in = space_buf; index_in + 63 < size; index_in += 64)
183+
/*lint -e440 */
184+
for (index_in = space_buf; (index_in + 64) <= size; index_in += 64)
183185
md5_transform(digest, pointer_offset_const(buffer, index_in));
184186

185187
index_buf = 0;
186188
}
187-
else
189+
else {
188190
index_in = 0;
191+
}
189192

190193
memcpy(digest->buffer + index_buf, pointer_offset_const(buffer, index_in), size - index_in);
191194

0 commit comments

Comments
 (0)