diff --git a/components/utilities/zmodem/rz.c b/components/utilities/zmodem/rz.c index fe09f4c4a..3bac91a37 100644 --- a/components/utilities/zmodem/rz.c +++ b/components/utilities/zmodem/rz.c @@ -19,13 +19,13 @@ void zr_start(char *path); -static rt_err_t zrec_init(rt_uint8_t *rxbuf,struct zfile *zf); +static rt_err_t zrec_init(rt_uint8_t *rxbuf, struct zfile *zf); static rt_err_t zrec_files(struct zfile *zf); -static rt_err_t zwrite_file(rt_uint8_t *buf,rt_uint16_t size,struct zfile *zf); -static rt_err_t zrec_file_data(rt_uint8_t *buf,struct zfile *zf);; -static rt_err_t zrec_file(rt_uint8_t *rxbuf,struct zfile *zf); -static rt_err_t zget_file_info(char *name,struct zfile *zf); -static rt_err_t zwrite_file(rt_uint8_t *buf,rt_uint16_t size,struct zfile *zf); +static rt_err_t zwrite_file(rt_uint8_t *buf, rt_uint16_t size, struct zfile *zf); +static rt_err_t zrec_file_data(rt_uint8_t *buf, struct zfile *zf);; +static rt_err_t zrec_file(rt_uint8_t *rxbuf, struct zfile *zf); +static rt_err_t zget_file_info(char *name, struct zfile *zf); +static rt_err_t zwrite_file(rt_uint8_t *buf, rt_uint16_t size, struct zfile *zf); static void zrec_ack_bibi(void); @@ -87,7 +87,7 @@ void zr_start(char *path) } /* receiver init, wait for ack */ -static rt_err_t zrec_init(rt_uint8_t *rxbuf,struct zfile *zf) +static rt_err_t zrec_init(rt_uint8_t *rxbuf, struct zfile *zf) { rt_uint8_t err_cnt = 0; rt_err_t res = -RT_ERROR; @@ -183,7 +183,7 @@ static rt_err_t zrec_files(struct zfile *zf) } } /* receive file */ -static rt_err_t zrec_file(rt_uint8_t *rxbuf,struct zfile *zf) +static rt_err_t zrec_file(rt_uint8_t *rxbuf, struct zfile *zf) { rt_err_t res = - RT_ERROR; rt_uint16_t err_cnt = 0; @@ -248,7 +248,7 @@ again: } /* proccess file infomation */ -static rt_err_t zget_file_info(char *name,struct zfile *zf) +static rt_err_t zget_file_info(char *name, struct zfile *zf) { char *p; char *full_path,*ptr; @@ -299,7 +299,7 @@ static rt_err_t zget_file_info(char *name,struct zfile *zf) zf->fname = full_path; p = strlen(name)+name+1; sscanf((const char *)p, "%ld%lo%o", &zf->bytes_total,&zf->ctime,&zf->mode); -#ifdef DFS_USING_WORKDIR +#ifdef defined(RT_USING_DFS) && defined(DFS_USING_WORKDIR) dfs_statfs(working_directory,&buf); if (zf->bytes_total > (buf.f_blocks * buf.f_bfree)) { @@ -324,7 +324,7 @@ static rt_err_t zget_file_info(char *name,struct zfile *zf) } /* receive file data,continously, no ack */ -static rt_err_t zrec_file_data(rt_uint8_t *buf,struct zfile *zf) +static rt_err_t zrec_file_data(rt_uint8_t *buf, struct zfile *zf) { rt_err_t res = -RT_ERROR; @@ -369,7 +369,7 @@ more_data: } /* write file */ -static rt_err_t zwrite_file(rt_uint8_t *buf,rt_uint16_t size,struct zfile *zf) +static rt_err_t zwrite_file(rt_uint8_t *buf,rt_uint16_t size, struct zfile *zf) { return (write(zf->fd,buf,size)); } diff --git a/components/utilities/zmodem/sz.c b/components/utilities/zmodem/sz.c index 4109f1060..ad30c9736 100644 --- a/components/utilities/zmodem/sz.c +++ b/components/utilities/zmodem/sz.c @@ -25,9 +25,9 @@ static rt_uint8_t ZF2_OP; /* file transfer option */ void zs_start(char *path); static void zsend_init(void); static rt_err_t zsend_files(struct zfile *zf); -static rt_err_t zsend_file(struct zfile *zf,rt_uint8_t *buf, rt_uint16_t len); +static rt_err_t zsend_file(struct zfile *zf, rt_uint8_t *buf, rt_uint16_t len); static rt_err_t zsend_file_data(struct zfile *zf); -static rt_uint16_t zfill_buffer(struct zfile *zf,rt_uint8_t *buf,rt_uint16_t size); +static rt_uint16_t zfill_buffer(struct zfile *zf, rt_uint8_t *buf, rt_uint16_t size); static rt_err_t zget_sync(void); static void zsay_bibi(void); @@ -162,7 +162,7 @@ static rt_err_t zsend_files(struct zfile *zf) } /* send file name and related info */ -static rt_err_t zsend_file(struct zfile *zf,rt_uint8_t *buf, rt_uint16_t len) +static rt_err_t zsend_file(struct zfile *zf, rt_uint8_t *buf, rt_uint16_t len) { rt_uint8_t cnt; rt_err_t res = -RT_ERROR; @@ -262,7 +262,7 @@ get_syn1: } /* fill file data to buffer*/ -static rt_uint16_t zfill_buffer(struct zfile *zf,rt_uint8_t *buf,rt_uint16_t size) +static rt_uint16_t zfill_buffer(struct zfile *zf, rt_uint8_t *buf, rt_uint16_t size) { return (read(zf->fd,buf,size)); } diff --git a/components/utilities/zmodem/zcore.c b/components/utilities/zmodem/zcore.c index 98406727a..cd52e2b24 100644 --- a/components/utilities/zmodem/zcore.c +++ b/components/utilities/zmodem/zcore.c @@ -37,8 +37,8 @@ void zinit_parameter(void); void zsend_bin_header(rt_uint8_t type, rt_uint8_t *hdr); void zsend_hex_header(rt_uint8_t type, rt_uint8_t *hdr); void zsend_bin_data(rt_uint8_t *buf, rt_int16_t len, rt_uint8_t frameend); -static rt_int16_t zrec_data16(rt_uint8_t *buf,rt_uint16_t len); -static rt_int16_t zrec_data32(rt_uint8_t *buf,rt_int16_t len); +static rt_int16_t zrec_data16(rt_uint8_t *buf, rt_uint16_t len); +static rt_int16_t zrec_data32(rt_uint8_t *buf, rt_int16_t len); static rt_int16_t zrec_data32r(rt_uint8_t *buf, rt_int16_t len); rt_int16_t zget_data(rt_uint8_t *buf, rt_uint16_t len); rt_int16_t zget_header(rt_uint8_t *hdr); @@ -271,17 +271,16 @@ void zsend_bin_data(rt_uint8_t *buf, rt_int16_t len, rt_uint8_t frameend) } /* receive data,with 16bits CRC check */ -static rt_int16_t zrec_data16(rt_uint8_t *buf,rt_uint16_t len) +static rt_int16_t zrec_data16(rt_uint8_t *buf, rt_uint16_t len) { rt_int16_t c,crc_cnt; rt_uint16_t crc; rt_err_t res = -RT_ERROR; rt_uint8_t *p,flag = 0; - rt_uint8_t i =0, debug[20]; - p = buf; - crc = 0L; - Rxcount = 0; - debug[0] = debug[4] = 0; + + p = buf; + crc_cnt = 0; crc = 0L; + Rxcount = 0; while(buf <= p+len) { if ((res = zread_byte()) & ~0377) @@ -290,8 +289,6 @@ static rt_int16_t zrec_data16(rt_uint8_t *buf,rt_uint16_t len) res == GOTCRCQ || res == GOTCRCW) { c = res; - debug[i++] = res; - c = debug[0]; c = res; crc = updcrc16(res&0377, crc); flag = 1; @@ -308,7 +305,6 @@ static rt_int16_t zrec_data16(rt_uint8_t *buf,rt_uint16_t len) { crc = updcrc16(res, crc); crc_cnt++; - debug[i++] = res; if (crc_cnt < 2) continue; if ((crc & 0xffff)) { @@ -332,14 +328,14 @@ static rt_int16_t zrec_data16(rt_uint8_t *buf,rt_uint16_t len) } /* receive data,with 32bits CRC check */ -static rt_int16_t zrec_data32(rt_uint8_t *buf,rt_int16_t len) +static rt_int16_t zrec_data32(rt_uint8_t *buf, rt_int16_t len) { - rt_int16_t c,crc_cnt = 0; + rt_int16_t c,crc_cnt; rt_uint32_t crc; rt_err_t res = -RT_ERROR; rt_uint8_t *p,flag = 0; - crc = 0xffffffffL; + crc_cnt = 0; crc = 0xffffffffL; Rxcount = 0; while (buf <= p+len) { @@ -388,12 +384,12 @@ static rt_int16_t zrec_data32(rt_uint8_t *buf,rt_int16_t len) /* receive data,with RLE encoded,32bits CRC check */ static rt_int16_t zrec_data32r(rt_uint8_t *buf, rt_int16_t len) { - rt_int16_t c,crc_cnt = 0; + rt_int16_t c,crc_cnt; rt_uint32_t crc; rt_err_t res = -RT_ERROR; rt_uint8_t *p,flag = 0; - crc = 0xffffffffL; + crc_cnt = 0; crc = 0xffffffffL; Rxcount = 0; p = buf; while (buf <= p+len) @@ -640,7 +636,8 @@ static rt_int16_t zget_bin_fcs(rt_uint8_t *hdr) if ((res = zread_byte()) & ~0377) return res; header_type = res; - crc = 0xFFFFFFFFL; crc = updcrc32(res, crc); + crc = 0xFFFFFFFFL; + crc = updcrc32(res, crc); for (i=0;i<4;i++) /* 4headers */ { @@ -859,8 +856,8 @@ rt_int16_t zxor_read(void) default: return res; } - } - /* NOTREACHED */ + } + } /* put file posistion into the header*/ diff --git a/components/utilities/zmodem/zdevice.c b/components/utilities/zmodem/zdevice.c index 794f01cae..6bf57d3b9 100644 --- a/components/utilities/zmodem/zdevice.c +++ b/components/utilities/zmodem/zdevice.c @@ -34,7 +34,7 @@ rt_uint32_t get_sys_time(void) void zsend_byte(rt_uint16_t ch) { - rt_device_write(zmodem.device,0,&ch,1); + rt_device_write(zmodem.device, 0, &ch,1); return; } @@ -44,7 +44,7 @@ void zsend_line(rt_uint16_t c) rt_uint16_t ch; ch = (c & 0377); - rt_device_write(zmodem.device,0,&ch,1); + rt_device_write(zmodem.device, 0, &ch, 1); return; }