FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Red Hat Install

 
 
LinkBack Thread Tools
 
Old 03-23-2010, 06:38 AM
Ales Kozumplik
 
Default Remove isys/str.c, replace calls with glib.h or string.h calls.

Hi,


On 03/22/2010 10:07 PM, David Cantrell wrote:

str.c was from a time when loader was still a statically linked binary.
Times have changed. Removed str.c and replaced calls with either
string.h or glib.h functions.

For g_ascii_strup() and g_ascii_strdown(), those functions dup the
passed in string, change it, and return that.
---
- } else if (strcount(str, ':')> 1) {
+ } else if (strstr(str, ":")) {


Or even strchr(str, ':') ?



Ales

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 03-23-2010, 02:54 PM
"Brian C. Lane"
 
Default Remove isys/str.c, replace calls with glib.h or string.h calls.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 03/23/2010 12:38 AM, Ales Kozumplik wrote:
> Hi,
>
>
> On 03/22/2010 10:07 PM, David Cantrell wrote:
>> str.c was from a time when loader was still a statically linked binary.
>> Times have changed. Removed str.c and replaced calls with either
>> string.h or glib.h functions.
>>
>> For g_ascii_strup() and g_ascii_strdown(), those functions dup the
>> passed in string, change it, and return that.
>> ---
>> - } else if (strcount(str, ':')> 1) {
>> + } else if (strstr(str, ":")) {
>
> Or even strchr(str, ':') ?

Actually, per the IRC discussion that doesn't do the same thing. The
else block below this expects an ipv4 address with optional ort at the
end so this compare needs to check for 2 colons to confirm that it is an
ipv6 address.

It also needs to handle the case where there are no colons, so comparing
a strchr and a strrchr doesn't work either. I think it needs to look
like this:

} else if ((strchr(str, ':') != NULL) && (strchr(str, ':') !=
strrchr(str, ':'))) {

I don't like calling strchr 2 times, but that's probably about as clean
as adding a temporary char *p to hold the results for the 2nd check.

- --
Brian C. Lane <bcl@redhat.com>
Red Hat / Port Orchard, WA
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iQEVAwUBS6jkTBF+jBaO/jp/AQLgIwgAkb0apSTTGJJitkvM+pBOPvq2Oj4aT7j+
586NiLyVcD+eKmnQ/g24mtsJ8DYTvtDgc/PwYCdVd8JPqY+oo72CV/3fvDEvX7Mi
OkOP+Oo6MrzgcbA9g9mVTs41OY1Yg2SRSnJfw09q2hgR4pXB4f 74cm+yjqcF3wpu
sdR893lWaTULziO4Gf86Sa/D2Dmpfq+iKi4sDMqD9bads9LCcrI2PvCO+5/ufvK1
jq3IMke57wnKiWQrZYeqPKw66WgZbnvoWE8SbtChh27TR5PJ/s6GFUocoucjtAqH
sLfkDqU3Q0xJlielYuobqlqTGf1kVWjI6ToDLNEMR4NZ/WI+6JUJIA==
=o4iF
-----END PGP SIGNATURE-----

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 03-24-2010, 03:59 PM
David Cantrell
 
Default Remove isys/str.c, replace calls with glib.h or string.h calls.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tue, 23 Mar 2010, Brian C. Lane wrote:


On 03/23/2010 12:38 AM, Ales Kozumplik wrote:

Hi,


On 03/22/2010 10:07 PM, David Cantrell wrote:

str.c was from a time when loader was still a statically linked binary.
Times have changed. Removed str.c and replaced calls with either
string.h or glib.h functions.

For g_ascii_strup() and g_ascii_strdown(), those functions dup the
passed in string, change it, and return that.
---
- } else if (strcount(str, ':')> 1) {
+ } else if (strstr(str, ":")) {


Or even strchr(str, ':') ?


Actually, per the IRC discussion that doesn't do the same thing. The
else block below this expects an ipv4 address with optional ort at the
end so this compare needs to check for 2 colons to confirm that it is an
ipv6 address.

It also needs to handle the case where there are no colons, so comparing
a strchr and a strrchr doesn't work either. I think it needs to look
like this:

} else if ((strchr(str, ':') != NULL) && (strchr(str, ':') !=
strrchr(str, ':'))) {


This check still doesn't make sure we have more than one colon. strrchr()
could still return NULL here but the test to make sure it doesn't equal the
first colon still passes.


I don't like calling strchr 2 times, but that's probably about as clean
as adding a temporary char *p to hold the results for the 2nd check.


How about this revision:

diff --git a/loader/net.c b/loader/net.c
index afbc6d8..a987050 100644
- --- a/loader/net.c
+++ b/loader/net.c
@@ -2004,6 +2004,8 @@ int kickstartNetworkUp(struct loaderData_s * loaderData,
i
void splitHostname (char *str, char **host, char **port)
{
char *rightbrack = strchr(str, ']');
+ char *firstcolon = strchr(str, ':');
+ char *secondcolon = strrchr(str, ':');

*host = NULL;
*port = NULL;
@@ -2020,7 +2022,7 @@ void splitHostname (char *str, char **host, char **port)
}
else
*host = strndup(str+1, rightbrack-1-str);
- - } else if (strstr(str, ":")) {
+ } else if (firstcolon && secondcolon && firstcolon != secondcolon) {
/* An IPv6 address without brackets. Don't make the user surround
* the
* address with brackets if there's no port number.
*/

- --
David Cantrell <dcantrell@redhat.com>

Red Hat / Honolulu, HI

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAkuqRQ4ACgkQ5hsjjIy1VklkWwCdHT7YHhlfDl rsahae/wPMix4H
/w4AmQEd1tGlUjs6rtJD/7FggdbIXIOv
=umHb
-----END PGP SIGNATURE-----

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 03-24-2010, 04:11 PM
"Brian C. Lane"
 
Default Remove isys/str.c, replace calls with glib.h or string.h calls.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 03/24/2010 09:59 AM, David Cantrell wrote:
> On Tue, 23 Mar 2010, Brian C. Lane wrote:
>

>> } else if ((strchr(str, ':') != NULL) && (strchr(str, ':') !=
>> strrchr(str, ':'))) {
>
> This check still doesn't make sure we have more than one colon. strrchr()
> could still return NULL here but the test to make sure it doesn't equal the
> first colon still passes.

Whoops, good point.

>
>> I don't like calling strchr 2 times, but that's probably about as clean
>> as adding a temporary char *p to hold the results for the 2nd check.
>
> How about this revision:
>
> diff --git a/loader/net.c b/loader/net.c
> index afbc6d8..a987050 100644
> --- a/loader/net.c
> +++ b/loader/net.c
> @@ -2004,6 +2004,8 @@ int kickstartNetworkUp(struct loaderData_s *
> loaderData,
> i
> void splitHostname (char *str, char **host, char **port)
> {
> char *rightbrack = strchr(str, ']');
> + char *firstcolon = strchr(str, ':');
> + char *secondcolon = strrchr(str, ':');
>
> *host = NULL;
> *port = NULL;
> @@ -2020,7 +2022,7 @@ void splitHostname (char *str, char **host, char
> **port)
> }
> else
> *host = strndup(str+1, rightbrack-1-str);
> - } else if (strstr(str, ":")) {
> + } else if (firstcolon && secondcolon && firstcolon != secondcolon) {
> /* An IPv6 address without brackets. Don't make the user surround
> * the
> * address with brackets if there's no port number.
> */

Yeah, that looks good to me.

- --
Brian C. Lane <bcl@redhat.com>
Red Hat / Port Orchard, WA
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iQEVAwUBS6pH0BF+jBaO/jp/AQJ2kQf/Zk34Qydkz8D/9rt+uvOGZhw3qXZGOa95
SkOXy/q2zx6CufbtWTn04/LToo7aZT1i6O25ZEJnltWNPZGQLvp+cHGErFF7PhTL
XshqOb0S6klX9UbVxgbn1//xOvgbKo/FUJ4IiRfmDYfD2MMo6w522863cbqKE5tM
tSrMqb2TCkDpbNDnxkFs/9vcwxf78TqwISA1oVGvcAAUbewZFzr3MjQ5hc/8Q3DN
2wpkZGrBZqrbILODucKR0fDEZFGUks+Gfq5aQRqH8iJWyQxcXq VGN6Uo2a9t96Ue
EfX5OXVJsody45sYG/NZufLssiM0LzL1BOVcowAkTo0ziTkG8YEe7w==
=6yDS
-----END PGP SIGNATURE-----

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 

Thread Tools




All times are GMT. The time now is 04:09 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org