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 So, I downgraded my compiler version to 8.3 where address-of-packed-member is not enabled, it still build successfully with out errors, as these values gets assigned as parameters: ~/bin/gcc-arm-8.3-arm/bin/arm-linux-gnueabihf-gcc -Wall -DVER=2.0-00120-g1478162-dirty -D_GNU_SOURCE -DHAVE_CLOCK_ADJTIME -DHAVE_POSIX_SPAWN -DHAVE_ONESTEP_SYNC -Werror -c -o phc2pwm.o phc2pwm.c ~/bin/gcc-arm-8.3-arm/bin/arm-linux-gnueabihf-gcc phc2pwm.o util.o pwm.o phc.o print.o sk.o version.o -lm -lrt -o phc2pwm Anyways Ill post a v2 immediately with checks for NULL values or assign default values wherever appropriate. Thanks and regards, Lokesh _______________________________________________ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel