Saturday, 15 January 2011

errno - IOCTL call and checking return value -



errno - IOCTL call and checking return value -

if((err = ioctl(fd, ioc_card_lock, &lock)) < 0) { printf("ioctl failed , returned errno %d \n",err); }

is above code right , programming practice? compile on pc. i.e populate err homecoming value of ioctl , check if err < 0

is above method standard way homecoming "err" returned ioctl.

there seem standard variable called errno? it? same above?

i found out improve way this.

if(ioctl(fd, ioc_card_lock, &lock) < 0) { printf("ioctl failed , returned errno %s \n",strerror(errno)); }

errno global variable set scheme calls.and strerror converts code (a negative integer) meaningful string ("invalid argument" example.)

ioctl errno

No comments:

Post a Comment