Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix gcc warnings #20

Merged
merged 16 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gui-win32/r16.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ runes16toutf(char *p, Rune16 *r, int nc)

op = p;
ep = p + nc;
while(c = *r++) {
while((c = *r++)) {
n = 1;
if(c >= Runeself)
n = runelen(c);
Expand Down
1 change: 1 addition & 0 deletions gui-win32/r16.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ Rune16* runes16dup(Rune16*);
Rune16* utftorunes16(Rune16*, char*, int);
char* runes16toutf(char*, Rune16*, int);
int runes16cmp(Rune16*, Rune16*);
void* smalloc(ulong);
14 changes: 7 additions & 7 deletions gui-win32/screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static Rendez rend;
Point ZP;

uint windowStyle;
const uint BORDERLESS = WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_THICKFRAME | WS_SYSMENU | WS_DLGFRAME | WS_CLIPSIBLINGS | WS_VISIBLE | WS_POPUP ^ WS_MINIMIZE | WS_MAXIMIZE;
const uint BORDERLESS = (WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_THICKFRAME | WS_SYSMENU | WS_DLGFRAME | WS_CLIPSIBLINGS | WS_VISIBLE) | (WS_POPUP ^ WS_MINIMIZE) | WS_MAXIMIZE;

static int
isready(void*a)
Expand Down Expand Up @@ -570,12 +570,12 @@ setcolor(ulong index, ulong red, ulong green, ulong blue)
}


uchar*
char*
clipreadunicode(HANDLE h)
{
Rune16 *p;
int n;
uchar *q;
char *q;

p = GlobalLock(h);
n = rune16nlen(p, runes16len(p)+1);
Expand All @@ -586,10 +586,10 @@ clipreadunicode(HANDLE h)
return q;
}

uchar *
char *
clipreadutf(HANDLE h)
{
uchar *p;
char *p;

p = GlobalLock(h);
p = strdup(p);
Expand All @@ -602,7 +602,7 @@ char*
clipread(void)
{
HANDLE h;
uchar *p;
char *p;

if(!OpenClipboard(window)) {
oserror();
Expand All @@ -626,7 +626,7 @@ int
clipwrite(char *buf)
{
HANDLE h;
char *p, *e;
char *p;
Rune16 *rp;
int n = strlen(buf);

Expand Down
4 changes: 2 additions & 2 deletions include/libsec.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ struct DESstate

void setupDESstate(DESstate *s, uchar key[8], uchar *ivec);
void des_key_setup(uchar[8], ulong[32]);
void block_cipher(ulong*, uchar*, int);
void block_cipher(ulong[32], uchar[8], int);
void desCBCencrypt(uchar*, int, DESstate*);
void desCBCdecrypt(uchar*, int, DESstate*);
void desECBencrypt(uchar*, int, DESstate*);
Expand Down Expand Up @@ -163,7 +163,7 @@ struct DES3state
};

void setupDES3state(DES3state *s, uchar key[3][8], uchar *ivec);
void triple_block_cipher(ulong keys[3][32], uchar*, int);
void triple_block_cipher(ulong keys[3][32], uchar[8], int);
void des3CBCencrypt(uchar*, int, DES3state*);
void des3CBCdecrypt(uchar*, int, DES3state*);
void des3ECBencrypt(uchar*, int, DES3state*);
Expand Down
1 change: 1 addition & 0 deletions kern/devip-win32.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <winsock2.h>
#include <windows.h>
#include <ws2tcpip.h>
#include "u.h"
Expand Down
2 changes: 1 addition & 1 deletion kern/devmnt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1113,8 +1113,8 @@ mntfree(Mntrpc *r)
lock(&mntalloc.lk);
if(mntalloc.nrpcfree >= 10){
free(r->rpc);
free(r);
freetag(r->request.tag);
free(r);
}
else{
r->list = mntalloc.rpcfree;
Expand Down
4 changes: 2 additions & 2 deletions kern/win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ WinMain(HINSTANCE x, HINSTANCE y, LPSTR z, int w)
Rune *warg;

if(0 && win_hasunicode()){
warg = GetCommandLineW();
warg = (Rune*)GetCommandLineW();
n = (wstrlen(warg)+1)*UTFmax;
arg = malloc(n);
wstrtoutf(arg, warg, n);
Expand Down Expand Up @@ -465,6 +465,6 @@ showfilewrite(char *a, int n)
action = Lopen;
arg = cmd;
}
ShellExecute(0, 0, action, arg, 0, SW_SHOWNORMAL);
ShellExecute(0, 0, (LPCWSTR)action, (LPCWSTR)arg, 0, SW_SHOWNORMAL);
return n;
}
2 changes: 1 addition & 1 deletion libauthsrv/opasstokey.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ opasstokey(char *key, char *p)
return 0;
if(n > 10)
n = 10;
strncpy((char*)t, p, n);
memcpy((char*)t, p, n);
if(n >= 9){
c = p[8] & 0xf;
if(n == 10)
Expand Down
13 changes: 7 additions & 6 deletions libc/runevsmprint.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,24 @@ static int
runeFmtStrFlush(Fmt *f)
{
Rune *s;
int n;
int n, d;

if(f->start == nil)
return 0;
n = (uintptr)f->farg;
n *= 2;
s = (Rune*)f->start;
f->start = realloc(s, sizeof(Rune)*n);
if(f->start == nil){
d = (Rune*)f->to - (Rune*)f->start;
s = realloc(f->start, sizeof(Rune)*n);
if(s == nil){
f->farg = nil;
f->to = nil;
f->stop = nil;
free(s);
free(f->start);
return 0;
}
f->start = s;
f->farg = (void*)(uintptr)n;
f->to = (Rune*)f->start + ((Rune*)f->to - s);
f->to = (Rune*)f->start + d;
f->stop = (Rune*)f->start + n - 1;
return 1;
}
Expand Down
1 change: 1 addition & 0 deletions libc/strtod.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <u.h>
#include <libc.h>
#include <ctype.h>
#include "fmtdef.h"

static ulong
Expand Down
13 changes: 7 additions & 6 deletions libc/vsmprint.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,24 @@ static int
fmtStrFlush(Fmt *f)
{
char *s;
int n;
int n, d;

if(f->start == nil)
return 0;
n = (uintptr)f->farg;
n *= 2;
s = (char*)f->start;
f->start = realloc(s, n);
if(f->start == nil){
d = (char*)f->to - (char*)f->start;
s = realloc(f->start, n);
if(s == nil){
f->farg = nil;
f->to = nil;
f->stop = nil;
free(s);
free(f->start);
return 0;
}
f->start = s;
f->farg = (void*)(uintptr)n;
f->to = (char*)f->start + ((char*)f->to - s);
f->to = (char*)f->start + d;
f->stop = (char*)f->start + n - 1;
return 1;
}
Expand Down
8 changes: 4 additions & 4 deletions libmemdraw/draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ _memimagedrawsetup(Memimage *dst, Rectangle r, Memimage *src, Point p0, Memimage
if(mask == nil)
mask = memopaque;

DBG print("memimagedraw %p/%luX %R @ %p %p/%luX %P %p/%luX %P... ", dst, dst->chan, r, dst->data->bdata, src, src->chan, p0, mask, mask->chan, p1);
DBG print("memimagedraw %p/%luX %R @ %p %p/%luX %P %p/%luX %P... ", dst, dst->chan, r, dst->data->bdata, src, src->chan, p0, mask, mask->chan, p1);

if(drawclip(dst, &r, src, &p0, mask, &p1, &par.sr, &par.mr) == 0){
// if(drawdebug)
Expand Down Expand Up @@ -776,9 +776,9 @@ DBG print("[");
bmask = rdmask(&mpar, mpar.bufbase, masky);
DBG print("]\n");
bdst = rddst(&dpar, dpar.bufbase, dsty);
DBG dumpbuf("src", bsrc, dx);
DBG dumpbuf("mask", bmask, dx);
DBG dumpbuf("dst", bdst, dx);
DBG dumpbuf("src", bsrc, dx);
DBG dumpbuf("mask", bmask, dx);
DBG dumpbuf("dst", bdst, dx);
bdst = calc(bdst, bsrc, bmask, dx, isgrey, op);
wrdst(&dpar, dpar.bytermin+dsty*dpar.bwidth, bdst);
}
Expand Down
6 changes: 4 additions & 2 deletions libmemlayer/draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ memdraw(Memimage *dst, Rectangle r, Memimage *src, Point p0, Memimage *mask, Poi
mask = memopaque;

if(mask->layer){
if(drawdebug) iprint("mask->layer != nil\n");
if(drawdebug)
iprint("mask->layer != nil\n");
return; /* too hard, at least for now */
}

Expand All @@ -75,7 +76,8 @@ if(drawdebug) iprint("mask->layer != nil\n");
}

if(drawclip(dst, &r, src, &p0, mask, &p1, &srcr, &mr) == 0){
if(drawdebug) iprint("drawclip dstcr %R srccr %R maskcr %R\n", dst->clipr, src->clipr, mask->clipr);
if(drawdebug)
iprint("drawclip dstcr %R srccr %R maskcr %R\n", dst->clipr, src->clipr, mask->clipr);
return;
}

Expand Down
52 changes: 0 additions & 52 deletions libsec/aes.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ static uchar basekey[3][16] = {

static int aes_setupEnc(ulong rk[/*4*(Nr + 1)*/], const uchar cipherKey[],
int keyBits);
static int aes_setupDec(ulong rk[/*4*(Nr + 1)*/], const uchar cipherKey[],
int keyBits);
static int aes_setup(ulong erk[/*4*(Nr + 1)*/], ulong drk[/*4*(Nr + 1)*/],
const uchar cipherKey[], int keyBits);

Expand Down Expand Up @@ -1240,56 +1238,6 @@ aes_setupEnc(ulong rk[/*4*(Nr + 1)*/], const uchar cipherKey[], int keyBits)
return 0;
}

/**
* Expand the cipher key into the decryption key schedule.
*
* @return the number of rounds for the given cipher key size.
*/
static int
aes_setupDec(ulong rk[/* 4*(Nr + 1) */], const uchar cipherKey[], int keyBits)
{
int Nr, i, j;
ulong temp;

/* expand the cipher key: */
Nr = aes_setupEnc(rk, cipherKey, keyBits);
/* invert the order of the round keys: */
for (i = 0, j = 4*Nr; i < j; i += 4, j -= 4) {
temp = rk[i ]; rk[i ] = rk[j ]; rk[j ] = temp;
temp = rk[i + 1]; rk[i + 1] = rk[j + 1]; rk[j + 1] = temp;
temp = rk[i + 2]; rk[i + 2] = rk[j + 2]; rk[j + 2] = temp;
temp = rk[i + 3]; rk[i + 3] = rk[j + 3]; rk[j + 3] = temp;
}
/*
* apply the inverse MixColumn transform to all round keys
* but the first and the last:
*/
for (i = 1; i < Nr; i++) {
rk += 4;
rk[0] =
Td0[Te4[(rk[0] >> 24) ]] ^
Td1[Te4[(rk[0] >> 16) & 0xff]] ^
Td2[Te4[(rk[0] >> 8) & 0xff]] ^
Td3[Te4[(rk[0] ) & 0xff]];
rk[1] =
Td0[Te4[(rk[1] >> 24) ]] ^
Td1[Te4[(rk[1] >> 16) & 0xff]] ^
Td2[Te4[(rk[1] >> 8) & 0xff]] ^
Td3[Te4[(rk[1] ) & 0xff]];
rk[2] =
Td0[Te4[(rk[2] >> 24) ]] ^
Td1[Te4[(rk[2] >> 16) & 0xff]] ^
Td2[Te4[(rk[2] >> 8) & 0xff]] ^
Td3[Te4[(rk[2] ) & 0xff]];
rk[3] =
Td0[Te4[(rk[3] >> 24) ]] ^
Td1[Te4[(rk[3] >> 16) & 0xff]] ^
Td2[Te4[(rk[3] >> 8) & 0xff]] ^
Td3[Te4[(rk[3] ) & 0xff]];
}
return Nr;
}

/* using round keys in rk, perform Nr rounds of encrypting pt into ct */
void
aes_encrypt(const ulong rk[/* 4*(Nr + 1) */], int Nr, const uchar pt[16],
Expand Down
4 changes: 2 additions & 2 deletions libsec/des.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ keycompperm(u32int left, u32int right, ulong *ek)
}

void
des_key_setup(uchar key[8], ulong *ek)
des_key_setup(uchar key[8], ulong ek[32])
{
u32int left, right, v0, v1;

Expand Down Expand Up @@ -471,7 +471,7 @@ des64to56(uchar *k64, uchar *k56)
}

void
key_setup(uchar key[7], ulong *ek)
key_setup(uchar key[7], ulong ek[32])
{
uchar k64[8];

Expand Down
Loading