Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101972 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 73329 invoked from network); 12 Mar 2018 17:18:34 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Mar 2018 17:18:34 -0000 Authentication-Results: pb1.pair.com smtp.mail=php@golemon.com; spf=softfail; sender-id=softfail Authentication-Results: pb1.pair.com header.from=php@golemon.com; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain golemon.com does not designate 209.85.220.175 as permitted sender) X-PHP-List-Original-Sender: php@golemon.com X-Host-Fingerprint: 209.85.220.175 mail-qk0-f175.google.com Received: from [209.85.220.175] ([209.85.220.175:40051] helo=mail-qk0-f175.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DE/AF-24487-966B6AA5 for ; Mon, 12 Mar 2018 12:18:33 -0500 Received: by mail-qk0-f175.google.com with SMTP id o25so12240008qkl.7 for ; Mon, 12 Mar 2018 10:18:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=golemon-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=vYkWCoFPDOOgVNhrZvVYmDCRTv0xmRWW3c23Mi/VtB0=; b=HWKu0bmmd4wb7vOTEug6lp+S7QmLydmtRpJWOpoAcE/GOZShOsYd0eqr35vagR1gJr EnOGmHWDNb0D7TQh4mh5F6SVMDv2B0Bs1+JL0CVQBASEWgBmPGMka2CM0nNRaU8e6ksS er+vfREmbSdzidGhiBTjDo85c/UMzh8RcYm2bL7PBQI8euqi3ZtOXefDForwf91FBvCE xzxzyyGYyLE41QrC6Y14NzEvRlcRT0f8Zp0MbYqxAMtlvcRD/6gyNOCCp/CtnLaYmtGv ts/d8ZZumJrKAJc6rSpfkGCstbgphyXTa6B7xgxQ6hDQ8a/M44gcyyPUJvuXz8hDaOMB qrUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=vYkWCoFPDOOgVNhrZvVYmDCRTv0xmRWW3c23Mi/VtB0=; b=N3rqhWHQBVSifagdKJUJ+lccfYfC8moL7VrnEZl6uJ3h092tCO5ljlFxGOEcD+zL28 vSHSg8Foz7OFENH8kBdRGC6ZRqLdSU8MQZUGNVpX7IwYeRrkfHQK9Q6t+DnctA10yi9a zKGBootiBgSL/cU2xr477f38Fgq0SMLhfXOidnA6I4gOfyNlyWs7xHMzTShWWDP1yX4r 25XB25gcIQjvCCXLqbSznTjdyGmGCiApgostww77nPSbJ69diZvZ05uB7/UkVtyX15tE U7zM224gW4oPkzGFHuMZhfeKmLjrTUDgHKQUN3jh59t2N2BS7xeE7AUIBTpYcqejRnPA D9WA== X-Gm-Message-State: AElRT7GmSrSC5GemymZFtE2IKkb4ZsDPhGgx36r+DzloGNZBP2JhRhXj 9UhLzqJm9ySLe9UoO2ujJ+KgZ1Q9z/3M82ExSNCUkA== X-Google-Smtp-Source: AG47ELsD4R2wxQZ/Qll2I4duUoH5t9ygkM1gkCC+DqeRgAjc0odN66zq8C4jys0e2Yv2sDcbvZgAh6i5n2Dim2fYCR4= X-Received: by 10.55.78.134 with SMTP id c128mr12972899qkb.226.1520875110717; Mon, 12 Mar 2018 10:18:30 -0700 (PDT) MIME-Version: 1.0 Sender: php@golemon.com Received: by 10.12.155.169 with HTTP; Mon, 12 Mar 2018 10:18:30 -0700 (PDT) X-Originating-IP: [206.252.215.26] In-Reply-To: <64.2E.24487.2D7A6AA5@pb1.pair.com> References: <64.2E.24487.2D7A6AA5@pb1.pair.com> Date: Mon, 12 Mar 2018 13:18:30 -0400 X-Google-Sender-Auth: 2xQapynj7ZsyYFODi6Zs1N7EK8w Message-ID: To: Richard Klingler Cc: PHP internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] Migrating php extension from 5 to 7, ZVAL_STRINGL no value returned From: pollita@php.net (Sara Golemon) On Mon, Mar 12, 2018 at 12:16 PM, Richard Klingler wrote: > ZEND_FUNCTION(readmydevice) > { > zend_long n; > zval *z; > size_t len; > char *p; > long r; > > if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lzl", &n, > &z, &len) == FAILURE) { > return; > } > > p = (char *) emalloc(len + 1); > memset(p,0,len+1); > > r = myread(n, p, len); > printf("Read %d bytes from device %d up to %d bytes\n", mycount, > n, len); > p[ibcnt] = '\0'; > ZVAL_STRINGL(z, p, mycount); > printf("Returned %s\n", p); > efree(p); > RETURN_LONG(r); > } > > > Any ideas why ZVAL_STRINGL is not doing anything? > Or did I miss something? > Well, ZVAL_STRINGL is probably doing something, but there are two reasons there's no way to be certain: 1. What is 'mycount' and where does it come from / how is it set? If it's zero, then you'll be saving a zero length string. In any case, it doesn't seem to have any relationship to the data read into `p`. I'm guessing you wanted to use `r` rather than `mycount` both here and in your debug message. 2. I'm inferring that you want argument 2 to your function to be a pass-by-ref argument. Are you specifying any arg_info in the function entry list? (where you have your PHP_FE macro -- or perhaps ZEND_FE macro, since you seem to be using those versions). In order to pass by ref, you need that structure to specify that the argument is by-ref. This *might* have worked without it in PHP 5, but only by accident and would have probably failed in hard-to-diagnose ways. 2a. Also, when using by-ref args, you need to destruct any previously held value. In this case, with a zval_dtor(z); prior to the ZVAL_STRINGL() macro. -Sara