error code in compiling

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
PsPfReAK
Posts: 61
Joined: Sat Mar 28, 2009 9:02 am
Contact:

error code in compiling

Post by PsPfReAK »

as you can tell im a noob seeking for help
lol

the problem is that im geting this error in my psp program
main.c (86) : warning: passing argument 1 of 'sceIoRead' makes integer from pointer without a cast
main.c (87) : warning: passing argument 1 of 'sceIoWrite' makes integer from pointer without a cast
and here are lines 86 and 87

Code: Select all

bytesRead = sceIoRead(InputFilePointer, buffer, readSize);
	bytesWritten = sceIoWrite(OutputFilePointer, buffer, bytesRead);
can anyone help me?
jojojoris
Posts: 255
Joined: Sun Mar 30, 2008 4:06 am

Re: error code in compiling

Post by jojojoris »

PsPfReAK wrote:as you can tell im a noob seeking for help
lol

the problem is that im geting this error in my psp program
main.c (86) : warning: passing argument 1 of 'sceIoRead' makes integer from pointer without a cast
main.c (87) : warning: passing argument 1 of 'sceIoWrite' makes integer from pointer without a cast
and here are lines 86 and 87

Code: Select all

bytesRead = sceIoRead(InputFilePointer, buffer, readSize);
	bytesWritten = sceIoWrite(OutputFilePointer, buffer, bytesRead);
can anyone help me?

Code: Select all

bytesRead = sceIoRead(*InputFilePointer, buffer, readSize);
	bytesWritten = sceIoWrite(*OutputFilePointer, buffer, bytesRead);

Code: Select all

int main(){
     SetupCallbacks();
     makeNiceGame();
     sceKernelExitGame();
}
PsPfReAK
Posts: 61
Joined: Sat Mar 28, 2009 9:02 am
Contact:

Re: error code in compiling

Post by PsPfReAK »

Code: Select all

bytesRead = sceIoRead(*InputFilePointer, buffer, readSize);
	bytesWritten = sceIoWrite(*OutputFilePointer, buffer, bytesRead);
[/quote]

okay, something must be wrong with my code

is this correct to flash a vshmain.prx or any file


Code: Select all

int flash_file(char *file, char *buf, int size) {
    p2c("Writing File %s.... ", file);
    fd = sceIoOpen(file, PSP_O_WRONLY | PSP_O_CREAT| PSP_O_TRUNC, 0777);
    if&#40;fd < 0&#41; &#123;
          TextColor&#40;RED&#41;;
          ErrorExit&#40;5000, "\n\nCannot open file for writing.\n"&#41;; &#125;
    written = sceIoWrite&#40;fd, buf, size&#41;;
    if&#40;written != file_size&#41; &#123;
               sceIoClose&#40;fd&#41;;
               TextColor&#40;RED&#41;;
               ErrorExit&#40;5000, "\n\nCannot write file.\n"&#41;; &#125;
    sceIoClose&#40;fd&#41;;
    p2c&#40;"OK\n\n"&#41;;
    return 0; &#125;
// copies the binary file contents from the input file to the output file
int copyFileContents&#40;SceUID* InputFilePointer, SceUID* OutputFilePointer&#41;
&#123;
	int readsize=512; // just an arbitrary value, generally larger chunks are faster in file copies due to the way sectors are handled on disk writes
	u8 buffer&#91;readsize&#93;;
	int bytesRead, bytesWritten;
	bytesRead = sceIoRead&#40;*InputFilePointer, buffer, readSize&#41;;
	bytesWritten = sceIoWrite&#40;*OutputFilePointer, buffer, bytesRead&#41;;
	if&#40;bytesWritten != bytesRead&#41;
	&#123;
		// write error
		return -1;
	&#125;
	return 1; // bytecopy successful
&#125;
MBx
Posts: 35
Joined: Sun Mar 22, 2009 12:52 am

Post by MBx »

why u passed pointers to "copyFileContents"?

Code: Select all

int copyFileContents&#40;SceUID InputFilePointer, SceUID OutputFilePointer&#41; 
...
   bytesRead = sceIoRead&#40;InputFilePointer, buffer, readSize&#41;;
   bytesWritten = sceIoWrite&#40;OutputFilePointer, buffer, bytesRead&#41;; 
...
PsPfReAK
Posts: 61
Joined: Sat Mar 28, 2009 9:02 am
Contact:

Post by PsPfReAK »

MBx wrote:why u passed pointers to "copyFileContents"?

Code: Select all

int copyFileContents&#40;SceUID InputFilePointer, SceUID OutputFilePointer&#41; 
...
   bytesRead = sceIoRead&#40;InputFilePointer, buffer, readSize&#41;;
   bytesWritten = sceIoWrite&#40;OutputFilePointer, buffer, bytesRead&#41;; 
...
so it will copy the data inside the file aswell as the actual file, i thought this would work but it doesnt, i still get an empty file
MBx
Posts: 35
Joined: Sun Mar 22, 2009 12:52 am

Post by MBx »

SceUID is just an ID, a number! nothing will copy into it!

did u tried my code?
PsPfReAK
Posts: 61
Joined: Sat Mar 28, 2009 9:02 am
Contact:

Post by PsPfReAK »

MBx wrote:SceUID is just an ID, a number! nothing will copy into it!

did u tried my code?

Code: Select all

int copyFileContents&#40;SceUID InputFilePointer, SceUID OutputFilePointer&#41;
...
   bytesRead = sceIoRead&#40;InputFilePointer, buffer, readSize&#41;;
   bytesWritten = sceIoWrite&#40;OutputFilePointer, buffer, bytesRead&#41;;
... 
this one?

yup, did the same thing

would this be correct, if so i'll do a re-write of the code

Code: Select all

fd= sceioopen&#40;"ms0&#58;/test.txt", PSP_O_RDONLY&#41;

sceiowrite&#40;flash0&#58;/test.txt", PSP_OWRONLY | PSP_O_CREAT

???
its supposed to flash test.txt to flash 0 ?
Last edited by PsPfReAK on Mon Mar 30, 2009 6:51 am, edited 1 time in total.
MBx
Posts: 35
Joined: Sun Mar 22, 2009 12:52 am

Post by MBx »

can you paste the complete code here please?
PsPfReAK
Posts: 61
Joined: Sat Mar 28, 2009 9:02 am
Contact:

Post by PsPfReAK »

MBx wrote:can you paste the complete code here please?
okay

Code: Select all

#include <pspsdk.h>
#include <pspkernel.h>
#include <pspctrl.h>
#include <string.h>
#include <stdio.h>
#include <stdarg.h>

////////////////////////////////////////////////////////////////////////////////
#define MODULE "test"
////////////////////////////////////////////////////////////////////////////////
PSP_MODULE_INFO&#40;MODULE, 0x0800, 1, 0&#41;; 
PSP_MAIN_THREAD_ATTR&#40;PSP_THREAD_ATTR_VSH&#41;;
////////////////////////////////////////////////////////////////////////////////
#define p2c pspDebugScreenPrintf
#define RED 0x111FFF
#define WHITE 0xFFFFF1
#define GREEN 0x0000FF00
#define TextColor pspDebugScreenSetTextColor
#define ClearScreen pspDebugScreenClear
#define test_size 13
char test_buffer&#91;test_size&#93;;
int readSize;

////////////////////////////////////////////////////////////////////////////////
char msg&#91;256&#93;;
int cbid;
int thid;
int written;
int file_size;
/////
SceUID fd;
/////
////////////////////////////////////////
int exit_callback&#40;int arg1, int arg2, void *common&#41; &#123;
    sceKernelExitGame&#40;&#41;;
	return 0; &#125;
////////////////////////////////////////
int CallbackThread&#40;SceSize args, void *argp&#41; &#123;
    cbid = sceKernelCreateCallback&#40;"Exit Callback", exit_callback, NULL&#41;;
    sceKernelRegisterExitCallback&#40;cbid&#41;;
    sceKernelSleepThreadCB&#40;&#41;;
	return 0; &#125;
////////////////////////////////////////
int SetupCallbacks&#40;void&#41; &#123;
    thid = 0;
    thid = sceKernelCreateThread&#40;"update_thread", CallbackThread, 0x11, 0xFA0, THREAD_ATTR_USER, 0&#41;;
    if &#40;thid >= 0&#41;
	sceKernelStartThread&#40;thid, 0, 0&#41;;
    return thid; &#125;
////////////////////////////////////////
void ErrorExit&#40;int milisecs, char *fmt, ...&#41; &#123;
	va_list list;
	va_start&#40;list, fmt&#41;;
	vsprintf&#40;msg, fmt, list&#41;;
	va_end&#40;list&#41;;
	p2c&#40;msg&#41;;
	sceKernelDelayThread&#40;milisecs*1000&#41;;
	sceKernelExitGame&#40;&#41;; &#125;
////////////////////////////////////////
int flash_file&#40;char *file, char *buf, int size&#41; &#123;
    p2c&#40;"Writing File %s.... ", file&#41;;
    fd = sceIoOpen&#40;file, PSP_O_WRONLY | PSP_O_CREAT| PSP_O_TRUNC, 0777&#41;;
    if&#40;fd < 0&#41; &#123;
          TextColor&#40;RED&#41;;
          ErrorExit&#40;5000, "\n\nCannot open file for writing.\n"&#41;; &#125;
    written = sceIoWrite&#40;fd, buf, size&#41;;
    if&#40;written != file_size&#41; &#123;
               sceIoClose&#40;fd&#41;;
               TextColor&#40;RED&#41;;
               ErrorExit&#40;5000, "\n\nCannot write file.\n"&#41;; &#125;
    sceIoClose&#40;fd&#41;;
    p2c&#40;"OK\n\n"&#41;;
    return 0; &#125;
////////////////////////////////////////
void remove_files&#40;char *files&#41; &#123;
     p2c&#40;"Removing File %s....", files&#41;;
     sceIoRemove&#40;files&#41;;
     p2c&#40;"OK\n"&#41;; &#125;
////////////////////////////////////////
// copies the binary file contents from the input file to the output file
int copyFileContents&#40;SceUID* InputFilePointer, SceUID* OutputFilePointer&#41;
&#123;
	int readsize=512; // just an arbitrary value, generally larger chunks are faster in file copies due to the way sectors are handled on disk writes
	u8 buffer&#91;readsize&#93;;
	int bytesRead, bytesWritten;
	bytesRead = sceIoRead&#40;*InputFilePointer, buffer, readSize&#41;;
	bytesWritten = sceIoWrite&#40;*OutputFilePointer, buffer, bytesRead&#41;;
	if&#40;bytesWritten != bytesRead&#41;
	&#123;
		// write error
		
		return -1;
	&#125;
	return 1; // bytecopy successful
&#125;
///////////////////////////////////////
int main&#40;&#41; &#123;
	pspDebugScreenInit&#40;&#41;;
	TextColor&#40;WHITE&#41;;
	SetupCallbacks&#40;&#41;;
    	
	p2c&#40;"test to\n"&#41;;
    p2c&#40;"flash test.txt with contents to flash0&#58;/\n"&#41;;
    p2c&#40;"To do so Press X to start at your own risk, R to exit.\n\n"&#41;;
    
	while &#40;1&#41; &#123;
        SceCtrlData pad;
        sceCtrlReadBufferPositive&#40;&pad, 1&#41;;

		if &#40;pad.Buttons & PSP_CTRL_CROSS&#41; &#123;
                        p2c&#40;"Assigning flash0.... "&#41;;                       
                        if &#40;sceIoUnassign&#40;"flash0&#58;"&#41; < 0&#41;
                        p2c&#40;"Cannot Un-Assign flash0&#58;"&#41;;
                        if &#40;sceIoAssign&#40;"flash0&#58;", "lflash0&#58;0,0", "flashfat0&#58;", IOASSIGN_RDWR, NULL, 0&#41; < 0&#41; &#123;
                                             p2c&#40;"Error Assigning flash0 in write mode"&#41;; &#125;
                        p2c&#40;"OK\n\n"&#41;;
                       
                        flash_file&#40;"flash0&#58;/test.txt", test_buffer, test_size&#41;;
                        break; &#125;

		else if &#40;pad.Buttons & PSP_CTRL_RTRIGGER&#41; &#123;
             p2c&#40;"\n\nExited by the user"&#41;;
             sceKernelExitGame&#40;&#41;; &#125;

		sceKernelDelayThread&#40;10000&#41;; &#125;
		
		p2c&#40;"\n\nPress X to Exit"&#41;;
		
		while &#40;1&#41; &#123;
        SceCtrlData pad;
        sceCtrlReadBufferPositive&#40;&pad, 1&#41;;

		if &#40;pad.Buttons & PSP_CTRL_CROSS&#41; &#123;
                        break; &#125;

		sceKernelDelayThread&#40;10000&#41;; &#125;
	
	sceKernelExitGame&#40;&#41;;

	return 0; &#125;
MBx
Posts: 35
Joined: Sun Mar 22, 2009 12:52 am

Post by MBx »

your code compiled well on my PC, I haven't test it to see if it works or not but it compiled.

do you have a compile problem?
PsPfReAK
Posts: 61
Joined: Sat Mar 28, 2009 9:02 am
Contact:

Post by PsPfReAK »

MBx wrote:your code compiled well on my PC, I haven't test it to see if it works or not but it compiled.

do you have a compile problem?
no it compiled fine, but say if you put the test.txt in the same directory as the eboot (with txt in it) it only flashes an empty file, or it may just fail...

i'll check back here later or tomorrow, thank you for your helo so far
NoEffex
Posts: 106
Joined: Thu Nov 27, 2008 6:48 am

Post by NoEffex »

Just a shot in the dark, but in the if(fd < 0) in the flash_file function, try

if(fd <= 0)

because it looks fine, writewise.
Programming with:
Geany + Latest PSPSDK from svn
PsPfReAK
Posts: 61
Joined: Sat Mar 28, 2009 9:02 am
Contact:

Post by PsPfReAK »

NoEffex wrote:Just a shot in the dark, but in the if(fd < 0) in the flash_file function, try

if(fd <= 0)

because it looks fine, writewise.
write failed

again, another blank text.txt....

just so all of you know, the text.txt is in the same directory as the eboot.pbp

ie psp/game/test <here lies the eboot.pbp and test.txt
jimparis
Posts: 1145
Joined: Fri Jun 10, 2005 4:21 am
Location: Boston

Post by jimparis »

sceIoWrite needs aligned buffers, which you might not have. Unless you really know what you're doing, just use the standard functions like open() and write() instead, as they already take care of this sort of thing.
PsPfReAK
Posts: 61
Joined: Sat Mar 28, 2009 9:02 am
Contact:

Post by PsPfReAK »

jimparis wrote:sceIoWrite needs aligned buffers, which you might not have. Unless you really know what you're doing, just use the standard functions like open() and write() instead, as they already take care of this sort of thing.
how do i use these?

do you mean sceioopen and sceiowrite??
NoEffex
Posts: 106
Joined: Thu Nov 27, 2008 6:48 am

Post by NoEffex »

I think it's because you're writing test_buffer, which is empty. I'm almost positive this is the problem.

To confirm, do something like

sprintf(test_buffer, "Test");

right before flash_file("flash0....
Programming with:
Geany + Latest PSPSDK from svn
PsPfReAK
Posts: 61
Joined: Sat Mar 28, 2009 9:02 am
Contact:

Post by PsPfReAK »

NoEffex wrote:I think it's because you're writing test_buffer, which is empty. I'm almost positive this is the problem.

To confirm, do something like

sprintf(test_buffer, "Test");

right before flash_file("flash0....
okay, that works, it flashes the text what ever is in the brackets, but how do i use this if i wanna say for example copy a prx or rco over?
NoEffex
Posts: 106
Joined: Thu Nov 27, 2008 6:48 am

Post by NoEffex »

PsPfReAK wrote:
NoEffex wrote:I think it's because you're writing test_buffer, which is empty. I'm almost positive this is the problem.

To confirm, do something like

sprintf(test_buffer, "Test");

right before flash_file("flash0....
okay, that works, it flashes the text what ever is in the brackets, but how do i use this if i wanna say for example copy a prx or rco over?
You'd fill the buffer with whatever data(And you'd need to make the buffer big enough, too).
Programming with:
Geany + Latest PSPSDK from svn
PsPfReAK
Posts: 61
Joined: Sat Mar 28, 2009 9:02 am
Contact:

Post by PsPfReAK »

NoEffex wrote:
PsPfReAK wrote:
NoEffex wrote:I think it's because you're writing test_buffer, which is empty. I'm almost positive this is the problem.

To confirm, do something like

sprintf(test_buffer, "Test");

right before flash_file("flash0....
okay, that works, it flashes the text what ever is in the brackets, but how do i use this if i wanna say for example copy a prx or rco over?
You'd fill the buffer with whatever data(And you'd need to make the buffer big enough, too).
so input the adrress where "Test" was?
NoEffex
Posts: 106
Joined: Thu Nov 27, 2008 6:48 am

Post by NoEffex »

What do you mean?

If you mean changing test_buffer and size and such, then test_buffer and the size argument would just be changed to the buffer containing the binary(and if it was large, you'd do a loop)

i.e.

Code: Select all

int flash_file&#40;char *filedest, char *filesrc&#41;
&#123;
	int fd0 = sceIoOpen&#40;filesrc, PSP_O_RDONLY, 0777&#41;;
	int fd1;
	if&#40;fd0 <= 0&#41; return -1;//No good, head back with error
	int len = sceIoLseek&#40;fd0, 0, 2&#41;; sceIoLseek&#40;fd0, 0, 0&#41;;//2 means SEEK_END, just a habit I have. Grabs the length of the file. Then it returns to the beginning.
	char buffer&#91;0x1000&#93;;//We'll use a buffer the size of 0x1000 for this.
	//Loop time
	int byteswritten;
	fd1 = sceIoOpen&#40;filedest, PSP_O_WRONLY | PSP_O_CREAT | PSP_O_TRUNC, 0777&#41;;//open up dest in create, truncate, and write mode
	while&#40;byteswritten < len&#41;
	&#123;
		int counter = len-byteswritten;//Just to make things easier
		sceIoRead&#40;fd0, buffer, counter >= 0x1000? 0x1000&#58; 0x1000-counter&#41;;//If counter is greater than 0x1000, then go ahead and do it normally, else get the difference, so we don't overwrite.
		byteswritten += sceIoWrite&#40;fd1, buffer, counter >= 0x1000? 0x1000&#58; 0x1000-counter&#41;;//Write the same condition as before
		sceIoLseek&#40;fd0, byteswritten, 0&#41;; sceIoLseek&#40;fd1, byteswritten, 0&#41;;//Seek to the offset on both
	&#125;
	return 0;//Return no error
&#125;
If there are errors, my bad, it's 2 in the morning.
Programming with:
Geany + Latest PSPSDK from svn
PsPfReAK
Posts: 61
Joined: Sat Mar 28, 2009 9:02 am
Contact:

Post by PsPfReAK »

NoEffex wrote:What do you mean?

If you mean changing test_buffer and size and such, then test_buffer and the size argument would just be changed to the buffer containing the binary(and if it was large, you'd do a loop)

i.e.

Code: Select all

int flash_file&#40;char *filedest, char *filesrc&#41;
&#123;
	int fd0 = sceIoOpen&#40;filesrc, PSP_O_RDONLY, 0777&#41;;
	int fd1;
	if&#40;fd0 <= 0&#41; return -1;//No good, head back with error
	int len = sceIoLseek&#40;fd0, 0, 2&#41;; sceIoLseek&#40;fd0, 0, 0&#41;;//2 means SEEK_END, just a habit I have. Grabs the length of the file. Then it returns to the beginning.
	char buffer&#91;0x1000&#93;;//We'll use a buffer the size of 0x1000 for this.
	//Loop time
	int byteswritten;
	fd1 = sceIoOpen&#40;filedest, PSP_O_WRONLY | PSP_O_CREAT | PSP_O_TRUNC, 0777&#41;;//open up dest in create, truncate, and write mode
	while&#40;byteswritten < len&#41;
	&#123;
		int counter = len-byteswritten;//Just to make things easier
		sceIoRead&#40;fd0, buffer, counter >= 0x1000? 0x1000&#58; 0x1000-counter&#41;;//If counter is greater than 0x1000, then go ahead and do it normally, else get the difference, so we don't overwrite.
		byteswritten += sceIoWrite&#40;fd1, buffer, counter >= 0x1000? 0x1000&#58; 0x1000-counter&#41;;//Write the same condition as before
		sceIoLseek&#40;fd0, byteswritten, 0&#41;; sceIoLseek&#40;fd1, byteswritten, 0&#41;;//Seek to the offset on both
	&#125;
	return 0;//Return no error
&#125;
If there are errors, my bad, it's 2 in the morning.
haha 2, so im gonna try and copy npaste this over my int flash_file and insert the file source and dest????

and what do know an error, lol

main.c: In function 'flash_file':
main.c (71) : warning: 'byteswritten' may be used uninitialized in this function

and line 71

while(byteswritten < len)

anyone????
Post Reply