openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/util-linux/2.33.2-r0/util-linux-2.33.2/sys-utils/hwclock.c
static int save_adjtime(const struct hwclock_control* ctl,
                        const struct adjtime* adjtime)
{
    char* content; /* Stuff to write to disk file */
    FILE* fp;

    xasprintf(&content, "%f %ld %f\n%ld\n%s\n", adjtime->drift_factor,
              adjtime->last_adj_time, adjtime->not_adjusted,
              adjtime->last_calib_time,
              (adjtime->local_utc == LOCAL) ? "LOCAL" : "UTC");

    if (ctl->verbose)
    {
        printf(_("New %s data:\n%s"), ctl->adj_file_name, content);
    }

    if (!ctl->testing)
    {
        fp = fopen(ctl->adj_file_name, "w");
        if (fp == NULL)
        {
            warn(_("cannot open %s"), ctl->adj_file_name);
            return EXIT_FAILURE;
        }
        else if (fputs(content, fp) < 0 || close_stream(fp) != 0)
        {
            warn(_("cannot update %s"), ctl->adj_file_name);
            return EXIT_FAILURE;
        }
    }
    return EXIT_SUCCESS;
}
/*
 * Write the contents of the <adjtime> structure to its disk file.
 *
 * But if the contents are clean (unchanged since read from disk), don't
 * bother.
 */
Write the contents of the  structure to its disk file.
But if the contents are clean (unchanged since read from disk), don't
bother.
Write the contents of the structure to its disk file . But if the contents are clean ( unchanged since read from disk ) don ' t bother .
static int save_adjtime(const struct hwclock_control* ctl,
                        const struct adjtime* adjtime)
{
    char* content; 
    FILE* fp;
    xasprintf(&content, "%f %ld %f\n%ld\n%s\n", adjtime->drift_factor,
              adjtime->last_adj_time, adjtime->not_adjusted,
              adjtime->last_calib_time,
              (adjtime->local_utc == LOCAL) ? "LOCAL" : "UTC");
    if (ctl->verbose)
    {
        printf(_("New %s data:\n%s"), ctl->adj_file_name, content);
    }
    if (!ctl->testing)
    {
        fp = fopen(ctl->adj_file_name, "w");
        if (fp == NULL)
        {
            warn(_("cannot open %s"), ctl->adj_file_name);
            return EXIT_FAILURE;
        }
        else if (fputs(content, fp) < 0 || close_stream(fp) != 0)
        {
            warn(_("cannot update %s"), ctl->adj_file_name);
            return EXIT_FAILURE;
        }
    }
    return EXIT_SUCCESS;
}
static int save_adjtime ( const struct hwclock_control * ctl , const struct adjtime * adjtime ) { char * content ; FILE * fp ; xasprintf ( & content , " \n \n \n " , adjtime -> drift_factor , adjtime -> last_adj_time , adjtime -> not_adjusted , adjtime -> last_calib_time , ( adjtime -> local_utc == LOCAL ) ? " " : " " ) ; if ( ctl -> verbose ) { printf ( _ ( " \n " ) , ctl -> adj_file_name , content ) ; } if ( ! ctl -> testing ) { fp = fopen ( ctl -> adj_file_name , " " ) ; if ( fp == NULL ) { warn ( _ ( " " ) , ctl -> adj_file_name ) ; return EXIT_FAILURE ; } else if ( fputs ( content , fp ) < 0 || close_stream ( fp ) != 0 ) { warn ( _ ( " " ) , ctl -> adj_file_name ) ; return EXIT_FAILURE ; } } return EXIT_SUCCESS ; }
Write the contents of the <adjtime> structure to its disk file.
Write the contents of the <adjtime > structure to its disk file .
/* Stuff to write to disk file */