On 5/16/2020 11:22 AM, Lokesh Vutla via Linuxptp-devel wrote:
> Hi Richard,
> 
> On 16/05/20 10:44 PM, Richard Cochran wrote:
>> On Sat, May 16, 2020 at 10:35:33PM +0530, Lokesh Vutla wrote:
>>> Hi Richard,
>>>
>>> On 16/05/20 10:24 PM, Richard Cochran wrote:
>>>> On Fri, Apr 17, 2020 at 10:00:09AM +0530, Lokesh Vutla wrote:
>>>>>  phc2pwm.c | 233 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>>>>  2 files changed, 237 insertions(+), 2 deletions(-)
>>>>>  create mode 100644 phc2pwm.c
>>>>
>>>> I wanted to try this today.  There are some issues:
>>>>
>>>> /home/richard/git/linuxptp/phc2pwm.c: In function ‘main’:
>>>> /home/richard/git/linuxptp/phc2pwm.c:222:3: error: ‘period’ may be used 
>>>> uninitialized in this function [-Werror=maybe-uninitialized]
>>>>    pwm_chan_set_period(chan, pwm_servo_sample(&ps, ts));
>>>>    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>> /home/richard/git/linuxptp/phc2pwm.c:193:8: error: ‘ptp_dev’ may be used 
>>>> uninitialized in this function [-Werror=maybe-uninitialized]
>>>>   clkid = phc_open(ptp_dev);
>>>>   ~~~~~~^~~~~~~~~~~~~~~~~~~
>>>> /home/richard/git/linuxptp/phc2pwm.c:203:8: error: ‘event_index’ may be 
>>>> used uninitialized in this function [-Werror=maybe-uninitialized]
>>>>   err = phc_enable_extts(clkid, event_index);
>>>>         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>> /home/richard/git/linuxptp/phc2pwm.c:197:9: error: ‘pwm_chan’ may be used 
>>>> uninitialized in this function [-Werror=maybe-uninitialized]
>>>>   chan = pwm_chan_create(pwm_chip, pwm_chan);
>>>>          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>> /home/richard/git/linuxptp/phc2pwm.c:197:9: error: ‘pwm_chip’ may be used 
>>>> uninitialized in this function [-Werror=maybe-uninitialized]
>>>> cc1: all warnings being treated as errors
>>>
>>> I am using 9.2 arm compiler and the build is successful. Which compiler are 
>>> you
>>> using?
>>
>> gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf
> 
> hmm..that's old. May be time to upgrade.
> 
>>
>> Compile with -Werror please.
> 
> I tried enabling -Werror in makefile, but the repo doesn't build at all with 
> the
> following error:
> clock.c:444:48: error: taking address of packed member of ‘struct
> subscribe_events_np’ may result in an unaligned pointer value
> [-Werror=address-of-packed-member]
>   444 |   clock_get_subscription(c, req, sen->bitmask, &sen->duration);
>       |                                                ^~~~~~~~~~~~~~
> cc1: all warnings being treated as errors
> <builtin>: recipe for target 'clock.o' failed
> 

Yep, the current code doing that is incorrect if the platform can't do
unaligned access.

I'm not sure what actually happens here: will the compiler for such a
platform produce the right code for reading, or will it simply give up
on the unaligned pointers?

I know kernel code uses "get_unaligned" and "put_unaligned" to avoid
this kind of issue.


_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to