Hi,
sorry about missing bug number (22871). Current implementation has a bug
that writes extra error line when there is no need for it. Bug
correction does not allow false information it simply trims spaces and
EOL characters from given line(s) (compare to boardname script
implementation and trimming there).
-Jouni
07.09.2011 04:49, Kok, Auke-jan H kirjoitti:
where is the bug that this fixes?
I realize that it's nice to make this code a bit more robust, but
allowing false information to pass through without errors won't help
us in the long run - in the end, /etc/boardname needs to be a file
with a single line, and boardname should return an error code and just
give up.
Auke
On Tue, Sep 6, 2011 at 9:15 PM, Jouni Peltonen<[email protected]> wrote:
Hi,
I have made the following changes to boardname in project devel:resourcepolicy.
Please review and accept ASAP.
Thank You,
Jouni Peltonen
[This message was auto-generated]
---
Request #23795:
submit:
home:jouni.peltonen:branches:devel:resourcepolicy/boardname(r19)(cleanup) ->
devel:resourcepolicy/boardname
Message:
* Mon Sep 6 2011 Jouni Peltonen<[email protected]> - 0.7
- Corrected boardname fileread to handle extra lines.
State: new 2011-09-06T05:07:45 jouni.peltonen
Comment: None
changes files:
--------------
--- boardname.changes
+++ boardname.changes
@@ -0,0 +1,3 @@
+* Mon Sep 6 2011 Jouni Peltonen<[email protected]> - 0.7
+- Corrected boardname fileread to handle extra lines.
+
new:
----
boardname_read.patch
spec files:
-----------
--- boardname.spec
+++ boardname.spec
@@ -15,6 +15,7 @@
Source0: boardname-%{version}.tar.gz
Source1: boardname.service
Source100: boardname.yaml
+Patch0: boardname_read.patch
Requires: coreutils
Requires: grep
Requires(post): /sbin/ldconfig
@@ -43,6 +44,8 @@
%prep
%setup -q -n %{name}-%{version}
+# boardname_read.patch
+%patch0 -p1
#>> setup
#<< setup
other changes:
--------------
++++++ boardname.yaml
--- boardname.yaml
+++ boardname.yaml
@@ -12,7 +12,8 @@
Sources :
- boardname-%{version}.tar.gz
- boardname.service
-
+Patches:
+ - boardname_read.patch
Configure: none
Builder: make
License: GPLv2
++++++ boardname_read.patch (new)
--- boardname_read.patch
+++ boardname_read.patch
+--- a/boardname.c
++++ b/boardname.c
+@@ -10,14 +10,17 @@
+ * of the License.
+ */
+
+-#include "stdio.h"
+-#include "stdlib.h"
++#include<stdio.h>
++#include<stdlib.h>
++#include<string.h>
++#include<ctype.h>
+
+ #define MAXSTRING 256
+
+ char* getboardname()
+ {
+ char *buffer;
++ int buflen;
+ FILE *fd;
+
+ fd = fopen("/etc/boardname", "r");
+@@ -28,11 +31,24 @@
+ }
+
+ buffer = malloc(MAXSTRING);
+- while (!feof(fd))
+- if (fgets(buffer, MAXSTRING, fd)<= 0)
+- fprintf(stderr, "Unable to read from
/etc/boardname.\n");
+-
+- fclose(fd);
+-
+- return buffer;
++ while (fgets(buffer, MAXSTRING, fd)){
++ if (!*buffer)
++ continue;
++ buflen = strlen(buffer);
++ while(buflen>= 2&& isspace(*buffer)&& (*buffer!='\0')){
++ memmove(buffer,buffer+1,buflen-1);
++ buflen--;
++ }
++ while(buflen>= 1&& isspace(buffer[buflen-1])) buflen--;
++ buffer[buflen]='\0';
++ if(buflen){
++ fclose(fd);
++ return buffer;
++ }
++ }
++
++ fclose(fd);
++ fprintf(stderr, "Unable to read from /etc/boardname.\n");
++
++ return NULL;
+ }
_______________________________________________
MeeGo-commits mailing list
[email protected]
http://lists.meego.com/listinfo/meego-commits
_______________________________________________
MeeGo-packaging mailing list
[email protected]
http://lists.meego.com/listinfo/meego-packaging