Re: [PATCH v6 2/4] virtio_rtc: Add PTP clocks

From: kernel test robot
Date: Tue Mar 18 2025 - 18:57:43 EST


Hi Peter,

kernel test robot noticed the following build warnings:

[auto build test WARNING on 9d8960672d63db4b3b04542f5622748b345c637a]

url: https://github.com/intel-lab-lkp/linux/commits/Peter-Hilber/virtio_rtc-Add-module-and-driver-core/20250314-014130
base: 9d8960672d63db4b3b04542f5622748b345c637a
patch link: https://lore.kernel.org/r/20250313173707.1492-3-quic_philber%40quicinc.com
patch subject: [PATCH v6 2/4] virtio_rtc: Add PTP clocks
config: sparc-allyesconfig (https://download.01.org/0day-ci/archive/20250319/202503190602.IElWB74j-lkp@xxxxxxxxx/config)
compiler: sparc64-linux-gcc (GCC) 7.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250319/202503190602.IElWB74j-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202503190602.IElWB74j-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

drivers/virtio/virtio_rtc_driver.c: In function 'viortc_probe':
>> drivers/virtio/virtio_rtc_driver.c:665:23: warning: '/variant ' directive output may be truncated writing 9 bytes into a region of size between 6 and 15 [-Wformat-truncation=]
"Virtio PTP type %d/variant %d", clock_type,
^~~~~~~~~
drivers/virtio/virtio_rtc_driver.c:665:4: note: directive argument in the range [0, 2147483647]
"Virtio PTP type %d/variant %d", clock_type,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/virtio/virtio_rtc_driver.c:664:2: note: 'snprintf' output between 28 and 46 bytes into a destination of size 32
snprintf(ptp_clock_name, PTP_CLOCK_NAME_LEN,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"Virtio PTP type %d/variant %d", clock_type,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
leap_second_smearing);
~~~~~~~~~~~~~~~~~~~~~


vim +665 drivers/virtio/virtio_rtc_driver.c

641
642 /*
643 * init, deinit
644 */
645
646 /**
647 * viortc_init_ptp_clock() - init and register PTP clock
648 * @viortc: device data
649 * @vio_clk_id: virtio_rtc clock id
650 * @clock_type: virtio_rtc clock type
651 * @leap_second_smearing: virtio_rtc leap second smearing
652 *
653 * Context: Process context.
654 * Return: Positive if registered, zero if not supported by configuration,
655 * negative error code otherwise.
656 */
657 static int viortc_init_ptp_clock(struct viortc_dev *viortc, u16 vio_clk_id,
658 u8 clock_type, u8 leap_second_smearing)
659 {
660 struct device *dev = &viortc->vdev->dev;
661 char ptp_clock_name[PTP_CLOCK_NAME_LEN];
662 struct viortc_ptp_clock *vio_ptp;
663
664 snprintf(ptp_clock_name, PTP_CLOCK_NAME_LEN,
> 665 "Virtio PTP type %d/variant %d", clock_type,
666 leap_second_smearing);
667
668 vio_ptp = viortc_ptp_register(viortc, dev, vio_clk_id, ptp_clock_name);
669 if (IS_ERR(vio_ptp)) {
670 dev_err(dev, "failed to register PTP clock '%s'\n",
671 ptp_clock_name);
672 return PTR_ERR(vio_ptp);
673 }
674
675 viortc->clocks_to_unregister[vio_clk_id] = vio_ptp;
676
677 return !!vio_ptp;
678 }
679

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki