Skip to content

Commit 0e2eed0

Browse files
committed
Merge branch 'natoscott-darwin-ci-fixes'
2 parents 76989e4 + 7e6e363 commit 0e2eed0

18 files changed

Lines changed: 69 additions & 67 deletions

CommandLine.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ static CommandLineStatus parseArguments(int argc, char** argv, CommandLineSettin
209209
fprintf(stderr, "Error: invalid user \"%s\".\n", username);
210210
return STATUS_ERROR_EXIT;
211211
}
212-
flags->userId = atol(username);
212+
flags->userId = (uid_t)atol(username);
213213
}
214214
break;
215215
}

Header.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ void Header_setLayout(Header* this, HeaderLayout hLayout) {
7777
Header_calculateHeight(this);
7878
}
7979

80-
static void Header_addMeterByName(Header* this, const char* name, MeterModeId mode, unsigned int column) {
80+
static void Header_addMeterByName(Header* this, const char* name, MeterModeId mode, size_t column) {
8181
assert(column < HeaderLayout_getColumns(this->headerLayout));
8282

8383
Vector* meters = this->columns[column];
@@ -170,7 +170,7 @@ void Header_writeBackToSettings(const Header* this) {
170170
}
171171
}
172172

173-
Meter* Header_addMeterByClass(Header* this, const MeterClass* type, unsigned int param, unsigned int column) {
173+
Meter* Header_addMeterByClass(Header* this, const MeterClass* type, unsigned int param, size_t column) {
174174
assert(column < HeaderLayout_getColumns(this->headerLayout));
175175

176176
Vector* meters = this->columns[column];
@@ -198,8 +198,8 @@ void Header_draw(const Header* this) {
198198
for (int y = 0; y < height; y++) {
199199
mvhline(y, 0, ' ', COLS);
200200
}
201-
const int numCols = HeaderLayout_getColumns(this->headerLayout);
202-
const int width = COLS - 2 * pad - (numCols - 1);
201+
const size_t numCols = HeaderLayout_getColumns(this->headerLayout);
202+
const int width = COLS - 2 * pad - ((int)numCols - 1);
203203
int x = pad;
204204
float roundingLoss = 0.0F;
205205

@@ -253,7 +253,7 @@ void Header_updateData(Header* this) {
253253
* by counting how many columns to the right are empty or contain a BlankMeter.
254254
* Returns the number of columns to span, i.e. if the direct neighbor is occupied 1.
255255
*/
256-
static int calcColumnWidthCount(const Header* this, const Meter* curMeter, const int pad, const unsigned int curColumn, const int curHeight) {
256+
static int calcColumnWidthCount(const Header* this, const Meter* curMeter, const int pad, const size_t curColumn, const int curHeight) {
257257
for (size_t i = curColumn + 1; i < HeaderLayout_getColumns(this->headerLayout); i++) {
258258
const Vector* meters = this->columns[i];
259259

@@ -269,11 +269,11 @@ static int calcColumnWidthCount(const Header* this, const Meter* curMeter, const
269269
continue;
270270

271271
if (!Object_isA((const Object*) meter, (const ObjectClass*) &BlankMeter_class))
272-
return i - curColumn;
272+
return (int)(i - curColumn);
273273
}
274274
}
275275

276-
return HeaderLayout_getColumns(this->headerLayout) - curColumn;
276+
return (int)(HeaderLayout_getColumns(this->headerLayout) - curColumn);
277277
}
278278

279279
int Header_calculateHeight(Header* this) {

Header.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void Header_populateFromSettings(Header* this);
3535

3636
void Header_writeBackToSettings(const Header* this);
3737

38-
Meter* Header_addMeterByClass(Header* this, const MeterClass* type, unsigned int param, unsigned int column);
38+
Meter* Header_addMeterByClass(Header* this, const MeterClass* type, unsigned int param, size_t column);
3939

4040
void Header_reinit(Header* this);
4141

IncSet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ typedef enum {
2525
typedef struct IncMode_ {
2626
char buffer[INCMODE_MAX + 1];
2727
FunctionBar* bar;
28-
uint32_t index;
28+
size_t index;
2929
bool isFilter;
3030
} IncMode;
3131

Panel.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ in the source distribution for its full text.
1111

1212
#include <assert.h>
1313
#include <ctype.h>
14+
#include <limits.h>
1415
#include <stdbool.h>
1516
#include <stdlib.h>
1617
#include <string.h>
@@ -79,7 +80,7 @@ void Panel_done(Panel* this) {
7980

8081
void Panel_setCursorToSelection(Panel* this) {
8182
this->cursorY = this->y + this->selected - this->scrollV + 1;
82-
this->cursorX = this->x + this->selectedLen - this->scrollH;
83+
this->cursorX = this->x + (int)this->selectedLen - this->scrollH;
8384
}
8485

8586
void Panel_setSelectionColor(Panel* this, ColorElements colorId) {
@@ -421,7 +422,7 @@ bool Panel_onKey(Panel* this, int key) {
421422

422423
case KEY_CTRL('E'):
423424
case '$':
424-
this->scrollH = MAXIMUM(this->selectedLen - this->w, 0);
425+
this->scrollH = CLAMP((int)this->selectedLen - this->w, 0, INT_MAX);
425426
this->needsRedraw = true;
426427
break;
427428

Panel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ struct Panel_ {
6767
Vector* items;
6868
int selected;
6969
int oldSelected;
70-
int selectedLen;
70+
size_t selectedLen;
7171
void* eventHandlerState;
7272
int scrollV;
7373
int scrollH;

Process.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,7 @@ static bool Process_setPriority(Process* this, int priority) {
892892
bool Process_rowChangePriorityBy(Row* super, Arg delta) {
893893
Process* this = (Process*) super;
894894
assert(Object_isA((const Object*) this, (const ObjectClass*) &Process_class));
895-
return Process_setPriority(this, this->nice + delta.i);
895+
return Process_setPriority(this, (int)this->nice + delta.i);
896896
}
897897

898898
static bool Process_sendSignal(Process* this, Arg sgn) {

RichString.c

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ in the source distribution for its full text.
2121

2222
#define charBytes(n) (sizeof(CharType) * (n))
2323

24-
static void RichString_extendLen(RichString* this, int len) {
24+
static void RichString_extendLen(RichString* this, size_t len) {
2525
if (this->chptr == this->chstr) {
2626
// String is in internal buffer
2727
if (len > RICHSTRING_MAXLEN) {
@@ -46,13 +46,13 @@ static void RichString_extendLen(RichString* this, int len) {
4646
}
4747

4848
RichString_setChar(this, len, 0);
49-
this->chlen = len;
49+
this->chlen = (int)len;
5050
}
5151

52-
static void RichString_setLen(RichString* this, int len) {
52+
static void RichString_setLen(RichString* this, size_t len) {
5353
if (len < RICHSTRING_MAXLEN && this->chlen < RICHSTRING_MAXLEN) {
5454
RichString_setChar(this, len, 0);
55-
this->chlen = len;
55+
this->chlen = (int)len;
5656
} else {
5757
RichString_extendLen(this, len);
5858
}
@@ -97,33 +97,33 @@ static size_t mbstowcs_nonfatal(wchar_t* restrict dest, const char* restrict src
9797
return written;
9898
}
9999

100-
static inline int RichString_writeFromWide(RichString* this, int attrs, const char* data_c, int from, int len) {
100+
static inline int RichString_writeFromWide(RichString* this, int attrs, const char* data_c, int from, size_t len) {
101101
wchar_t data[len];
102102
len = mbstowcs_nonfatal(data, data_c, len);
103103
if (len <= 0)
104104
return 0;
105105

106-
int newLen = from + len;
106+
size_t newLen = from + len;
107107
RichString_setLen(this, newLen);
108-
for (int i = from, j = 0; i < newLen; i++, j++) {
108+
for (size_t i = from, j = 0; i < newLen; i++, j++) {
109109
this->chptr[i] = (CharType) { .attr = attrs & 0xffffff, .chars = { (iswprint(data[j]) ? data[j] : L'\xFFFD') } };
110110
}
111111

112-
return len;
112+
return (int)len;
113113
}
114114

115-
int RichString_appendnWideColumns(RichString* this, int attrs, const char* data_c, int len, int* columns) {
115+
int RichString_appendnWideColumns(RichString* this, int attrs, const char* data_c, size_t len, int* columns) {
116116
wchar_t data[len];
117117
len = mbstowcs_nonfatal(data, data_c, len);
118118
if (len <= 0)
119119
return 0;
120120

121121
int from = this->chlen;
122-
int newLen = from + len;
122+
size_t newLen = from + len;
123123
RichString_setLen(this, newLen);
124124
int columnsWritten = 0;
125125
int pos = from;
126-
for (int j = 0; j < len; j++) {
126+
for (size_t j = 0; j < len; j++) {
127127
wchar_t c = iswprint(data[j]) ? data[j] : L'\xFFFD';
128128
int cwidth = wcwidth(c);
129129
if (cwidth > *columns)
@@ -142,20 +142,20 @@ int RichString_appendnWideColumns(RichString* this, int attrs, const char* data_
142142
return pos - from;
143143
}
144144

145-
static inline int RichString_writeFromAscii(RichString* this, int attrs, const char* data, int from, int len) {
146-
int newLen = from + len;
145+
static inline int RichString_writeFromAscii(RichString* this, int attrs, const char* data, int from, size_t len) {
146+
size_t newLen = from + len;
147147
RichString_setLen(this, newLen);
148-
for (int i = from, j = 0; i < newLen; i++, j++) {
148+
for (size_t i = from, j = 0; i < newLen; i++, j++) {
149149
assert((unsigned char)data[j] <= SCHAR_MAX);
150150
this->chptr[i] = (CharType) { .attr = attrs & 0xffffff, .chars = { (isprint((unsigned char)data[j]) ? data[j] : L'\xFFFD') } };
151151
}
152152

153-
return len;
153+
return (int)len;
154154
}
155155

156-
inline void RichString_setAttrn(RichString* this, int attrs, int start, int charcount) {
157-
int end = CLAMP(start + charcount, 0, this->chlen);
158-
for (int i = start; i < end; i++) {
156+
inline void RichString_setAttrn(RichString* this, int attrs, size_t start, size_t charcount) {
157+
size_t end = CLAMP(start + charcount, 0, (size_t)this->chlen);
158+
for (size_t i = start; i < end; i++) {
159159
this->chptr[i].attr = attrs;
160160
}
161161
}
@@ -182,30 +182,31 @@ int RichString_findChar(const RichString* this, char c, int start) {
182182

183183
#else /* HAVE_LIBNCURSESW */
184184

185-
static inline int RichString_writeFromWide(RichString* this, int attrs, const char* data_c, int from, int len) {
186-
int newLen = from + len;
185+
static inline int RichString_writeFromWide(RichString* this, int attrs, const char* data_c, int from, size_t len) {
186+
size_t newLen = from + len;
187187
RichString_setLen(this, newLen);
188-
for (int i = from, j = 0; i < newLen; i++, j++) {
188+
for (size_t i = from, j = 0; i < newLen; i++, j++) {
189189
this->chptr[i] = (((unsigned char)data_c[j]) >= 32 ? ((unsigned char)data_c[j]) : '?') | attrs;
190190
}
191191
this->chptr[newLen] = 0;
192192

193193
return len;
194194
}
195195

196-
int RichString_appendnWideColumns(RichString* this, int attrs, const char* data_c, int len, int* columns) {
197-
int written = RichString_writeFromWide(this, attrs, data_c, this->chlen, MINIMUM(len, *columns));
196+
int RichString_appendnWideColumns(RichString* this, int attrs, const char* data_c, size_t len, int* columns) {
197+
size_t minlen = MINIMUM(len, (size_t) *columns);
198+
int written = RichString_writeFromWide(this, attrs, data_c, this->chlen, minlen);
198199
*columns = written;
199200
return written;
200201
}
201202

202-
static inline int RichString_writeFromAscii(RichString* this, int attrs, const char* data_c, int from, int len) {
203+
static inline int RichString_writeFromAscii(RichString* this, int attrs, const char* data_c, int from, size_t len) {
203204
return RichString_writeFromWide(this, attrs, data_c, from, len);
204205
}
205206

206-
void RichString_setAttrn(RichString* this, int attrs, int start, int charcount) {
207-
int end = CLAMP(start + charcount, 0, this->chlen);
208-
for (int i = start; i < end; i++) {
207+
void RichString_setAttrn(RichString* this, int attrs, size_t start, size_t charcount) {
208+
size_t end = CLAMP(start + charcount, 0, (size_t)this->chlen);
209+
for (size_t i = start; i < end; i++) {
209210
this->chptr[i] = (this->chptr[i] & 0xff) | attrs;
210211
}
211212
}
@@ -246,7 +247,7 @@ int RichString_appendWide(RichString* this, int attrs, const char* data) {
246247
return RichString_writeFromWide(this, attrs, data, this->chlen, strlen(data));
247248
}
248249

249-
int RichString_appendnWide(RichString* this, int attrs, const char* data, int len) {
250+
int RichString_appendnWide(RichString* this, int attrs, const char* data, size_t len) {
250251
return RichString_writeFromWide(this, attrs, data, this->chlen, len);
251252
}
252253

@@ -258,7 +259,7 @@ int RichString_appendAscii(RichString* this, int attrs, const char* data) {
258259
return RichString_writeFromAscii(this, attrs, data, this->chlen, strlen(data));
259260
}
260261

261-
int RichString_appendnAscii(RichString* this, int attrs, const char* data, int len) {
262+
int RichString_appendnAscii(RichString* this, int attrs, const char* data, size_t len) {
262263
return RichString_writeFromAscii(this, attrs, data, this->chlen, len);
263264
}
264265

RichString.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void RichString_delete(RichString* this);
5050

5151
void RichString_rewind(RichString* this, int count);
5252

53-
void RichString_setAttrn(RichString* this, int attrs, int start, int charcount);
53+
void RichString_setAttrn(RichString* this, int attrs, size_t start, size_t charcount);
5454

5555
int RichString_findChar(const RichString* this, char c, int start);
5656

@@ -63,17 +63,17 @@ void RichString_appendChr(RichString* this, int attrs, char c, int count);
6363
int RichString_appendWide(RichString* this, int attrs, const char* data);
6464

6565
ATTR_ACCESS3_R(3, 4)
66-
int RichString_appendnWide(RichString* this, int attrs, const char* data, int len);
66+
int RichString_appendnWide(RichString* this, int attrs, const char* data, size_t len);
6767

6868
/* columns takes the maximum number of columns to write and contains on return the number of columns written. */
69-
int RichString_appendnWideColumns(RichString* this, int attrs, const char* data, int len, int* columns);
69+
int RichString_appendnWideColumns(RichString* this, int attrs, const char* data, size_t len, int* columns);
7070

7171
int RichString_writeWide(RichString* this, int attrs, const char* data);
7272

7373
int RichString_appendAscii(RichString* this, int attrs, const char* data);
7474

7575
ATTR_ACCESS3_R(3, 4)
76-
int RichString_appendnAscii(RichString* this, int attrs, const char* data, int len);
76+
int RichString_appendnAscii(RichString* this, int attrs, const char* data, size_t len);
7777

7878
int RichString_writeAscii(RichString* this, int attrs, const char* data);
7979

ScreenManager.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,13 @@ static void ScreenManager_drawScreenTabs(ScreenManager* this) {
219219
attrset(CRT_colors[RESET_COLOR]);
220220
}
221221

222-
static void ScreenManager_drawPanels(ScreenManager* this, int focus, bool force_redraw) {
222+
static void ScreenManager_drawPanels(ScreenManager* this, size_t focus, bool force_redraw) {
223223
Settings* settings = this->host->settings;
224224
if (settings->screenTabs) {
225225
ScreenManager_drawScreenTabs(this);
226226
}
227-
const int nPanels = this->panelCount;
228-
for (int i = 0; i < nPanels; i++) {
227+
const size_t nPanels = this->panelCount;
228+
for (size_t i = 0; i < nPanels; i++) {
229229
Panel* panel = (Panel*) Vector_get(this->panels, i);
230230
Panel_draw(panel,
231231
force_redraw,
@@ -238,7 +238,7 @@ static void ScreenManager_drawPanels(ScreenManager* this, int focus, bool force_
238238

239239
void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey, const char* name) {
240240
bool quit = false;
241-
int focus = 0;
241+
size_t focus = 0;
242242

243243
Panel* panelFocus = (Panel*) Vector_get(this->panels, focus);
244244
Settings* settings = this->host->settings;

0 commit comments

Comments
 (0)