[mw-devel] [Git][arthur/mw][master] More SEEK_* usage
Andrew Price
welshbyte at sucs.org
Sat Nov 14 16:15:08 GMT 2015
Andrew Price pushed to branch master at Justin Mitchell / mw
Commits:
07679188 by Andrew Price at 2015-11-14T16:11:40Z
More SEEK_* usage
That coccinelle script works better without the semicolons (duh):
@rule0@
expression A,B;
@@
- lseek(A, B, 0)
+ lseek(A, B, SEEK_SET)
@rule1@
expression A,B;
@@
- lseek(A, B, 1)
+ lseek(A, B, SEEK_CUR)
@rule2@
expression A,B;
@@
- lseek(A, B, 2)
+ lseek(A, B, SEEK_END)
- - - - -
6 changed files:
- src/client/add.c
- src/client/edit.c
- src/client/mod.c
- src/client/new.c
- src/client/newmain.c
- src/client/read.c
Changes:
=====================================
src/client/add.c
=====================================
--- a/src/client/add.c
+++ b/src/client/add.c
@@ -159,7 +159,7 @@ int add_msg(int folnum, struct user *user, int replyto)
}
posn=(replyto-(fol->first))*sizeof(struct Header);
- tmppos=lseek(headfile,0,2);
+ tmppos=lseek(headfile, 0, SEEK_END);
if (posn<0 || posn>tmppos-sizeof(struct Header))
{
printf(_("There is no message %d\n"),replyto);
@@ -178,7 +178,7 @@ int add_msg(int folnum, struct user *user, int replyto)
free(new);
return(0);
}
- replyposn=lseek(headfile,0,1)-sizeof(inreplyto);
+ replyposn=lseek(headfile, 0, SEEK_CUR)-sizeof(inreplyto);
close(headfile);
inreplyto.status|=(1<<2);
}
@@ -371,7 +371,7 @@ int add_msg(int folnum, struct user *user, int replyto)
free(buff);
return(0);
}
- size=lseek(tfile,0,2);
+ size=lseek(tfile, 0, SEEK_END);
lseek(tfile, 0, SEEK_SET);
buff=(char *)realloc(buff,size);
read(tfile,buff,size);
@@ -397,7 +397,7 @@ int add_msg(int folnum, struct user *user, int replyto)
Lock_File(i);
Lock_File(data);
- new->datafield=lseek(data,0l,2);
+ new->datafield=lseek(data, 0l, SEEK_END);
lseek(folderfile, folnum * sizeof(struct folder), SEEK_SET);
read(folderfile,fol,sizeof(*fol));
lseek(folderfile, -1 * sizeof(struct folder), SEEK_CUR);
@@ -416,7 +416,7 @@ int add_msg(int folnum, struct user *user, int replyto)
new->Ref=0;
}
- tt=lseek(i,0,2);
+ tt=lseek(i, 0, SEEK_END);
td=tt%sizeof(*new);
if (td>0){
=====================================
src/client/edit.c
=====================================
--- a/src/client/edit.c
+++ b/src/client/edit.c
@@ -865,7 +865,7 @@ void mesg_edit(const char *args, struct folder *folder, int msgno, struct user *
perms_restore();
return;
}
- size=lseek(tfile,0,2);
+ size=lseek(tfile, 0, SEEK_END);
lseek(tfile, 0, SEEK_SET);
buff=(char *)realloc(buff,size);
read(tfile,buff,size);
@@ -875,7 +875,7 @@ void mesg_edit(const char *args, struct folder *folder, int msgno, struct user *
/* end of setuid stuff */
Lock_File(text);
- head.datafield=lseek(text,0,2);
+ head.datafield=lseek(text, 0, SEEK_END);
write(text,buff,size);
Unlock_File(text);
}else
=====================================
src/client/mod.c
=====================================
--- a/src/client/mod.c
+++ b/src/client/mod.c
@@ -30,7 +30,7 @@ static void add_message(struct folder *fold, struct Header *head, char *text)
Lock_File(modindex);
Lock_File(modtext);
head->Ref=fold->last;
- head->datafield=lseek(modtext,0,2);
+ head->datafield=lseek(modtext, 0, SEEK_END);
if (write(modindex,head,sizeof(*head))<0) {perror("mod: writehead");}
if (write(modtext,text,head->size)<0) {perror("mod: write text");}
@@ -53,7 +53,7 @@ static void put_back(struct folder *fold, struct Header *head, char *text)
exit(-1);
Lock_File(newindex);
Lock_File(newtext);
- head->datafield=lseek(newtext,0,2);
+ head->datafield=lseek(newtext, 0, SEEK_END);
head->Ref=0;
write(newindex,head,sizeof(*head));
write(newtext,text,head->size);
=====================================
src/client/new.c
=====================================
--- a/src/client/new.c
+++ b/src/client/new.c
@@ -149,7 +149,7 @@ static int read_new(struct user *user, struct folder *data, int folnum)
if (stringcmp(tmp,"reply",3))
{
long foo;
- foo=lseek(indexfile,0,1);
+ foo=lseek(indexfile, 0, SEEK_CUR);
add_msg(folnum, user, head.Ref);
lseek(indexfile, foo, SEEK_SET);
get_folder_number(data,folnum);
=====================================
src/client/newmain.c
=====================================
--- a/src/client/newmain.c
+++ b/src/client/newmain.c
@@ -723,7 +723,7 @@ void c_tidyup(CommandList *cm, int argc, const char **argv, char *args)
textbuff=(char *)malloc(idx.size+1);
lseek(textin, idx.datafield, SEEK_SET);
read(textin,textbuff,idx.size);
- idx.datafield=lseek(textout,0,1);
+ idx.datafield=lseek(textout, 0, SEEK_CUR);
write(textout,textbuff,idx.size);
write(indexout,&idx,sizeof(idx));
free(textbuff);
=====================================
src/client/read.c
=====================================
--- a/src/client/read.c
+++ b/src/client/read.c
@@ -129,7 +129,7 @@ int read_msg(int folnum, int msgnum, struct user *user)
close(headfile);
return false;
}
- tmppos=lseek(headfile,0,2);
+ tmppos=lseek(headfile, 0, SEEK_END);
posn=(msgnum - data.last - 1)*sizeof(struct Header);
if (posn < -tmppos)
lseek(headfile, 0, SEEK_SET);
@@ -283,7 +283,7 @@ int get_mesg_header(struct folder *data, int msgnum, struct Header *head)
return false;
/* no message - file too small */
- tmppos = lseek(headfile, 0, 2);
+ tmppos = lseek(headfile, 0, SEEK_END);
/* locate to file data */
posn=(msgnum - data->last - 1)*sizeof(struct Header);
View it on GitLab: https://projects.sucs.org/arthur/mw/commit/07679188dab56cc80227009d6969ee2e7d82ff1b
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sucs.org/pipermail/mw-devel/attachments/20151114/49f01d2e/attachment.html>
More information about the mw-devel
mailing list