RFC: vmware registration

Jim Meyering jim at meyering.net
Thu May 26 19:57:04 UTC 2011


Pete Zaitcev wrote:
> On Thu, 26 May 2011 11:53:23 +0200
> Jim Meyering <jim at meyering.net> wrote:
>
>> With this patch, everything compiles warning-free:
>
> Yeah, but that's not the objective here... This is a problem:
>
>> @@ -651,14 +651,6 @@ static void poke_Login(struct config *cfg, struct session *ses,
>>  	ns_env = xmlNewNs(etroot,
>>  	    BAD_CAST "http://schemas.xmlsoap.org/soap/envelope/",
>>  	    BAD_CAST "SOAP-ENV");
>> -	ns_enc = xmlNewNs(etroot,
>> -	    BAD_CAST "http://schemas.xmlsoap.org/soap/encoding/",
>> -	    BAD_CAST "SOAP-ENC");
>> -	ns_xsi = xmlNewNs(etroot,
>> -	    BAD_CAST "http://www.w3.org/2001/XMLSchema-instance",
>> -	    BAD_CAST "xsi");
>> -	ns_xsd = xmlNewNs(etroot,
>> -	    BAD_CAST "http://www.w3.org/2001/XMLSchema", BAD_CAST "xsd");
>>  	ns_v = xmlNewNs(etroot, BAD_CAST "urn:vim25", BAD_CAST "v");
>>  	xmlSetNs(etroot, ns_env);
>
> I found that VMware for some reason is picky about namespaces, even
> unused ones. It would definitely reject an XML that does not have them.
> Why, I have no idea.

If they're required, then no problem to leave them, of course.
But if they're required, then we shouldn't ignore failure.

> The right approach is probably xmlNewNs to (void).

Since xmlNewNs can fail (i.e., return NULL),
please check for that.  I would do that by writing a trivial
wrapper, say "void xxmlNewNs(...", that just calls xmlNewNs and diagnoses
any NULL return.  Then you can just s/xmlNewNs/xxmlNewNs/ and
still remove those variable declarations.

>> @@ -2400,8 +2336,9 @@ static void run_upload(struct config *cfg, struct session *ses,
>>  	if (uploader == 0) {
>>  		v_upload(cfg, ses, 0, url, tfd);
>>  		status = 3;
>> -		write(pipe_up_report[1], &status, 1);
>> -		exit(0);
>> +		int err = (write(pipe_up_report[1], &status, 1) == 1
>> +			   ? EXIT_SUCCESS : EXIT_FAILURE);
>> +		exit(err);
>>  	}
>
> Heh. I think EPIPE here is going to mean that nobody is there
> to fetch the exit status.

The point is not to ignore write's return value.
If you find a better way to do it, that's fine, too.

>> @@ -2503,13 +2440,13 @@ static void convert(const char *fname, off_t
>> vol_size, int vfd)
>>  	struct GrainMarker *gm;
>>  	struct MetaDataMarker gtmarker, gdmarker, eosmarker, footmarker;
>>  	unsigned int *currentGrainTable, *grainDirectory;
>> -	int cgx, gdx;
>> +	unsigned long cgx, gdx;
>
> What, seriously? Wow.

The important thing is that they be unsigned.
If you prefer "unsigned int", I don't really mind.

>> -	int i;
>> +	unsigned int i;


More information about the iwhd-devel mailing list