* mtd-utils: fec.c uses bcopy() @ 2008-10-08 0:27 Mitch Davis 2008-10-08 1:02 ` Mike Frysinger 0 siblings, 1 reply; 10+ messages in thread From: Mitch Davis @ 2008-10-08 0:27 UTC (permalink / raw) To: linux-mtd Hello, I use buildroot to build my embedded Linux. My run-time library is uClibc, which doesn't provide bcopy(). fec.c in mtd-utils uses bcopy(), so mtd-utils doesn't compile for me. I'd like to fix this. - Should I rewrite fec.c so it uses memcpy instead? - Should I just add #define NEED_BCOPY to fec.c? - Should I leave fec.c unchanged and add -DNEED_BCOPY to the Makefile (which would be passed to every compile?) http://git.infradead.org/mtd-utils.git?a=blob_plain;f=fec.c Which solution would you guys accept? Thanks, Mitch. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: mtd-utils: fec.c uses bcopy() 2008-10-08 0:27 mtd-utils: fec.c uses bcopy() Mitch Davis @ 2008-10-08 1:02 ` Mike Frysinger 2008-10-08 2:36 ` Mitch Davis 0 siblings, 1 reply; 10+ messages in thread From: Mike Frysinger @ 2008-10-08 1:02 UTC (permalink / raw) To: Mitch Davis; +Cc: linux-mtd On Tue, Oct 7, 2008 at 20:27, Mitch Davis wrote: > I use buildroot to build my embedded Linux. My run-time library is > uClibc, which doesn't provide bcopy(). actually it does. you just disabled support for it. > fec.c in mtd-utils uses bcopy(), so mtd-utils doesn't compile for me. > I'd like to fix this. > > - Should I rewrite fec.c so it uses memcpy instead? > - Should I just add #define NEED_BCOPY to fec.c? > - Should I leave fec.c unchanged and add -DNEED_BCOPY to the Makefile > (which would be passed to every compile?) a simple sed can fix the code as the only difference between bcopy() and memcpy() is the argument order. ifdef's are pointless/ugly in this case. -mike ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: mtd-utils: fec.c uses bcopy() 2008-10-08 1:02 ` Mike Frysinger @ 2008-10-08 2:36 ` Mitch Davis 2008-10-08 2:38 ` Mike Frysinger 0 siblings, 1 reply; 10+ messages in thread From: Mitch Davis @ 2008-10-08 2:36 UTC (permalink / raw) To: Mike Frysinger; +Cc: linux-mtd [-- Attachment #1: Type: text/plain, Size: 786 bytes --] On Wed, Oct 8, 2008 at 12:02 PM, Mike Frysinger <vapier.adi@gmail.com> wrote: > On Tue, Oct 7, 2008 at 20:27, Mitch Davis wrote: > >> fec.c in mtd-utils uses bcopy(), so mtd-utils doesn't compile for me. >> I'd like to fix this. >> >> - Should I rewrite fec.c so it uses memcpy instead? >> - Should I just add #define NEED_BCOPY to fec.c? >> - Should I leave fec.c unchanged and add -DNEED_BCOPY to the Makefile >> (which would be passed to every compile?) > > a simple sed can fix the code as the only difference between bcopy() > and memcpy() is the argument order. ifdef's are pointless/ugly in > this case. I agree. I've attached a diff that makes this change. It compiles with no warnings, but I have no way of testing it. Any suggestions what to do next? Thanks, Mitch. [-- Attachment #2: fec.diff --] [-- Type: application/octet-stream, Size: 3975 bytes --] [PATCH] [MTD] mtd-utils: fec.c: bzero->memset, bcopy->memcpy, bcmp->memcmp This patch alters fec.c so it does not use the deprecated bzero, bcopy and bcmp functions. This can help on platforms that do not have these functions. From: Mitch Davis <mitch.davis@symstream.com> Signed-off-by: Mitch Davis <mitch.davis@symstream.com> diff --git a/fec.c b/fec.c index 09e8453..6d9020f 100644 --- a/fec.c +++ b/fec.c @@ -47,19 +47,6 @@ #include <string.h> /* - * compatibility stuff - */ -#ifdef MSDOS /* but also for others, e.g. sun... */ -#define NEED_BCOPY -#define bcmp(a,b,n) memcmp(a,b,n) -#endif - -#ifdef NEED_BCOPY -#define bcopy(s, d, siz) memcpy((d), (s), (siz)) -#define bzero(d, siz) memset((d), '\0', (siz)) -#endif - -/* * stuff used for testing purposes only */ @@ -433,7 +420,7 @@ invert_mat(gf *src, int k) gf *id_row = NEW_GF_MATRIX(1, k); gf *temp_row = NEW_GF_MATRIX(1, k); - bzero(id_row, k*sizeof(gf)); + memset(id_row, '\0', k*sizeof(gf)); DEB( pivloops=0; pivswaps=0 ; /* diagnostic */ ) /* * ipiv marks elements already used as pivots. @@ -513,7 +500,7 @@ found_piv: * we can optimize the addmul). */ id_row[icol] = 1; - if (bcmp(pivot_row, id_row, k*sizeof(gf)) != 0) { + if (memcmp(pivot_row, id_row, k*sizeof(gf)) != 0) { for (p = src, ix = 0 ; ix < k ; ix++, p += k ) { if (ix != icol) { c = p[icol] ; @@ -704,7 +691,7 @@ fec_new(int k, int n) /* * the upper matrix is I so do not bother with a slow multiply */ - bzero(retval->enc_matrix, k*k*sizeof(gf) ); + memset(retval->enc_matrix, '\0', k*k*sizeof(gf) ); for (p = retval->enc_matrix, col = 0 ; col < k ; col++, p += k+1 ) *p = 1 ; free(tmp_m); @@ -731,10 +718,10 @@ fec_encode(struct fec_parms *code, gf *src[], gf *fec, int index, int sz) sz /= 2 ; if (index < k) - bcopy(src[index], fec, sz*sizeof(gf) ) ; + memcpy(fec, src[index], sz*sizeof(gf) ) ; else if (index < code->n) { p = &(code->enc_matrix[index*k] ); - bzero(fec, sz*sizeof(gf)); + memset(fec, '\0', sz*sizeof(gf)); for (i = 0; i < k ; i++) addmul(fec, src[i], p[i], sz ) ; } else @@ -751,10 +738,10 @@ void fec_encode_linear(struct fec_parms *code, gf *src, gf *fec, int index, int sz /= 2 ; if (index < k) - bcopy(src + (index * sz), fec, sz*sizeof(gf) ) ; + memcpy(fec, src + (index * sz), sz*sizeof(gf) ) ; else if (index < code->n) { p = &(code->enc_matrix[index*k] ); - bzero(fec, sz*sizeof(gf)); + memset(fec, '\0', sz*sizeof(gf)); for (i = 0; i < k ; i++) addmul(fec, src + (i * sz), p[i], sz ) ; } else @@ -814,12 +801,12 @@ build_decode_matrix(struct fec_parms *code, gf *pkt[], int index[]) for (i = 0, p = matrix ; i < k ; i++, p += k ) { #if 1 /* this is simply an optimization, not very useful indeed */ if (index[i] < k) { - bzero(p, k*sizeof(gf) ); + memset(p, '\0', k*sizeof(gf) ); p[i] = 1 ; } else #endif if (index[i] < code->n ) - bcopy( &(code->enc_matrix[index[i]*k]), p, k*sizeof(gf) ); + memcpy(p, &(code->enc_matrix[index[i]*k]), k*sizeof(gf) ); else { fprintf(stderr, "decode: invalid index %d (max %d)\n", index[i], code->n - 1 ); @@ -870,7 +857,7 @@ fec_decode(struct fec_parms *code, gf *pkt[], int index[], int sz) for (row = 0 ; row < k ; row++ ) { if (index[row] >= k) { new_pkt[row] = my_malloc (sz * sizeof (gf), "new pkt buffer" ); - bzero(new_pkt[row], sz * sizeof(gf) ) ; + memset(new_pkt[row], '\0', sz * sizeof(gf) ) ; for (col = 0 ; col < k ; col++ ) addmul(new_pkt[row], pkt[col], m_dec[row*k + col], sz) ; } @@ -880,7 +867,7 @@ fec_decode(struct fec_parms *code, gf *pkt[], int index[], int sz) */ for (row = 0 ; row < k ; row++ ) { if (index[row] >= k) { - bcopy(new_pkt[row], pkt[row], sz*sizeof(gf)); + memcpy(pkt[row], new_pkt[row], sz*sizeof(gf)); free(new_pkt[row]); } } ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: mtd-utils: fec.c uses bcopy() 2008-10-08 2:36 ` Mitch Davis @ 2008-10-08 2:38 ` Mike Frysinger 2008-10-08 4:56 ` Mitch Davis 0 siblings, 1 reply; 10+ messages in thread From: Mike Frysinger @ 2008-10-08 2:38 UTC (permalink / raw) To: Mitch Davis; +Cc: linux-mtd On Tue, Oct 7, 2008 at 22:36, Mitch Davis wrote: > On Wed, Oct 8, 2008 at 12:02 PM, Mike Frysinger wrote: >> On Tue, Oct 7, 2008 at 20:27, Mitch Davis wrote: >>> fec.c in mtd-utils uses bcopy(), so mtd-utils doesn't compile for me. >>> I'd like to fix this. >>> >>> - Should I rewrite fec.c so it uses memcpy instead? >>> - Should I just add #define NEED_BCOPY to fec.c? >>> - Should I leave fec.c unchanged and add -DNEED_BCOPY to the Makefile >>> (which would be passed to every compile?) >> >> a simple sed can fix the code as the only difference between bcopy() >> and memcpy() is the argument order. ifdef's are pointless/ugly in >> this case. > > I agree. I've attached a diff that makes this change. > > It compiles with no warnings, but I have no way of testing it. Any > suggestions what to do next? use `git diff` to generate a diff instead of posting the entire file as an attachment. really you should use git to send the patch, but if that's too much for you, just post the diff. -mike ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: mtd-utils: fec.c uses bcopy() 2008-10-08 2:38 ` Mike Frysinger @ 2008-10-08 4:56 ` Mitch Davis 2008-10-08 5:07 ` Mike Frysinger 0 siblings, 1 reply; 10+ messages in thread From: Mitch Davis @ 2008-10-08 4:56 UTC (permalink / raw) To: Mike Frysinger; +Cc: linux-mtd Hi Mike, On Wed, Oct 8, 2008 at 1:38 PM, Mike Frysinger <vapier.adi@gmail.com> wrote: > On Tue, Oct 7, 2008 at 22:36, Mitch Davis wrote: >> On Wed, Oct 8, 2008 at 12:02 PM, Mike Frysinger wrote: >>> On Tue, Oct 7, 2008 at 20:27, Mitch Davis wrote: >>>> fec.c in mtd-utils uses bcopy(), so mtd-utils doesn't compile for me. >>>> I'd like to fix this. >>>> >>>> - Should I rewrite fec.c so it uses memcpy instead? >>> >>> a simple sed can fix the code as the only difference between bcopy() >>> and memcpy() is the argument order. ifdef's are pointless/ugly in >>> this case. >> >> I agree. I've attached a diff that makes this change. >> >> It compiles with no warnings, but I have no way of testing it. Any >> suggestions what to do next? > > use `git diff` to generate a diff instead of posting the entire file > as an attachment. The diff I attached previously was generated by git diff from HEAD. It was not the entire file. > really you should use git to send the patch Do you mean a git push? I'd need an account for that on infradead, no? A pointer to some instructions would be great. Note, two of the three links to informative articles on the MTD GIT HOWTO page are broken. If you don't mean a git push, please tell me what you mean. Hmm, I hope the following inline pasting doesn't break tabs, etc. Thanks for your help, Mitch. [PATCH] [MTD] mtd-utils: fec.c: bzero->memset, bcopy->memcpy, bcmp->memcmp This patch alters fec.c so it does not use the deprecated bzero, bcopy and bcmp functions. This can help on platforms that do not have these functions. From: Mitch Davis <mitch.davis@symstream.com> Signed-off-by: Mitch Davis <mitch.davis@symstream.com> diff --git a/fec.c b/fec.c index 09e8453..6d9020f 100644 --- a/fec.c +++ b/fec.c @@ -47,19 +47,6 @@ #include <string.h> /* - * compatibility stuff - */ -#ifdef MSDOS /* but also for others, e.g. sun... */ -#define NEED_BCOPY -#define bcmp(a,b,n) memcmp(a,b,n) -#endif - -#ifdef NEED_BCOPY -#define bcopy(s, d, siz) memcpy((d), (s), (siz)) -#define bzero(d, siz) memset((d), '\0', (siz)) -#endif - -/* * stuff used for testing purposes only */ @@ -433,7 +420,7 @@ invert_mat(gf *src, int k) gf *id_row = NEW_GF_MATRIX(1, k); gf *temp_row = NEW_GF_MATRIX(1, k); - bzero(id_row, k*sizeof(gf)); + memset(id_row, '\0', k*sizeof(gf)); DEB( pivloops=0; pivswaps=0 ; /* diagnostic */ ) /* * ipiv marks elements already used as pivots. @@ -513,7 +500,7 @@ found_piv: * we can optimize the addmul). */ id_row[icol] = 1; - if (bcmp(pivot_row, id_row, k*sizeof(gf)) != 0) { + if (memcmp(pivot_row, id_row, k*sizeof(gf)) != 0) { for (p = src, ix = 0 ; ix < k ; ix++, p += k ) { if (ix != icol) { c = p[icol] ; @@ -704,7 +691,7 @@ fec_new(int k, int n) /* * the upper matrix is I so do not bother with a slow multiply */ - bzero(retval->enc_matrix, k*k*sizeof(gf) ); + memset(retval->enc_matrix, '\0', k*k*sizeof(gf) ); for (p = retval->enc_matrix, col = 0 ; col < k ; col++, p += k+1 ) *p = 1 ; free(tmp_m); @@ -731,10 +718,10 @@ fec_encode(struct fec_parms *code, gf *src[], gf *fec, int index, int sz) sz /= 2 ; if (index < k) - bcopy(src[index], fec, sz*sizeof(gf) ) ; + memcpy(fec, src[index], sz*sizeof(gf) ) ; else if (index < code->n) { p = &(code->enc_matrix[index*k] ); - bzero(fec, sz*sizeof(gf)); + memset(fec, '\0', sz*sizeof(gf)); for (i = 0; i < k ; i++) addmul(fec, src[i], p[i], sz ) ; } else @@ -751,10 +738,10 @@ void fec_encode_linear(struct fec_parms *code, gf *src, gf *fec, int index, int sz /= 2 ; if (index < k) - bcopy(src + (index * sz), fec, sz*sizeof(gf) ) ; + memcpy(fec, src + (index * sz), sz*sizeof(gf) ) ; else if (index < code->n) { p = &(code->enc_matrix[index*k] ); - bzero(fec, sz*sizeof(gf)); + memset(fec, '\0', sz*sizeof(gf)); for (i = 0; i < k ; i++) addmul(fec, src + (i * sz), p[i], sz ) ; } else @@ -814,12 +801,12 @@ build_decode_matrix(struct fec_parms *code, gf *pkt[], int index[]) for (i = 0, p = matrix ; i < k ; i++, p += k ) { #if 1 /* this is simply an optimization, not very useful indeed */ if (index[i] < k) { - bzero(p, k*sizeof(gf) ); + memset(p, '\0', k*sizeof(gf) ); p[i] = 1 ; } else #endif if (index[i] < code->n ) - bcopy( &(code->enc_matrix[index[i]*k]), p, k*sizeof(gf) ); + memcpy(p, &(code->enc_matrix[index[i]*k]), k*sizeof(gf) ); else { fprintf(stderr, "decode: invalid index %d (max %d)\n", index[i], code->n - 1 ); @@ -870,7 +857,7 @@ fec_decode(struct fec_parms *code, gf *pkt[], int index[], int sz) for (row = 0 ; row < k ; row++ ) { if (index[row] >= k) { new_pkt[row] = my_malloc (sz * sizeof (gf), "new pkt buffer" ); - bzero(new_pkt[row], sz * sizeof(gf) ) ; + memset(new_pkt[row], '\0', sz * sizeof(gf) ) ; for (col = 0 ; col < k ; col++ ) addmul(new_pkt[row], pkt[col], m_dec[row*k + col], sz) ; } @@ -880,7 +867,7 @@ fec_decode(struct fec_parms *code, gf *pkt[], int index[], int sz) */ for (row = 0 ; row < k ; row++ ) { if (index[row] >= k) { - bcopy(new_pkt[row], pkt[row], sz*sizeof(gf)); + memcpy(pkt[row], new_pkt[row], sz*sizeof(gf)); free(new_pkt[row]); } } ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: mtd-utils: fec.c uses bcopy() 2008-10-08 4:56 ` Mitch Davis @ 2008-10-08 5:07 ` Mike Frysinger 2008-10-08 6:06 ` Mitch Davis 0 siblings, 1 reply; 10+ messages in thread From: Mike Frysinger @ 2008-10-08 5:07 UTC (permalink / raw) To: Mitch Davis; +Cc: linux-mtd On Wed, Oct 8, 2008 at 00:56, Mitch Davis wrote: > On Wed, Oct 8, 2008 at 1:38 PM, Mike Frysinger wrote: >> use `git diff` to generate a diff instead of posting the entire file >> as an attachment. > > The diff I attached previously was generated by git diff from HEAD. > It was not the entire file. sorry, my mistake >> really you should use git to send the patch > > Do you mean a git push? no. use the send-email function. read `man git-send-email` for more info. -mike ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: mtd-utils: fec.c uses bcopy() 2008-10-08 5:07 ` Mike Frysinger @ 2008-10-08 6:06 ` Mitch Davis 2008-10-08 6:08 ` Artem Bityutskiy ` (2 more replies) 0 siblings, 3 replies; 10+ messages in thread From: Mitch Davis @ 2008-10-08 6:06 UTC (permalink / raw) To: Mike Frysinger; +Cc: linux-mtd Hi Mike, On Wed, Oct 8, 2008 at 4:07 PM, Mike Frysinger <vapier.adi@gmail.com> wrote: > On Wed, Oct 8, 2008 at 00:56, Mitch Davis wrote: >> On Wed, Oct 8, 2008 at 1:38 PM, Mike Frysinger wrote: >>> use `git diff` to generate a diff instead of posting the entire file >>> as an attachment. >> > sorry, my mistake > >>> really you should use git to send the patch >> >> Do you mean a git push? > > no. use the send-email function. read `man git-send-email` for more info. - Who is best told about the broken git info links on the MTD git web page? - This process of submitting stuff with git-send-email is not documented on the MTD page, but newbies should use it anyway. Can I suggest the howto on the MTD page be updated to avoid people like me getting it wrong? - On my machine (Fedora 9) git-send-email is part of the git-email package, not standard git. Others may benefit from knowing this if it's part of that updated page. And finally: - I've sent my diff twice already. Can you have a look at it and comment please? :-) Thanks heaps, Mitch. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: mtd-utils: fec.c uses bcopy() 2008-10-08 6:06 ` Mitch Davis @ 2008-10-08 6:08 ` Artem Bityutskiy 2008-10-08 6:23 ` Mike Frysinger 2008-10-08 12:43 ` Josh Boyer 2 siblings, 0 replies; 10+ messages in thread From: Artem Bityutskiy @ 2008-10-08 6:08 UTC (permalink / raw) To: Mitch Davis; +Cc: linux-mtd, Mike Frysinger On Wed, 2008-10-08 at 17:06 +1100, Mitch Davis wrote: > Hi Mike, > > On Wed, Oct 8, 2008 at 4:07 PM, Mike Frysinger <vapier.adi@gmail.com> wrote: > > On Wed, Oct 8, 2008 at 00:56, Mitch Davis wrote: > >> On Wed, Oct 8, 2008 at 1:38 PM, Mike Frysinger wrote: > >>> use `git diff` to generate a diff instead of posting the entire file > >>> as an attachment. > >> > > sorry, my mistake > > > >>> really you should use git to send the patch > >> > >> Do you mean a git push? > > > > no. use the send-email function. read `man git-send-email` for more info. > > - Who is best told about the broken git info links on the MTD git web page? > > - This process of submitting stuff with git-send-email is not > documented on the MTD page, but newbies should use it anyway. Can I > suggest the howto on the MTD page be updated to avoid people like me > getting it wrong? > - On my machine (Fedora 9) git-send-email is part of the git-email > package, not standard git. Others may benefit from knowing this if > it's part of that updated page. MTD web site source may be found at: git://git.infradead.org/mtd-www.git Please, feel free to add such a HOWTO and send a patch. -- Best regards, Artem Bityutskiy (Битюцкий Артём) ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: mtd-utils: fec.c uses bcopy() 2008-10-08 6:06 ` Mitch Davis 2008-10-08 6:08 ` Artem Bityutskiy @ 2008-10-08 6:23 ` Mike Frysinger 2008-10-08 12:43 ` Josh Boyer 2 siblings, 0 replies; 10+ messages in thread From: Mike Frysinger @ 2008-10-08 6:23 UTC (permalink / raw) To: Mitch Davis; +Cc: linux-mtd On Wed, Oct 8, 2008 at 02:06, Mitch Davis wrote: > On Wed, Oct 8, 2008 at 4:07 PM, Mike Frysinger wrote: >> On Wed, Oct 8, 2008 at 00:56, Mitch Davis wrote: >>> On Wed, Oct 8, 2008 at 1:38 PM, Mike Frysinger wrote: >>>> really you should use git to send the patch >>> >>> Do you mean a git push? >> >> no. use the send-email function. read `man git-send-email` for more info. > > - This process of submitting stuff with git-send-email is not > documented on the MTD page, but newbies should use it anyway. Can I > suggest the howto on the MTD page be updated to avoid people like me > getting it wrong? > - On my machine (Fedora 9) git-send-email is part of the git-email > package, not standard git. Others may benefit from knowing this if > it's part of that updated page. it's the same method as any git repo. there isnt anything specific for the MTD project other than the e-mail address you send it to. if you want to know about git and how to use it, you should go to the git homepage: http://git.or.cz/ > - I've sent my diff twice already. Can you have a look at it and > comment please? :-) i have no commit access, but i already gave the patch a quick eye over and it looked fine to me. the b* suite of memory functions have long been deprecated in favor of the mem* functions. -mike ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: mtd-utils: fec.c uses bcopy() 2008-10-08 6:06 ` Mitch Davis 2008-10-08 6:08 ` Artem Bityutskiy 2008-10-08 6:23 ` Mike Frysinger @ 2008-10-08 12:43 ` Josh Boyer 2 siblings, 0 replies; 10+ messages in thread From: Josh Boyer @ 2008-10-08 12:43 UTC (permalink / raw) To: Mitch Davis; +Cc: linux-mtd, Mike Frysinger On Wed, Oct 08, 2008 at 05:06:07PM +1100, Mitch Davis wrote: > - I've sent my diff twice already. Can you have a look at it and >comment please? :-) Why do you use '\0' for the memcpy operand instead of just plain 0 or 0x0? josh ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2008-10-08 12:44 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2008-10-08 0:27 mtd-utils: fec.c uses bcopy() Mitch Davis 2008-10-08 1:02 ` Mike Frysinger 2008-10-08 2:36 ` Mitch Davis 2008-10-08 2:38 ` Mike Frysinger 2008-10-08 4:56 ` Mitch Davis 2008-10-08 5:07 ` Mike Frysinger 2008-10-08 6:06 ` Mitch Davis 2008-10-08 6:08 ` Artem Bityutskiy 2008-10-08 6:23 ` Mike Frysinger 2008-10-08 12:43 ` Josh Boyer
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox