Skip to contentSkip to conversation

do not use linux/string.h in sha1.c on hosts

PATCH New Mike Frysinger 4 participants 10 messages Dec 24, 2007 – Jan 9, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 do not use linux/string.h in sha1.c on hosts

linux/string.h is not a valid include outside of the kernel, so when compiling sha1.c for the host (for use with the mkimage host binary), the include needs to be changed to string.h.

---

lib_generic/sha1.c +4 -0
index 08ffa6b..d04cba7 100644
@@ -29,7 +29,11 @@
 #define _CRT_SECURE_NO_DEPRECATE 1
 #endif
 
+#ifndef USE_HOSTCC
 #include <linux/string.h>
+#else
+#include <string.h>
+#endif
 #include "sha1.h"
 
 /*
tools/easylogo/Makefile +8 -2
index 292344a..566b125 100644
@@ -1,2 +1,8 @@
-all:	easylogo.c
-	gcc easylogo.c -o easylogo
+CFLAGS += -Wall
+
+all: easylogo
+
+clean:
+	rm -f easylogo *.o
+
+.PHONY: all clean
tools/easylogo/easylogo.c +30 -5
index 9f1d1ff..c69f012 100644
@@ -8,6 +8,8 @@
 */
 
 #include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 
 #pragma pack(1)
 
@@ -41,7 +43,7 @@ typedef struct {
 } yuyv_t ;
 
 typedef struct {
-	unsigned char	*data,
+	void				*data,
 					*palette ;
 	int				width,
 					height,
@@ -125,6 +127,16 @@ void printlogo_yuyv (unsigned short *data, int w, int h)
     }
 }
 
+static inline unsigned short le16_to_cpu (unsigned short val)
+{
+    union {
+	unsigned char pval[2];
+	unsigned short val;
+    } swapped;
+    swapped.val = val;
+    return (swapped.pval[1] << 8) + swapped.pval[0];
+}
+
 int image_load_tga (image_t *image, char *filename)
 {
     FILE *file ;
@@ -138,6 +150,14 @@ int image_load_tga (image_t *image, char *filename)
 
     fread(&header, sizeof(header), 1, file);
 
+    /* byte swap: tga is little endian, host is ??? */
+    header.ColorMapOrigin = le16_to_cpu (header.ColorMapOrigin);
+    header.ColorMapLenght = le16_to_cpu (header.ColorMapLenght);
+    header.ImageXOrigin = le16_to_cpu (header.ImageXOrigin);
+    header.ImageYOrigin = le16_to_cpu (header.ImageYOrigin);
+    header.ImageWidth = le16_to_cpu (header.ImageWidth);
+    header.ImageHeight = le16_to_cpu (header.ImageHeight);
+
     image->width 	= header.ImageWidth ;
     image->height 	= header.ImageHeight ;
 
@@ -352,9 +372,10 @@ int main (int argc, char *argv[])
 	    strcpy (varname, 	argv[2]);
 	else
 	{
-	    int pos = strchr(inputfile, '.');
+	    char *dot = strchr(inputfile, '.');
+	    int pos = dot - inputfile;
 
-	    if (pos >= 0)
+	    if (dot)
 	    {
 		strncpy (varname, inputfile, pos);
 		varname[pos] = 0 ;
@@ -365,13 +386,15 @@ int main (int argc, char *argv[])
 	    strcpy (outputfile, argv[3]);
 	else
 	{
-	    int pos = strchr (varname, '.');
+	    char *dot = strchr (varname, '.');
+	    int pos = dot - varname;
 
-	    if (pos > 0)
+	    if (dot)
 	    {
 		char app[DEF_FILELEN] ;
 
 		strncpy(app, varname, pos);
+		app[pos] = 0;
 		sprintf(outputfile, "%s.h", app);
 	    }
 	}
@@ -389,6 +412,8 @@ int main (int argc, char *argv[])
 	return -1 ;
     }
 
+    setbuf(stdout, NULL);
+
     printf("Doing '%s' (%s) from '%s'...",
 	outputfile, varname, inputfile);
 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20071224/afa3f5dd/attachment.pgp

#1 lore raw

PATCH 1/1 do not use linux/string.h in sha1.c on hosts

tools/easylogo/easylogo.c

Quoted 2 lines · Mike Frysinger
tools/easylogo/Makefile +0 -0
tools/easylogo/easylogo.c +0 -0

blah, i thought i'd cut the patch before i appended, but that appears to not be the case. ignore all the hunks other than sha1.c as they've already been posted to the list.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20071224/3a750c3b/attachment.pgp

#2 lore raw

PATCH 1/1 do not use linux/string.h in sha1.c on hosts

In reply to Mike Frysinger
Quoted 4 lines · In message <[email protected]> you wrote:

linux/string.h is not a valid include outside of the kernel, so when compiling sha1.c for the host (for use with the mkimage host binary), the include needs to be changed to string.h.

But IIRC mkimage does not use any sha1 code ...

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Single tasking: Just Say No.
#3 lore raw

PATCH 1/1 do not use linux/string.h in sha1.c on hosts

Quoted 6 lines · Wolfgang Denk
Quoted 3 lines · In message <[email protected]> you wrote:

linux/string.h is not a valid include outside of the kernel, so when compiling sha1.c for the host (for use with the mkimage host binary), the include needs to be changed to string.h.

But IIRC mkimage does not use any sha1 code ...

the Makefile claims otherwise ... patch attached to remove sha1.o from mkimage linking since it isnt actually used.

---

tools/Makefile +1 -1
index e8e0280..0432253 100644
@@ -136,7 +136,7 @@ $(obj)img2srec$(SFX):	$(obj)img2srec.o
 		$(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
 		$(STRIP) $@
 
-$(obj)mkimage$(SFX):	$(obj)mkimage.o $(obj)crc32.o $(obj)sha1.o
+$(obj)mkimage$(SFX):	$(obj)mkimage.o $(obj)crc32.o
 		$(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
 		$(STRIP) $@
 
#4 lore raw

PATCH 1/1 do not use linux/string.h in sha1.c on hosts

Quoted 9 lines · Mike Frysinger
Quoted 5 lines · Wolfgang Denk
Quoted 3 lines · In message <[email protected]> you wrote:

linux/string.h is not a valid include outside of the kernel, so when compiling sha1.c for the host (for use with the mkimage host binary), the include needs to be changed to string.h.

But IIRC mkimage does not use any sha1 code ...

the Makefile claims otherwise ... patch attached to remove sha1.o from mkimage linking since it isnt actually used.

It is likely we'll need sha1 support in mkimage for the new uImage format. Let's wait with this patch until mkimage extension to the new uImage format is settled down.

Regards,
Bartlomiej

#5 lore raw

PATCH 1/1 do not use linux/string.h in sha1.c on hosts

Quoted 5 lines · In message <[email protected]> you wrote:
Quoted 5 lines
Quoted 2 lines

But IIRC mkimage does not use any sha1 code ...

the Makefile claims otherwise ... patch attached to remove sha1.o from mkimage linking since it isnt actually used.

Indeed the Makefile contained a not needed reference.

Quoted 3 lines

It is likely we'll need sha1 support in mkimage for the new uImage format. Let's wait with this patch until mkimage extension to the new uImage format is settled down.

I'm not so sure. Maybe it's better to clean up now, and deal with the new image format requirements when we're at it. Please note that the mkimage code has recenty been added to the Linux kernel tree, and there the sha1 reference was also removed. I think it makes sense to keep both in sync...

Best regards,

Wolfgang Denk

Signature · 7 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Do you know about being with somebody? Wanting to be? If  I  had  the
whole  universe,  I'd  give it to you, Janice. When I see you, I feel
like I'm hungry all over. Do you know how that feels?
	-- Charlie Evans, "Charlie X", stardate 1535.8
#6 lore raw

PATCH 1/1 do not use linux/string.h in sha1.c on hosts

Quoted 11 lines · Wolfgang Denk
Quoted 3 lines · In message <[email protected]> you wrote:
Quoted 3 lines
Quoted 1 line

But IIRC mkimage does not use any sha1 code ...

the Makefile claims otherwise ... patch attached to remove sha1.o from mkimage linking since it isnt actually used.

Indeed the Makefile contained a not needed reference.

Quoted 3 lines

It is likely we'll need sha1 support in mkimage for the new uImage format. Let's wait with this patch until mkimage extension to the new uImage format is settled down.

Quoted 5 lines

I'm not so sure. Maybe it's better to clean up now, and deal with the new image format requirements when we're at it. Please note that the mkimage code has recenty been added to the Linux kernel tree, and there the sha1 reference was also removed. I think it makes sense to keep both in sync...

I think it makes sense, too.

I am fine with having the clean-up now, and adding sha1 later on when needed.

Regards,
Barlomiej

#7 lore raw

PATCH 1/1 do not use linux/string.h in sha1.c on hosts

In reply to Wolfgang Denk
Quoted 13 lines · On Thu, 27 Dec 2007 21:15:16 +0100 Wolfgang Denk <[email protected]> wrote:
Quoted 5 lines · In message <[email protected]> you wrote:
Quoted 5 lines
Quoted 2 lines

But IIRC mkimage does not use any sha1 code ...

the Makefile claims otherwise ... patch attached to remove sha1.o from mkimage linking since it isnt actually used.

Indeed the Makefile contained a not needed reference.

Quoted 3 lines

It is likely we'll need sha1 support in mkimage for the new uImage format. Let's wait with this patch until mkimage extension to the new uImage format is settled down.

Quoted 5 lines

I'm not so sure. Maybe it's better to clean up now, and deal with the new image format requirements when we're at it. Please note that the mkimage code has recenty been added to the Linux kernel tree, and there the sha1 reference was also removed. I think it makes sense to keep both in sync...

Actually, it hasn't been added yet. I've only sent out one round of patches so far. And those included the sha1.c code because of the exact same reason. I wanted to keep them in sync :)

josh

#8 lore raw

PATCH 1/1 do not use linux/string.h in sha1.c on hosts

In reply to Bartlomiej Sieka
Quoted 7 lines · Bartlomiej Sieka
Quoted 6 lines · Mike Frysinger
Quoted 5 lines · Wolfgang Denk
Quoted 3 lines · In message <[email protected]> you wrote:

linux/string.h is not a valid include outside of the kernel, so when compiling sha1.c for the host (for use with the mkimage host binary), the include needs to be changed to string.h.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

But IIRC mkimage does not use any sha1 code ...

the Makefile claims otherwise ... patch attached to remove sha1.o from mkimage linking since it isnt actually used.

It is likely we'll need sha1 support in mkimage for the new uImage format. Let's wait with this patch until mkimage extension to the new uImage format is settled down.

pick one ... fix sha1.c or dont link it in. doesnt matter to me.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20071227/f9b39eb8/attachment.pgp

#9 lore raw

PATCH 1/1 do not use linux/string.h in sha1.c on hosts

In reply to Mike Frysinger
Quoted 6 lines · In message <[email protected]> you wrote:
Quoted 5 lines · Wolfgang Denk
Quoted 3 lines · In message <[email protected]> you wrote:

linux/string.h is not a valid include outside of the kernel, so when compiling sha1.c for the host (for use with the mkimage host binary), the include needs to be changed to string.h.

Quoted 6 lines
Quoted 1 line

But IIRC mkimage does not use any sha1 code ...

the Makefile claims otherwise ... patch attached to remove sha1.o from mkimage linking since it isnt actually used.

Applied. Thanks.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
When you die, the first thing you lose is your life. The  next  thing
is the illusions.                       - Terry Pratchett, _Pyramids_