diff options
author | Jan Synacek <jsynacek@redhat.com> | 2013-09-18 08:33:03 +0200 |
---|---|---|
committer | Jan Synacek <jsynacek@redhat.com> | 2013-09-18 15:19:30 +0200 |
commit | cd13c983a49ce3685a3813e66001bd3ea8f796c8 (patch) | |
tree | c79386678dbfdbfbdbbccb48d690f7cd3f475c50 /src/logicalfile/LMI_UnixDeviceFileProvider.c | |
parent | 2746832524f5e5d022b13ffa0890f895ab82355c (diff) | |
download | openlmi-providers-cd13c983a49ce3685a3813e66001bd3ea8f796c8.tar.gz openlmi-providers-cd13c983a49ce3685a3813e66001bd3ea8f796c8.tar.xz openlmi-providers-cd13c983a49ce3685a3813e66001bd3ea8f796c8.zip |
logicalfile: code cleanup and rewrite
GetInstance() calls were rewritten using cleaner code. Also, the macros
that were used before were either rewritten to functions, or cleaned up
so they wouldn't return or do anything unexpected.
Helper functions now use CMPIStatus more consistently.
Some memory leaks were fixed.
Diffstat (limited to 'src/logicalfile/LMI_UnixDeviceFileProvider.c')
-rw-r--r-- | src/logicalfile/LMI_UnixDeviceFileProvider.c | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/src/logicalfile/LMI_UnixDeviceFileProvider.c b/src/logicalfile/LMI_UnixDeviceFileProvider.c index 4d09efa..6a707f8 100644 --- a/src/logicalfile/LMI_UnixDeviceFileProvider.c +++ b/src/logicalfile/LMI_UnixDeviceFileProvider.c @@ -61,23 +61,18 @@ static CMPIStatus LMI_UnixDeviceFileGetInstance( const CMPIObjectPath* cop, const char** properties) { - LMI_UnixDeviceFile lmi_file; - const char *path; - char tmp[16]; - - LMI_UnixDeviceFile_InitFromObjectPath(&lmi_file, _cb, cop); - path = KChars(lmi_file.Name.value); - fill_basic(UnixDeviceFile, path, S_IFCHR | S_IFBLK, "No such device: %s"); - - sprintf(tmp, "%lu", sb.st_rdev); - LMI_UnixDeviceFile_Set_DeviceId(&lmi_file, tmp); - sprintf(tmp, "%u", major(sb.st_rdev)); - LMI_UnixDeviceFile_Set_DeviceMajor(&lmi_file, tmp); - sprintf(tmp, "%u", minor(sb.st_rdev)); - LMI_UnixDeviceFile_Set_DeviceMinor(&lmi_file, tmp); - - KReturnInstance(cr, lmi_file); - CMReturn(CMPI_RC_OK); + CMPIStatus st = {.rc = CMPI_RC_OK}; + logicalfile_t logicalfile; + + st = lmi_check_required(_cb, cop); + check_status(st); + + LMI_UnixDeviceFile_InitFromObjectPath(&logicalfile.lf.unixdevicefile, _cb, cop); + st = stat_logicalfile_and_fill(_cb, &logicalfile, S_IFCHR | S_IFBLK, "No such device: %s"); + check_status(st); + + KReturnInstance(cr, logicalfile.lf.unixdevicefile); + return st; } static CMPIStatus LMI_UnixDeviceFileCreateInstance( @@ -160,3 +155,6 @@ KONKRET_REGISTRATION( "LMI_UnixDeviceFile", "instance method") /* vi: set et: */ +/* Local Variables: */ +/* indent-tabs-mode: nil */ +/* End: */ |